24 $objWriter =
new XMLWriter(XMLWriter::STORAGE_MEMORY);
28 $objWriter->startDocument(
'1.0',
'UTF-8',
'yes');
31 $objWriter->startElement(
'Properties');
32 $objWriter->writeAttribute(
'xmlns',
'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties');
33 $objWriter->writeAttribute(
'xmlns:vt',
'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
36 $objWriter->writeElement(
'Application',
'Microsoft Excel');
39 $objWriter->writeElement(
'DocSecurity',
'0');
42 $objWriter->writeElement(
'ScaleCrop',
'false');
45 $objWriter->startElement(
'HeadingPairs');
48 $objWriter->startElement(
'vt:vector');
49 $objWriter->writeAttribute(
'size',
'2');
50 $objWriter->writeAttribute(
'baseType',
'variant');
53 $objWriter->startElement(
'vt:variant');
54 $objWriter->writeElement(
'vt:lpstr',
'Worksheets');
55 $objWriter->endElement();
58 $objWriter->startElement(
'vt:variant');
59 $objWriter->writeElement(
'vt:i4', $spreadsheet->
getSheetCount());
60 $objWriter->endElement();
62 $objWriter->endElement();
64 $objWriter->endElement();
67 $objWriter->startElement(
'TitlesOfParts');
70 $objWriter->startElement(
'vt:vector');
71 $objWriter->writeAttribute(
'size', $spreadsheet->
getSheetCount());
72 $objWriter->writeAttribute(
'baseType',
'lpstr');
75 for (
$i = 0;
$i < $sheetCount; ++
$i) {
76 $objWriter->writeElement(
'vt:lpstr', $spreadsheet->
getSheet(
$i)->getTitle());
79 $objWriter->endElement();
81 $objWriter->endElement();
84 $objWriter->writeElement(
'Company', $spreadsheet->
getProperties()->getCompany());
87 $objWriter->writeElement(
'Manager', $spreadsheet->
getProperties()->getManager());
90 $objWriter->writeElement(
'LinksUpToDate',
'false');
93 $objWriter->writeElement(
'SharedDoc',
'false');
96 $objWriter->writeElement(
'HyperlinksChanged',
'false');
99 $objWriter->writeElement(
'AppVersion',
'12.0000');
101 $objWriter->endElement();
104 return $objWriter->getData();
119 $objWriter =
new XMLWriter(XMLWriter::STORAGE_MEMORY);
123 $objWriter->startDocument(
'1.0',
'UTF-8',
'yes');
126 $objWriter->startElement(
'cp:coreProperties');
127 $objWriter->writeAttribute(
'xmlns:cp',
'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
128 $objWriter->writeAttribute(
'xmlns:dc',
'http://purl.org/dc/elements/1.1/');
129 $objWriter->writeAttribute(
'xmlns:dcterms',
'http://purl.org/dc/terms/');
130 $objWriter->writeAttribute(
'xmlns:dcmitype',
'http://purl.org/dc/dcmitype/');
131 $objWriter->writeAttribute(
'xmlns:xsi',
'http://www.w3.org/2001/XMLSchema-instance');
134 $objWriter->writeElement(
'dc:creator', $spreadsheet->
getProperties()->getCreator());
137 $objWriter->writeElement(
'cp:lastModifiedBy', $spreadsheet->
getProperties()->getLastModifiedBy());
140 $objWriter->startElement(
'dcterms:created');
141 $objWriter->writeAttribute(
'xsi:type',
'dcterms:W3CDTF');
144 $objWriter->writeRawData($date->format(DATE_W3C));
145 $objWriter->endElement();
148 $objWriter->startElement(
'dcterms:modified');
149 $objWriter->writeAttribute(
'xsi:type',
'dcterms:W3CDTF');
152 $objWriter->writeRawData($date->format(DATE_W3C));
153 $objWriter->endElement();
156 $objWriter->writeElement(
'dc:title', $spreadsheet->
getProperties()->getTitle());
159 $objWriter->writeElement(
'dc:description', $spreadsheet->
getProperties()->getDescription());
162 $objWriter->writeElement(
'dc:subject', $spreadsheet->
getProperties()->getSubject());
165 $objWriter->writeElement(
'cp:keywords', $spreadsheet->
getProperties()->getKeywords());
168 $objWriter->writeElement(
'cp:category', $spreadsheet->
getProperties()->getCategory());
170 $objWriter->endElement();
173 return $objWriter->getData();
183 $customPropertyList = $spreadsheet->
getProperties()->getCustomProperties();
184 if (empty($customPropertyList)) {
193 $objWriter =
new XMLWriter(XMLWriter::STORAGE_MEMORY);
197 $objWriter->startDocument(
'1.0',
'UTF-8',
'yes');
200 $objWriter->startElement(
'Properties');
201 $objWriter->writeAttribute(
'xmlns',
'http://schemas.openxmlformats.org/officeDocument/2006/custom-properties');
202 $objWriter->writeAttribute(
'xmlns:vt',
'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
204 foreach ($customPropertyList as
$key => $customProperty) {
205 $propertyValue = $spreadsheet->
getProperties()->getCustomPropertyValue($customProperty);
206 $propertyType = $spreadsheet->
getProperties()->getCustomPropertyType($customProperty);
208 $objWriter->startElement(
'property');
209 $objWriter->writeAttribute(
'fmtid',
'{D5CDD505-2E9C-101B-9397-08002B2CF9AE}');
210 $objWriter->writeAttribute(
'pid',
$key + 2);
211 $objWriter->writeAttribute(
'name', $customProperty);
213 switch ($propertyType) {
214 case Properties::PROPERTY_TYPE_INTEGER:
215 $objWriter->writeElement(
'vt:i4', $propertyValue);
218 case Properties::PROPERTY_TYPE_FLOAT:
219 $objWriter->writeElement(
'vt:r8', $propertyValue);
222 case Properties::PROPERTY_TYPE_BOOLEAN:
223 $objWriter->writeElement(
'vt:bool', ($propertyValue) ?
'true' :
'false');
226 case Properties::PROPERTY_TYPE_DATE:
227 $objWriter->startElement(
'vt:filetime');
229 $objWriter->writeRawData($date->format(DATE_W3C));
230 $objWriter->endElement();
234 $objWriter->writeElement(
'vt:lpwstr', $propertyValue);
239 $objWriter->endElement();
242 $objWriter->endElement();
244 return $objWriter->getData();
getSheet($pIndex)
Get sheet by index.
writeDocPropsApp(Spreadsheet $spreadsheet)
Write docProps/app.xml to XML format.
getProperties()
Get properties.
getDiskCachingDirectory()
Get disk caching directory.
getParentWriter()
Get parent Xlsx object.
static dateTimeFromTimestamp(string $date, ?DateTimeZone $timeZone=null)
writeDocPropsCore(Spreadsheet $spreadsheet)
Write docProps/core.xml to XML format.
getUseDiskCaching()
Get use disk caching where possible?
writeDocPropsCustom(Spreadsheet $spreadsheet)
Write docProps/custom.xml to XML format.
getSheetCount()
Get sheet count.