ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PhpOffice\PhpSpreadsheet\Writer\Xlsx Class Reference
+ Inheritance diagram for PhpOffice\PhpSpreadsheet\Writer\Xlsx:
+ Collaboration diagram for PhpOffice\PhpSpreadsheet\Writer\Xlsx:

Public Member Functions

 __construct (Spreadsheet $spreadsheet)
 Create a new Xlsx Writer. More...
 
 getWriterPartChart ()
 
 getWriterPartComments ()
 
 getWriterPartContentTypes ()
 
 getWriterPartDocProps ()
 
 getWriterPartDrawing ()
 
 getWriterPartRels ()
 
 getWriterPartRelsRibbon ()
 
 getWriterPartRelsVBA ()
 
 getWriterPartStringTable ()
 
 getWriterPartStyle ()
 
 getWriterPartTheme ()
 
 getWriterPartWorkbook ()
 
 getWriterPartWorksheet ()
 
 save ($pFilename)
 Save PhpSpreadsheet to file. More...
 
 getSpreadsheet ()
 Get Spreadsheet object. More...
 
 setSpreadsheet (Spreadsheet $spreadsheet)
 Set Spreadsheet object. More...
 
 getStringTable ()
 Get string table. More...
 
 getStyleHashTable ()
 Get Style HashTable. More...
 
 getStylesConditionalHashTable ()
 Get Conditional HashTable. More...
 
 getFillHashTable ()
 Get Fill HashTable. More...
 
 getFontHashTable ()
 Get HashTable. More...
 
 getBordersHashTable ()
 Get Borders HashTable. More...
 
 getNumFmtHashTable ()
 Get NumberFormat HashTable. More...
 
 getDrawingHashTable ()
 Get HashTable. More...
 
 getOffice2003Compatibility ()
 Get Office2003 compatibility. More...
 
 setOffice2003Compatibility ($pValue)
 Set Office2003 compatibility. More...
 
- Public Member Functions inherited from PhpOffice\PhpSpreadsheet\Writer\BaseWriter
 getIncludeCharts ()
 Write charts in workbook? If this is true, then the Writer will write definitions for any charts that exist in the PhpSpreadsheet object. More...
 
 setIncludeCharts ($pValue)
 Set write charts in workbook Set to true, to advise the Writer to include any charts that exist in the PhpSpreadsheet object. More...
 
 getPreCalculateFormulas ()
 Get Pre-Calculate Formulas flag If this is true (the default), then the writer will recalculate all formulae in a workbook when saving, so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet viewer when opening the file If false, then formulae are not calculated on save. More...
 
 setPreCalculateFormulas ($pValue)
 Set Pre-Calculate Formulas Set to true (the default) to advise the Writer to calculate all formulae on save Set to false to prevent precalculation of formulae on save. More...
 
 getUseDiskCaching ()
 Get use disk caching where possible? More...
 
 setUseDiskCaching ($pValue, $pDirectory=null)
 Set use disk caching where possible? More...
 
 getDiskCachingDirectory ()
 Get disk caching directory. More...
 
 openFileHandle ($filename)
 Open file handle. More...
 

Private Member Functions

 addZipFile (string $path, string $content)
 
 addZipFiles (array $zipContent)
 

Private Attributes

 $office2003compatibility = false
 
 $spreadSheet
 
 $stringTable = []
 
 $stylesConditionalHashTable
 
 $styleHashTable
 
 $fillHashTable
 
 $fontHashTable
 
 $bordersHashTable
 
 $numFmtHashTable
 
 $drawingHashTable
 
 $zip
 
 $writerPartChart
 
 $writerPartComments
 
 $writerPartContentTypes
 
 $writerPartDocProps
 
 $writerPartDrawing
 
 $writerPartRels
 
 $writerPartRelsRibbon
 
 $writerPartRelsVBA
 
 $writerPartStringTable
 
 $writerPartStyle
 
 $writerPartTheme
 
 $writerPartWorkbook
 
 $writerPartWorksheet
 
 $pathNames = []
 

Additional Inherited Members

- Protected Member Functions inherited from PhpOffice\PhpSpreadsheet\Writer\BaseWriter
 maybeCloseFileHandle ()
 Close file handle only if we opened it ourselves. More...
 
- Protected Attributes inherited from PhpOffice\PhpSpreadsheet\Writer\BaseWriter
 $includeCharts = false
 
 $preCalculateFormulas = true
 
 $fileHandle
 

Detailed Description

Definition at line 36 of file Xlsx.php.

Constructor & Destructor Documentation

◆ __construct()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::__construct ( Spreadsheet  $spreadsheet)

Create a new Xlsx Writer.

Implements PhpOffice\PhpSpreadsheet\Writer\IWriter.

Definition at line 183 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\setSpreadsheet().

184  {
185  // Assign PhpSpreadsheet
186  $this->setSpreadsheet($spreadsheet);
187 
188  $this->writerPartChart = new Chart($this);
189  $this->writerPartComments = new Comments($this);
190  $this->writerPartContentTypes = new ContentTypes($this);
191  $this->writerPartDocProps = new DocProps($this);
192  $this->writerPartDrawing = new Drawing($this);
193  $this->writerPartRels = new Rels($this);
194  $this->writerPartRelsRibbon = new RelsRibbon($this);
195  $this->writerPartRelsVBA = new RelsVBA($this);
196  $this->writerPartStringTable = new StringTable($this);
197  $this->writerPartStyle = new Style($this);
198  $this->writerPartTheme = new Theme($this);
199  $this->writerPartWorkbook = new Workbook($this);
200  $this->writerPartWorksheet = new Worksheet($this);
201 
202  // Set HashTable variables
203  // @phpstan-ignore-next-line
204  $this->bordersHashTable = new HashTable();
205  // @phpstan-ignore-next-line
206  $this->drawingHashTable = new HashTable();
207  // @phpstan-ignore-next-line
208  $this->fillHashTable = new HashTable();
209  // @phpstan-ignore-next-line
210  $this->fontHashTable = new HashTable();
211  // @phpstan-ignore-next-line
212  $this->numFmtHashTable = new HashTable();
213  // @phpstan-ignore-next-line
214  $this->styleHashTable = new HashTable();
215  // @phpstan-ignore-next-line
216  $this->stylesConditionalHashTable = new HashTable();
217  }
setSpreadsheet(Spreadsheet $spreadsheet)
Set Spreadsheet object.
Definition: Xlsx.php:541
+ Here is the call graph for this function:

Member Function Documentation

◆ addZipFile()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::addZipFile ( string  $path,
string  $content 
)
private

Definition at line 654 of file Xlsx.php.

References $path.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\addZipFiles().

654  : void
655  {
656  if (!in_array($path, $this->pathNames)) {
657  $this->pathNames[] = $path;
658  $this->zip->addFile($path, $content);
659  }
660  }
$path
Definition: aliased.php:25
+ Here is the caller graph for this function:

◆ addZipFiles()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::addZipFiles ( array  $zipContent)
private

Definition at line 662 of file Xlsx.php.

References $path, and PhpOffice\PhpSpreadsheet\Writer\Xlsx\addZipFile().

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\save().

662  : void
663  {
664  foreach ($zipContent as $path => $content) {
665  $this->addZipFile($path, $content);
666  }
667  }
$path
Definition: aliased.php:25
addZipFile(string $path, string $content)
Definition: Xlsx.php:654
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBordersHashTable()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getBordersHashTable ( )

Get Borders HashTable.

Returns
HashTable<Borders>

Definition at line 603 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$bordersHashTable.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\Style\writeCellStyleXf(), and PhpOffice\PhpSpreadsheet\Writer\Xlsx\Style\writeStyles().

604  {
606  }
+ Here is the caller graph for this function:

◆ getDrawingHashTable()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getDrawingHashTable ( )

Get HashTable.

Returns
HashTable<BaseDrawing>

Definition at line 623 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$drawingHashTable.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\save(), and PhpOffice\PhpSpreadsheet\Writer\Xlsx\ContentTypes\writeContentTypes().

624  {
626  }
+ Here is the caller graph for this function:

◆ getFillHashTable()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getFillHashTable ( )

Get Fill HashTable.

Returns
HashTable<Fill>

Definition at line 583 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$fillHashTable.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\Style\writeCellStyleXf(), and PhpOffice\PhpSpreadsheet\Writer\Xlsx\Style\writeStyles().

584  {
585  return $this->fillHashTable;
586  }
+ Here is the caller graph for this function:

◆ getFontHashTable()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getFontHashTable ( )

Get HashTable.

Returns
HashTable<Font>

Definition at line 593 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$fontHashTable.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\Style\writeCellStyleXf(), and PhpOffice\PhpSpreadsheet\Writer\Xlsx\Style\writeStyles().

594  {
595  return $this->fontHashTable;
596  }
+ Here is the caller graph for this function:

◆ getNumFmtHashTable()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getNumFmtHashTable ( )

Get NumberFormat HashTable.

Returns
HashTable<NumberFormat>

Definition at line 613 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$numFmtHashTable.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\Style\writeCellStyleXf(), and PhpOffice\PhpSpreadsheet\Writer\Xlsx\Style\writeStyles().

614  {
615  return $this->numFmtHashTable;
616  }
+ Here is the caller graph for this function:

◆ getOffice2003Compatibility()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getOffice2003Compatibility ( )

Get Office2003 compatibility.

Returns
bool

Definition at line 633 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$office2003compatibility.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet\writeCellFormula(), and PhpOffice\PhpSpreadsheet\Writer\Xlsx\Workbook\writeWorkbook().

634  {
636  }
+ Here is the caller graph for this function:

◆ getSpreadsheet()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getSpreadsheet ( )

Get Spreadsheet object.

Returns
Spreadsheet

Definition at line 529 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$spreadSheet.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet\writeSheetViews().

530  {
531  return $this->spreadSheet;
532  }
+ Here is the caller graph for this function:

◆ getStringTable()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getStringTable ( )

Get string table.

Returns
string[]

Definition at line 553 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$stringTable.

554  {
555  return $this->stringTable;
556  }

◆ getStyleHashTable()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getStyleHashTable ( )

Get Style HashTable.

Returns
HashTable<>

Definition at line 563 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$styleHashTable.

564  {
565  return $this->styleHashTable;
566  }

◆ getStylesConditionalHashTable()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getStylesConditionalHashTable ( )

Get Conditional HashTable.

Returns
HashTable<Conditional>

Definition at line 573 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$stylesConditionalHashTable.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\Style\writeStyles().

+ Here is the caller graph for this function:

◆ getWriterPartChart()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getWriterPartChart ( )

Definition at line 219 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$writerPartChart.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\save().

219  : Chart
220  {
221  return $this->writerPartChart;
222  }
+ Here is the caller graph for this function:

◆ getWriterPartComments()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getWriterPartComments ( )

Definition at line 224 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$writerPartComments.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\save().

224  : Comments
225  {
227  }
+ Here is the caller graph for this function:

◆ getWriterPartContentTypes()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getWriterPartContentTypes ( )

Definition at line 229 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$writerPartContentTypes.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\save().

229  : ContentTypes
230  {
232  }
+ Here is the caller graph for this function:

◆ getWriterPartDocProps()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getWriterPartDocProps ( )

Definition at line 234 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$writerPartDocProps.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\save().

234  : DocProps
235  {
237  }
+ Here is the caller graph for this function:

◆ getWriterPartDrawing()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getWriterPartDrawing ( )

Definition at line 239 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$writerPartDrawing.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\save().

239  : Drawing
240  {
242  }
+ Here is the caller graph for this function:

◆ getWriterPartRels()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getWriterPartRels ( )

Definition at line 244 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$writerPartRels.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\save().

244  : Rels
245  {
246  return $this->writerPartRels;
247  }
+ Here is the caller graph for this function:

◆ getWriterPartRelsRibbon()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getWriterPartRelsRibbon ( )

Definition at line 249 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$writerPartRelsRibbon.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\save().

249  : RelsRibbon
250  {
252  }
+ Here is the caller graph for this function:

◆ getWriterPartRelsVBA()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getWriterPartRelsVBA ( )

Definition at line 254 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$writerPartRelsVBA.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\save().

254  : RelsVBA
255  {
257  }
+ Here is the caller graph for this function:

◆ getWriterPartStringTable()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getWriterPartStringTable ( )

Definition at line 259 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$writerPartStringTable.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\save().

259  : StringTable
260  {
262  }
+ Here is the caller graph for this function:

◆ getWriterPartStyle()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getWriterPartStyle ( )

Definition at line 264 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$writerPartStyle.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\save().

264  : Style
265  {
266  return $this->writerPartStyle;
267  }
+ Here is the caller graph for this function:

◆ getWriterPartTheme()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getWriterPartTheme ( )

Definition at line 269 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$writerPartTheme.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\save().

269  : Theme
270  {
271  return $this->writerPartTheme;
272  }
+ Here is the caller graph for this function:

◆ getWriterPartWorkbook()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getWriterPartWorkbook ( )

Definition at line 274 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$writerPartWorkbook.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\save().

274  : Workbook
275  {
277  }
+ Here is the caller graph for this function:

◆ getWriterPartWorksheet()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::getWriterPartWorksheet ( )

Definition at line 279 of file Xlsx.php.

References PhpOffice\PhpSpreadsheet\Writer\Xlsx\$writerPartWorksheet.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\save().

279  : Worksheet
280  {
282  }
+ Here is the caller graph for this function:

◆ save()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::save (   $pFilename)

Save PhpSpreadsheet to file.

Parameters
resource | string$pFilename

Implements PhpOffice\PhpSpreadsheet\Writer\IWriter.

Definition at line 289 of file Xlsx.php.

References $i, PhpOffice\PhpSpreadsheet\Writer\BaseWriter\$includeCharts, PHPMailer\PHPMailer\$options, PhpOffice\PhpSpreadsheet\Writer\Xlsx\$stringTable, PhpOffice\PhpSpreadsheet\Writer\Xlsx\addZipFiles(), PhpOffice\PhpSpreadsheet\Writer\Xlsx\getDrawingHashTable(), PhpOffice\PhpSpreadsheet\Calculation\Calculation\getInstance(), PhpOffice\PhpSpreadsheet\Calculation\Functions\getReturnDateType(), PhpOffice\PhpSpreadsheet\Writer\Xlsx\getWriterPartChart(), PhpOffice\PhpSpreadsheet\Writer\Xlsx\getWriterPartComments(), PhpOffice\PhpSpreadsheet\Writer\Xlsx\getWriterPartContentTypes(), PhpOffice\PhpSpreadsheet\Writer\Xlsx\getWriterPartDocProps(), PhpOffice\PhpSpreadsheet\Writer\Xlsx\getWriterPartDrawing(), PhpOffice\PhpSpreadsheet\Writer\Xlsx\getWriterPartRels(), PhpOffice\PhpSpreadsheet\Writer\Xlsx\getWriterPartRelsRibbon(), PhpOffice\PhpSpreadsheet\Writer\Xlsx\getWriterPartRelsVBA(), PhpOffice\PhpSpreadsheet\Writer\Xlsx\getWriterPartStringTable(), PhpOffice\PhpSpreadsheet\Writer\Xlsx\getWriterPartStyle(), PhpOffice\PhpSpreadsheet\Writer\Xlsx\getWriterPartTheme(), PhpOffice\PhpSpreadsheet\Writer\Xlsx\getWriterPartWorkbook(), PhpOffice\PhpSpreadsheet\Writer\Xlsx\getWriterPartWorksheet(), PhpOffice\PhpSpreadsheet\Writer\BaseWriter\maybeCloseFileHandle(), PhpOffice\PhpSpreadsheet\Writer\BaseWriter\openFileHandle(), PhpOffice\PhpSpreadsheet\Calculation\Functions\RETURNDATE_EXCEL, and PhpOffice\PhpSpreadsheet\Calculation\Functions\setReturnDateType().

289  : void
290  {
291  // garbage collect
292  $this->pathNames = [];
293  $this->spreadSheet->garbageCollect();
294 
295  $saveDebugLog = Calculation::getInstance($this->spreadSheet)->getDebugLog()->getWriteDebugLog();
296  Calculation::getInstance($this->spreadSheet)->getDebugLog()->setWriteDebugLog(false);
297  $saveDateReturnType = Functions::getReturnDateType();
299 
300  // Create string lookup table
301  $this->stringTable = [];
302  for ($i = 0; $i < $this->spreadSheet->getSheetCount(); ++$i) {
303  $this->stringTable = $this->getWriterPartStringTable()->createStringTable($this->spreadSheet->getSheet($i), $this->stringTable);
304  }
305 
306  // Create styles dictionaries
307  $this->styleHashTable->addFromSource($this->getWriterPartStyle()->allStyles($this->spreadSheet));
308  $this->stylesConditionalHashTable->addFromSource($this->getWriterPartStyle()->allConditionalStyles($this->spreadSheet));
309  $this->fillHashTable->addFromSource($this->getWriterPartStyle()->allFills($this->spreadSheet));
310  $this->fontHashTable->addFromSource($this->getWriterPartStyle()->allFonts($this->spreadSheet));
311  $this->bordersHashTable->addFromSource($this->getWriterPartStyle()->allBorders($this->spreadSheet));
312  $this->numFmtHashTable->addFromSource($this->getWriterPartStyle()->allNumberFormats($this->spreadSheet));
313 
314  // Create drawing dictionary
315  $this->drawingHashTable->addFromSource($this->getWriterPartDrawing()->allDrawings($this->spreadSheet));
316 
317  $zipContent = [];
318  // Add [Content_Types].xml to ZIP file
319  $zipContent['[Content_Types].xml'] = $this->getWriterPartContentTypes()->writeContentTypes($this->spreadSheet, $this->includeCharts);
320 
321  //if hasMacros, add the vbaProject.bin file, Certificate file(if exists)
322  if ($this->spreadSheet->hasMacros()) {
323  $macrosCode = $this->spreadSheet->getMacrosCode();
324  if ($macrosCode !== null) {
325  // we have the code ?
326  $zipContent['xl/vbaProject.bin'] = $macrosCode; //allways in 'xl', allways named vbaProject.bin
327  if ($this->spreadSheet->hasMacrosCertificate()) {
328  //signed macros ?
329  // Yes : add the certificate file and the related rels file
330  $zipContent['xl/vbaProjectSignature.bin'] = $this->spreadSheet->getMacrosCertificate();
331  $zipContent['xl/_rels/vbaProject.bin.rels'] = $this->getWriterPartRelsVBA()->writeVBARelationships($this->spreadSheet);
332  }
333  }
334  }
335  //a custom UI in this workbook ? add it ("base" xml and additional objects (pictures) and rels)
336  if ($this->spreadSheet->hasRibbon()) {
337  $tmpRibbonTarget = $this->spreadSheet->getRibbonXMLData('target');
338  $zipContent[$tmpRibbonTarget] = $this->spreadSheet->getRibbonXMLData('data');
339  if ($this->spreadSheet->hasRibbonBinObjects()) {
340  $tmpRootPath = dirname($tmpRibbonTarget) . '/';
341  $ribbonBinObjects = $this->spreadSheet->getRibbonBinObjects('data'); //the files to write
342  foreach ($ribbonBinObjects as $aPath => $aContent) {
343  $zipContent[$tmpRootPath . $aPath] = $aContent;
344  }
345  //the rels for files
346  $zipContent[$tmpRootPath . '_rels/' . basename($tmpRibbonTarget) . '.rels'] = $this->getWriterPartRelsRibbon()->writeRibbonRelationships($this->spreadSheet);
347  }
348  }
349 
350  // Add relationships to ZIP file
351  $zipContent['_rels/.rels'] = $this->getWriterPartRels()->writeRelationships($this->spreadSheet);
352  $zipContent['xl/_rels/workbook.xml.rels'] = $this->getWriterPartRels()->writeWorkbookRelationships($this->spreadSheet);
353 
354  // Add document properties to ZIP file
355  $zipContent['docProps/app.xml'] = $this->getWriterPartDocProps()->writeDocPropsApp($this->spreadSheet);
356  $zipContent['docProps/core.xml'] = $this->getWriterPartDocProps()->writeDocPropsCore($this->spreadSheet);
357  $customPropertiesPart = $this->getWriterPartDocProps()->writeDocPropsCustom($this->spreadSheet);
358  if ($customPropertiesPart !== null) {
359  $zipContent['docProps/custom.xml'] = $customPropertiesPart;
360  }
361 
362  // Add theme to ZIP file
363  $zipContent['xl/theme/theme1.xml'] = $this->getWriterPartTheme()->writeTheme($this->spreadSheet);
364 
365  // Add string table to ZIP file
366  $zipContent['xl/sharedStrings.xml'] = $this->getWriterPartStringTable()->writeStringTable($this->stringTable);
367 
368  // Add styles to ZIP file
369  $zipContent['xl/styles.xml'] = $this->getWriterPartStyle()->writeStyles($this->spreadSheet);
370 
371  // Add workbook to ZIP file
372  $zipContent['xl/workbook.xml'] = $this->getWriterPartWorkbook()->writeWorkbook($this->spreadSheet, $this->preCalculateFormulas);
373 
374  $chartCount = 0;
375  // Add worksheets
376  for ($i = 0; $i < $this->spreadSheet->getSheetCount(); ++$i) {
377  $zipContent['xl/worksheets/sheet' . ($i + 1) . '.xml'] = $this->getWriterPartWorksheet()->writeWorksheet($this->spreadSheet->getSheet($i), $this->stringTable, $this->includeCharts);
378  if ($this->includeCharts) {
379  $charts = $this->spreadSheet->getSheet($i)->getChartCollection();
380  if (count($charts) > 0) {
381  foreach ($charts as $chart) {
382  $zipContent['xl/charts/chart' . ($chartCount + 1) . '.xml'] = $this->getWriterPartChart()->writeChart($chart, $this->preCalculateFormulas);
383  ++$chartCount;
384  }
385  }
386  }
387  }
388 
389  $chartRef1 = 0;
390  // Add worksheet relationships (drawings, ...)
391  for ($i = 0; $i < $this->spreadSheet->getSheetCount(); ++$i) {
392  // Add relationships
393  $zipContent['xl/worksheets/_rels/sheet' . ($i + 1) . '.xml.rels'] = $this->getWriterPartRels()->writeWorksheetRelationships($this->spreadSheet->getSheet($i), ($i + 1), $this->includeCharts);
394 
395  // Add unparsedLoadedData
396  $sheetCodeName = $this->spreadSheet->getSheet($i)->getCodeName();
397  $unparsedLoadedData = $this->spreadSheet->getUnparsedLoadedData();
398  if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['ctrlProps'])) {
399  foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['ctrlProps'] as $ctrlProp) {
400  $zipContent[$ctrlProp['filePath']] = $ctrlProp['content'];
401  }
402  }
403  if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['printerSettings'])) {
404  foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['printerSettings'] as $ctrlProp) {
405  $zipContent[$ctrlProp['filePath']] = $ctrlProp['content'];
406  }
407  }
408 
409  $drawings = $this->spreadSheet->getSheet($i)->getDrawingCollection();
410  $drawingCount = count($drawings);
411  if ($this->includeCharts) {
412  $chartCount = $this->spreadSheet->getSheet($i)->getChartCount();
413  }
414 
415  // Add drawing and image relationship parts
416  if (($drawingCount > 0) || ($chartCount > 0)) {
417  // Drawing relationships
418  $zipContent['xl/drawings/_rels/drawing' . ($i + 1) . '.xml.rels'] = $this->getWriterPartRels()->writeDrawingRelationships($this->spreadSheet->getSheet($i), $chartRef1, $this->includeCharts);
419 
420  // Drawings
421  $zipContent['xl/drawings/drawing' . ($i + 1) . '.xml'] = $this->getWriterPartDrawing()->writeDrawings($this->spreadSheet->getSheet($i), $this->includeCharts);
422  } elseif (isset($unparsedLoadedData['sheets'][$sheetCodeName]['drawingAlternateContents'])) {
423  // Drawings
424  $zipContent['xl/drawings/drawing' . ($i + 1) . '.xml'] = $this->getWriterPartDrawing()->writeDrawings($this->spreadSheet->getSheet($i), $this->includeCharts);
425  }
426 
427  // Add unparsed drawings
428  if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['Drawings'])) {
429  foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['Drawings'] as $relId => $drawingXml) {
430  $drawingFile = array_search($relId, $unparsedLoadedData['sheets'][$sheetCodeName]['drawingOriginalIds']);
431  if ($drawingFile !== false) {
432  $drawingFile = ltrim($drawingFile, '.');
433  $zipContent['xl' . $drawingFile] = $drawingXml;
434  }
435  }
436  }
437 
438  // Add comment relationship parts
439  if (count($this->spreadSheet->getSheet($i)->getComments()) > 0) {
440  // VML Comments
441  $zipContent['xl/drawings/vmlDrawing' . ($i + 1) . '.vml'] = $this->getWriterPartComments()->writeVMLComments($this->spreadSheet->getSheet($i));
442 
443  // Comments
444  $zipContent['xl/comments' . ($i + 1) . '.xml'] = $this->getWriterPartComments()->writeComments($this->spreadSheet->getSheet($i));
445  }
446 
447  // Add unparsed relationship parts
448  if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['vmlDrawings'])) {
449  foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['vmlDrawings'] as $vmlDrawing) {
450  $zipContent[$vmlDrawing['filePath']] = $vmlDrawing['content'];
451  }
452  }
453 
454  // Add header/footer relationship parts
455  if (count($this->spreadSheet->getSheet($i)->getHeaderFooter()->getImages()) > 0) {
456  // VML Drawings
457  $zipContent['xl/drawings/vmlDrawingHF' . ($i + 1) . '.vml'] = $this->getWriterPartDrawing()->writeVMLHeaderFooterImages($this->spreadSheet->getSheet($i));
458 
459  // VML Drawing relationships
460  $zipContent['xl/drawings/_rels/vmlDrawingHF' . ($i + 1) . '.vml.rels'] = $this->getWriterPartRels()->writeHeaderFooterDrawingRelationships($this->spreadSheet->getSheet($i));
461 
462  // Media
463  foreach ($this->spreadSheet->getSheet($i)->getHeaderFooter()->getImages() as $image) {
464  $zipContent['xl/media/' . $image->getIndexedFilename()] = file_get_contents($image->getPath());
465  }
466  }
467  }
468 
469  // Add media
470  for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) {
471  if ($this->getDrawingHashTable()->getByIndex($i) instanceof WorksheetDrawing) {
472  $imageContents = null;
473  $imagePath = $this->getDrawingHashTable()->getByIndex($i)->getPath();
474  if (strpos($imagePath, 'zip://') !== false) {
475  $imagePath = substr($imagePath, 6);
476  $imagePathSplitted = explode('#', $imagePath);
477 
478  $imageZip = new ZipArchive();
479  $imageZip->open($imagePathSplitted[0]);
480  $imageContents = $imageZip->getFromName($imagePathSplitted[1]);
481  $imageZip->close();
482  unset($imageZip);
483  } else {
484  $imageContents = file_get_contents($imagePath);
485  }
486 
487  $zipContent['xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename())] = $imageContents;
488  } elseif ($this->getDrawingHashTable()->getByIndex($i) instanceof MemoryDrawing) {
489  ob_start();
490  call_user_func(
491  $this->getDrawingHashTable()->getByIndex($i)->getRenderingFunction(),
492  $this->getDrawingHashTable()->getByIndex($i)->getImageResource()
493  );
494  $imageContents = ob_get_contents();
495  ob_end_clean();
496 
497  $zipContent['xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename())] = $imageContents;
498  }
499  }
500 
501  Functions::setReturnDateType($saveDateReturnType);
502  Calculation::getInstance($this->spreadSheet)->getDebugLog()->setWriteDebugLog($saveDebugLog);
503 
504  $this->openFileHandle($pFilename);
505 
506  $options = new Archive();
507  $options->setEnableZip64(false);
508  $options->setOutputStream($this->fileHandle);
509 
510  $this->zip = new ZipStream(null, $options);
511 
512  $this->addZipFiles($zipContent);
513 
514  // Close file
515  try {
516  $this->zip->finish();
517  } catch (OverflowException $e) {
518  throw new WriterException('Could not close resource.');
519  }
520 
521  $this->maybeCloseFileHandle();
522  }
Class Version .
Definition: Bigint.php:4
static getReturnDateType()
Return the current Return Date Format for functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object).
Definition: Functions.php:133
static setReturnDateType($returnDateType)
Set the Return Date Format used by functions that return a date/time (Excel, PHP Serialized Numeric o...
Definition: Functions.php:109
addZipFiles(array $zipContent)
Definition: Xlsx.php:662
static getInstance(?Spreadsheet $spreadsheet=null)
Get an instance of this class.
$i
Definition: disco.tpl.php:19
openFileHandle($filename)
Open file handle.
Definition: BaseWriter.php:102
getDrawingHashTable()
Get HashTable.
Definition: Xlsx.php:623
maybeCloseFileHandle()
Close file handle only if we opened it ourselves.
Definition: BaseWriter.php:123
+ Here is the call graph for this function:

◆ setOffice2003Compatibility()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::setOffice2003Compatibility (   $pValue)

Set Office2003 compatibility.

Parameters
bool$pValueOffice2003 compatibility?
Returns
$this

Definition at line 645 of file Xlsx.php.

646  {
647  $this->office2003compatibility = $pValue;
648 
649  return $this;
650  }

◆ setSpreadsheet()

PhpOffice\PhpSpreadsheet\Writer\Xlsx::setSpreadsheet ( Spreadsheet  $spreadsheet)

Set Spreadsheet object.

Parameters
Spreadsheet$spreadsheetPhpSpreadsheet object
Returns
$this

Definition at line 541 of file Xlsx.php.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\__construct().

542  {
543  $this->spreadSheet = $spreadsheet;
544 
545  return $this;
546  }
+ Here is the caller graph for this function:

Field Documentation

◆ $bordersHashTable

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$bordersHashTable
private

Definition at line 92 of file Xlsx.php.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\getBordersHashTable().

◆ $drawingHashTable

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$drawingHashTable
private

Definition at line 106 of file Xlsx.php.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\getDrawingHashTable().

◆ $fillHashTable

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$fillHashTable
private

Definition at line 78 of file Xlsx.php.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\getFillHashTable().

◆ $fontHashTable

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$fontHashTable
private

Definition at line 85 of file Xlsx.php.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\getFontHashTable().

◆ $numFmtHashTable

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$numFmtHashTable
private

Definition at line 99 of file Xlsx.php.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\getNumFmtHashTable().

◆ $office2003compatibility

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$office2003compatibility = false
private

◆ $pathNames

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$pathNames = []
private

Definition at line 652 of file Xlsx.php.

◆ $spreadSheet

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$spreadSheet
private

Definition at line 50 of file Xlsx.php.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\getSpreadsheet().

◆ $stringTable

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$stringTable = []
private

◆ $styleHashTable

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$styleHashTable
private

Definition at line 71 of file Xlsx.php.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\getStyleHashTable().

◆ $stylesConditionalHashTable

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$stylesConditionalHashTable
private

◆ $writerPartChart

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$writerPartChart
private

Definition at line 118 of file Xlsx.php.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\getWriterPartChart().

◆ $writerPartComments

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$writerPartComments
private

◆ $writerPartContentTypes

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$writerPartContentTypes
private

◆ $writerPartDocProps

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$writerPartDocProps
private

◆ $writerPartDrawing

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$writerPartDrawing
private

Definition at line 138 of file Xlsx.php.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\getWriterPartDrawing().

◆ $writerPartRels

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$writerPartRels
private

Definition at line 143 of file Xlsx.php.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\getWriterPartRels().

◆ $writerPartRelsRibbon

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$writerPartRelsRibbon
private

◆ $writerPartRelsVBA

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$writerPartRelsVBA
private

Definition at line 153 of file Xlsx.php.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\getWriterPartRelsVBA().

◆ $writerPartStringTable

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$writerPartStringTable
private

◆ $writerPartStyle

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$writerPartStyle
private

Definition at line 163 of file Xlsx.php.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\getWriterPartStyle().

◆ $writerPartTheme

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$writerPartTheme
private

Definition at line 168 of file Xlsx.php.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\getWriterPartTheme().

◆ $writerPartWorkbook

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$writerPartWorkbook
private

◆ $writerPartWorksheet

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$writerPartWorksheet
private

◆ $zip

PhpOffice\PhpSpreadsheet\Writer\Xlsx::$zip
private

Definition at line 113 of file Xlsx.php.


The documentation for this class was generated from the following file: