26 $objWriter =
new XMLWriter(XMLWriter::STORAGE_MEMORY);
30 $objWriter->startDocument(
'1.0',
'UTF-8',
'yes');
33 $objWriter->startElement(
'workbook');
34 $objWriter->writeAttribute(
'xml:space',
'preserve');
35 $objWriter->writeAttribute(
'xmlns',
'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
36 $objWriter->writeAttribute(
'xmlns:r',
'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
56 (
new DefinedNamesWriter($objWriter, $spreadsheet))->
write();
61 $objWriter->endElement();
64 return $objWriter->getData();
74 $objWriter->startElement(
'fileVersion');
75 $objWriter->writeAttribute(
'appName',
'xl');
76 $objWriter->writeAttribute(
'lastEdited',
'4');
77 $objWriter->writeAttribute(
'lowestEdited',
'4');
78 $objWriter->writeAttribute(
'rupBuild',
'4505');
79 $objWriter->endElement();
89 $objWriter->startElement(
'workbookPr');
92 $objWriter->writeAttribute(
'date1904',
'1');
95 $objWriter->writeAttribute(
'codeName',
'ThisWorkbook');
97 $objWriter->endElement();
108 $objWriter->startElement(
'bookViews');
111 $objWriter->startElement(
'workbookView');
116 $objWriter->writeAttribute(
'minimized', ($spreadsheet->
getMinimized() ?
'true' :
'false'));
117 $objWriter->writeAttribute(
'showHorizontalScroll', ($spreadsheet->
getShowHorizontalScroll() ?
'true' :
'false'));
118 $objWriter->writeAttribute(
'showSheetTabs', ($spreadsheet->
getShowSheetTabs() ?
'true' :
'false'));
119 $objWriter->writeAttribute(
'showVerticalScroll', ($spreadsheet->
getShowVerticalScroll() ?
'true' :
'false'));
120 $objWriter->writeAttribute(
'tabRatio', $spreadsheet->
getTabRatio());
121 $objWriter->writeAttribute(
'visibility', $spreadsheet->
getVisibility());
123 $objWriter->endElement();
125 $objWriter->endElement();
135 if ($spreadsheet->
getSecurity()->isSecurityEnabled()) {
136 $objWriter->startElement(
'workbookProtection');
137 $objWriter->writeAttribute(
'lockRevision', ($spreadsheet->
getSecurity()->getLockRevision() ?
'true' :
'false'));
138 $objWriter->writeAttribute(
'lockStructure', ($spreadsheet->
getSecurity()->getLockStructure() ?
'true' :
'false'));
139 $objWriter->writeAttribute(
'lockWindows', ($spreadsheet->
getSecurity()->getLockWindows() ?
'true' :
'false'));
141 if ($spreadsheet->
getSecurity()->getRevisionsPassword() !=
'') {
142 $objWriter->writeAttribute(
'revisionsPassword', $spreadsheet->
getSecurity()->getRevisionsPassword());
145 if ($spreadsheet->
getSecurity()->getWorkbookPassword() !=
'') {
146 $objWriter->writeAttribute(
'workbookPassword', $spreadsheet->
getSecurity()->getWorkbookPassword());
149 $objWriter->endElement();
161 $objWriter->startElement(
'calcPr');
166 $objWriter->writeAttribute(
'calcId',
'999999');
167 $objWriter->writeAttribute(
'calcMode',
'auto');
169 $objWriter->writeAttribute(
'calcCompleted', ($recalcRequired) ? 1 : 0);
170 $objWriter->writeAttribute(
'fullCalcOnLoad', ($recalcRequired) ? 0 : 1);
171 $objWriter->writeAttribute(
'forceFullCalc', ($recalcRequired) ? 0 : 1);
173 $objWriter->endElement();
184 $objWriter->startElement(
'sheets');
186 for (
$i = 0;
$i < $sheetCount; ++
$i) {
197 $objWriter->endElement();
209 private function writeSheet(
XMLWriter $objWriter, $pSheetname, $pSheetId = 1, $pRelId = 1, $sheetState =
'visible'): void
211 if ($pSheetname !=
'') {
213 $objWriter->startElement(
'sheet');
214 $objWriter->writeAttribute(
'name', $pSheetname);
215 $objWriter->writeAttribute(
'sheetId', $pSheetId);
216 if ($sheetState !==
'visible' && $sheetState !=
'') {
217 $objWriter->writeAttribute(
'state', $sheetState);
219 $objWriter->writeAttribute(
'r:id',
'rId' . $pRelId);
220 $objWriter->endElement();
getShowHorizontalScroll()
Get the visibility of the horizonal scroll bar in the application.
getSheet($pIndex)
Get sheet by index.
getShowVerticalScroll()
Get the visibility of the vertical scroll bar in the application.
getActiveSheetIndex()
Get active sheet index.
getAutoFilterDateGrouping()
Return whether to group dates when presenting the user with filtering optiomd in the user interface...
writeCalcPr(XMLWriter $objWriter, $recalcRequired=true)
Write calcPr.
writeBookViews(XMLWriter $objWriter, Spreadsheet $spreadsheet)
Write BookViews.
getTabRatio()
Get the ratio between the workbook tabs bar and the horizontal scroll bar.
writeWorkbookProtection(XMLWriter $objWriter, Spreadsheet $spreadsheet)
Write WorkbookProtection.
getDiskCachingDirectory()
Get disk caching directory.
getOffice2003Compatibility()
Get Office2003 compatibility.
getVisibility()
Return the visibility status of the workbook.
getFirstSheetIndex()
Return the first sheet in the book view.
writeSheet(XMLWriter $objWriter, $pSheetname, $pSheetId=1, $pRelId=1, $sheetState='visible')
Write sheet.
getParentWriter()
Get parent Xlsx object.
getSecurity()
Get security.
writeWorkbook(Spreadsheet $spreadsheet, $recalcRequired=false)
Write workbook to XML format.
writeSheets(XMLWriter $objWriter, Spreadsheet $spreadsheet)
Write sheets.
getShowSheetTabs()
Get the visibility of the sheet tabs in the application.
getUseDiskCaching()
Get use disk caching where possible?
writeWorkbookPr(XMLWriter $objWriter)
Write WorkbookPr.
writeFileVersion(XMLWriter $objWriter)
Write file version.
getMinimized()
Return whether the workbook window is minimized.
static getExcelCalendar()
Return the Excel calendar (Windows 1900 or Mac 1904).
getSheetCount()
Get sheet count.