Я пытаюсь создать таблицы OpenDocument с использованием PHP. Это мой код:Создание таблиц OpenDocument с PHP
$content_xml = '<?xml version="1.0" encoding="UTF-8"?><office:document-content ...';
$file = 'spreadsheet.ods'; // this one is beeing generated. It is not existent yet...
$zipfile = 'container.zip'; // this one already exists. It's in the same directory
// this script is in. I created the container.zip by unziping a usual .ods file,
// removing the content.xml and ziping again
$handle1 = fopen($zipfile, "r");
$handle2 = fopen($file, "w");
// writing the content of the `container.zip` to the `spreadsheet.ods`
fwrite($handle2, fread($handle1, filesize($zipfile)));
fclose($handle1);
fclose($handle2);
$zip = new ZipArchive();
$zip->open($file, ZIPARCHIVE::CREATE);
// adding the xml string to the zip file
$zip->addFromString('content.xml',$content_xml);
$zip->close();
header('Content-disposition: attachment; filename="'.$file.'"');
header('Content-Type: application/vnd.oasis.opendocument.spreadsheet');
header('Content-Length: ' . filesize($file));
readfile($file);
unlink($file);
Если открыть сгенерированный файл с OpenOffice - все выглядит нормально. Но MS Excel по какой-то причине не может открыть файл. Я думаю, что строка XML в $content_xml
повреждена. Я не хочу никого беспокоить этой струной - она огромная! Я получил его из простой таблицы ods. Я только что отредактировал часть <office:body>...</office:body>
.
Я задаюсь вопросом, является ли это хорошим способом создания электронных таблиц. Кто-нибудь знает учебник для выполнения этой задачи:
- сделать все, что почтовый StuFF
- структуру простого content.xml в ODS файла
Что касается «1. делать все, что почтовый материал» : что я делаю здесь генерировании content.xml
и добавив его в корень структуры .ods
Configurations2 // Folder
META-INF // Folder
Thumbnails // Folder
meta.xml
mimetype
settings.xml
styles.xml
Поступая
$zip->addFromString('content.xml',$content_xml);
Но как я могу добавить файл НЕ в корень структуры, но (давайте говорить) в Configurations2/images/Bitmamps
?
спасибо! ........................... – esviko