25 $objWriter =
new XMLWriter(XMLWriter::STORAGE_MEMORY);
29 $objWriter->startDocument(
'1.0',
'UTF-8');
32 $objWriter->startElement(
'office:document-meta');
34 $objWriter->writeAttribute(
'xmlns:office',
'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
35 $objWriter->writeAttribute(
'xmlns:xlink',
'http://www.w3.org/1999/xlink');
36 $objWriter->writeAttribute(
'xmlns:dc',
'http://purl.org/dc/elements/1.1/');
37 $objWriter->writeAttribute(
'xmlns:meta',
'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
38 $objWriter->writeAttribute(
'xmlns:ooo',
'http://openoffice.org/2004/office');
39 $objWriter->writeAttribute(
'xmlns:grddl',
'http://www.w3.org/2003/g/data-view#');
40 $objWriter->writeAttribute(
'office:version',
'1.2');
42 $objWriter->startElement(
'office:meta');
44 $objWriter->writeElement(
'meta:initial-creator', $spreadsheet->getProperties()->getCreator());
45 $objWriter->writeElement(
'dc:creator', $spreadsheet->getProperties()->getCreator());
46 $created = $spreadsheet->getProperties()->getCreated();
48 $date->setTimeZone(Date::getDefaultOrLocalTimeZone());
49 $objWriter->writeElement(
'meta:creation-date', $date->format(DATE_W3C));
50 $created = $spreadsheet->getProperties()->getModified();
52 $date->setTimeZone(Date::getDefaultOrLocalTimeZone());
53 $objWriter->writeElement(
'dc:date', $date->format(DATE_W3C));
54 $objWriter->writeElement(
'dc:title', $spreadsheet->getProperties()->getTitle());
55 $objWriter->writeElement(
'dc:description', $spreadsheet->getProperties()->getDescription());
56 $objWriter->writeElement(
'dc:subject', $spreadsheet->getProperties()->getSubject());
57 $objWriter->writeElement(
'meta:keyword', $spreadsheet->getProperties()->getKeywords());
66 $objWriter->startElement(
'meta:user-defined');
67 $objWriter->writeAttribute(
'meta:name',
'Company');
68 $objWriter->writeRaw($spreadsheet->getProperties()->getCompany());
69 $objWriter->endElement();
71 $objWriter->startElement(
'meta:user-defined');
72 $objWriter->writeAttribute(
'meta:name',
'category');
73 $objWriter->writeRaw($spreadsheet->getProperties()->getCategory());
74 $objWriter->endElement();
76 self::writeDocPropsCustom($objWriter, $spreadsheet);
78 $objWriter->endElement();
80 $objWriter->endElement();
82 return $objWriter->getData();
87 $customPropertyList = $spreadsheet->
getProperties()->getCustomProperties();
88 foreach ($customPropertyList as
$key => $customProperty) {
89 $propertyValue = $spreadsheet->
getProperties()->getCustomPropertyValue($customProperty);
90 $propertyType = $spreadsheet->
getProperties()->getCustomPropertyType($customProperty);
92 $objWriter->startElement(
'meta:user-defined');
93 $objWriter->writeAttribute(
'meta:name', $customProperty);
95 switch ($propertyType) {
96 case Properties::PROPERTY_TYPE_INTEGER:
97 case Properties::PROPERTY_TYPE_FLOAT:
98 $objWriter->writeAttribute(
'meta:value-type',
'float');
102 case Properties::PROPERTY_TYPE_BOOLEAN:
103 $objWriter->writeAttribute(
'meta:value-type',
'boolean');
104 $objWriter->
writeRawData($propertyValue ?
'true' :
'false');
107 case Properties::PROPERTY_TYPE_DATE:
108 $objWriter->writeAttribute(
'meta:value-type',
'date');
119 $objWriter->endElement();
writeRawData($text)
Wrapper method for writeRaw.
getProperties()
Get properties.
getDiskCachingDirectory()
Get disk caching directory.
getParentWriter()
Get Ods writer.
static dateTimeFromTimestamp(string $date, ?DateTimeZone $timeZone=null)
getUseDiskCaching()
Get use disk caching where possible?