Failed Conditions
Push — master ( 42761f...d02352 )
by Adrien
16:26 queued 08:32
created

Xlsx::getWriterPartContentTypes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Writer;
4
5
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
6
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
7
use PhpOffice\PhpSpreadsheet\HashTable;
8
use PhpOffice\PhpSpreadsheet\Spreadsheet;
9
use PhpOffice\PhpSpreadsheet\Style\Borders;
10
use PhpOffice\PhpSpreadsheet\Style\Conditional;
11
use PhpOffice\PhpSpreadsheet\Style\Fill;
12
use PhpOffice\PhpSpreadsheet\Style\Font;
13
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
14
use PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing;
15
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing as WorksheetDrawing;
16
use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing;
17
use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException;
18
use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Chart;
19
use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Comments;
20
use PhpOffice\PhpSpreadsheet\Writer\Xlsx\ContentTypes;
21
use PhpOffice\PhpSpreadsheet\Writer\Xlsx\DocProps;
22
use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Drawing;
23
use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Rels;
24
use PhpOffice\PhpSpreadsheet\Writer\Xlsx\RelsRibbon;
25
use PhpOffice\PhpSpreadsheet\Writer\Xlsx\RelsVBA;
26
use PhpOffice\PhpSpreadsheet\Writer\Xlsx\StringTable;
27
use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Style;
28
use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Theme;
29
use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Workbook;
30
use PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet;
31
use ZipArchive;
32
use ZipStream\Exception\OverflowException;
33
use ZipStream\Option\Archive;
34
use ZipStream\ZipStream;
35
36
class Xlsx extends BaseWriter
37
{
38
    /**
39
     * Office2003 compatibility.
40
     *
41
     * @var bool
42
     */
43
    private $office2003compatibility = false;
44
45
    /**
46
     * Private Spreadsheet.
47
     *
48
     * @var Spreadsheet
49
     */
50
    private $spreadSheet;
51
52
    /**
53
     * Private string table.
54
     *
55
     * @var string[]
56
     */
57
    private $stringTable = [];
58
59
    /**
60
     * Private unique Conditional HashTable.
61
     *
62
     * @var HashTable<Conditional>
63
     */
64
    private $stylesConditionalHashTable;
65
66
    /**
67
     * Private unique Style HashTable.
68
     *
69
     * @var HashTable<\PhpOffice\PhpSpreadsheet\Style\Style>
70
     */
71
    private $styleHashTable;
72
73
    /**
74
     * Private unique Fill HashTable.
75
     *
76
     * @var HashTable<Fill>
77
     */
78
    private $fillHashTable;
79
80
    /**
81
     * Private unique \PhpOffice\PhpSpreadsheet\Style\Font HashTable.
82
     *
83
     * @var HashTable<Font>
84
     */
85
    private $fontHashTable;
86
87
    /**
88
     * Private unique Borders HashTable.
89
     *
90
     * @var HashTable<Borders>
91
     */
92
    private $bordersHashTable;
93
94
    /**
95
     * Private unique NumberFormat HashTable.
96
     *
97
     * @var HashTable<NumberFormat>
98
     */
99
    private $numFmtHashTable;
100
101
    /**
102
     * Private unique \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\BaseDrawing HashTable.
103
     *
104
     * @var HashTable<BaseDrawing>
105
     */
106
    private $drawingHashTable;
107
108
    /**
109
     * Private handle for zip stream.
110
     *
111
     * @var ZipStream
112
     */
113
    private $zip;
114
115
    /**
116
     * @var Chart
117
     */
118
    private $writerPartChart;
119
120
    /**
121
     * @var Comments
122
     */
123
    private $writerPartComments;
124
125
    /**
126
     * @var ContentTypes
127
     */
128
    private $writerPartContentTypes;
129
130
    /**
131
     * @var DocProps
132
     */
133
    private $writerPartDocProps;
134
135
    /**
136
     * @var Drawing
137
     */
138
    private $writerPartDrawing;
139
140
    /**
141
     * @var Rels
142
     */
143
    private $writerPartRels;
144
145
    /**
146
     * @var RelsRibbon
147
     */
148
    private $writerPartRelsRibbon;
149
150
    /**
151
     * @var RelsVBA
152
     */
153
    private $writerPartRelsVBA;
154
155
    /**
156
     * @var StringTable
157
     */
158
    private $writerPartStringTable;
159
160
    /**
161
     * @var Style
162
     */
163
    private $writerPartStyle;
164
165
    /**
166
     * @var Theme
167
     */
168
    private $writerPartTheme;
169
170
    /**
171
     * @var Workbook
172
     */
173
    private $writerPartWorkbook;
174
175
    /**
176
     * @var Worksheet
177
     */
178
    private $writerPartWorksheet;
179
180
    /**
181
     * Create a new Xlsx Writer.
182
     */
183 129
    public function __construct(Spreadsheet $spreadsheet)
184
    {
185
        // Assign PhpSpreadsheet
186 129
        $this->setSpreadsheet($spreadsheet);
187
188 129
        $this->writerPartChart = new Chart($this);
189 129
        $this->writerPartComments = new Comments($this);
190 129
        $this->writerPartContentTypes = new ContentTypes($this);
191 129
        $this->writerPartDocProps = new DocProps($this);
192 129
        $this->writerPartDrawing = new Drawing($this);
193 129
        $this->writerPartRels = new Rels($this);
194 129
        $this->writerPartRelsRibbon = new RelsRibbon($this);
195 129
        $this->writerPartRelsVBA = new RelsVBA($this);
196 129
        $this->writerPartStringTable = new StringTable($this);
197 129
        $this->writerPartStyle = new Style($this);
198 129
        $this->writerPartTheme = new Theme($this);
199 129
        $this->writerPartWorkbook = new Workbook($this);
200 129
        $this->writerPartWorksheet = new Worksheet($this);
201
202
        // Set HashTable variables
203 129
        $this->bordersHashTable = new HashTable();
204 129
        $this->drawingHashTable = new HashTable();
205 129
        $this->fillHashTable = new HashTable();
206 129
        $this->fontHashTable = new HashTable();
207 129
        $this->numFmtHashTable = new HashTable();
208 129
        $this->styleHashTable = new HashTable();
209 129
        $this->stylesConditionalHashTable = new HashTable();
210 129
    }
211
212 15
    public function getWriterPartChart(): Chart
213
    {
214 15
        return $this->writerPartChart;
215
    }
216
217 11
    public function getWriterPartComments(): Comments
218
    {
219 11
        return $this->writerPartComments;
220
    }
221
222 128
    public function getWriterPartContentTypes(): ContentTypes
223
    {
224 128
        return $this->writerPartContentTypes;
225
    }
226
227 128
    public function getWriterPartDocProps(): DocProps
228
    {
229 128
        return $this->writerPartDocProps;
230
    }
231
232 128
    public function getWriterPartDrawing(): Drawing
233
    {
234 128
        return $this->writerPartDrawing;
235
    }
236
237 128
    public function getWriterPartRels(): Rels
238
    {
239 128
        return $this->writerPartRels;
240
    }
241
242
    public function getWriterPartRelsRibbon(): RelsRibbon
243
    {
244
        return $this->writerPartRelsRibbon;
245
    }
246
247
    public function getWriterPartRelsVBA(): RelsVBA
248
    {
249
        return $this->writerPartRelsVBA;
250
    }
251
252 128
    public function getWriterPartStringTable(): StringTable
253
    {
254 128
        return $this->writerPartStringTable;
255
    }
256
257 128
    public function getWriterPartStyle(): Style
258
    {
259 128
        return $this->writerPartStyle;
260
    }
261
262 128
    public function getWriterPartTheme(): Theme
263
    {
264 128
        return $this->writerPartTheme;
265
    }
266
267 128
    public function getWriterPartWorkbook(): Workbook
268
    {
269 128
        return $this->writerPartWorkbook;
270
    }
271
272 128
    public function getWriterPartWorksheet(): Worksheet
273
    {
274 128
        return $this->writerPartWorksheet;
275
    }
276
277
    /**
278
     * Save PhpSpreadsheet to file.
279
     *
280
     * @param resource|string $pFilename
281
     */
282 128
    public function save($pFilename): void
283
    {
284
        // garbage collect
285 128
        $this->pathNames = [];
286 128
        $this->spreadSheet->garbageCollect();
287
288 128
        $this->openFileHandle($pFilename);
289
290 128
        $saveDebugLog = Calculation::getInstance($this->spreadSheet)->getDebugLog()->getWriteDebugLog();
291 128
        Calculation::getInstance($this->spreadSheet)->getDebugLog()->setWriteDebugLog(false);
292 128
        $saveDateReturnType = Functions::getReturnDateType();
293 128
        Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
294
295
        // Create string lookup table
296 128
        $this->stringTable = [];
297 128
        for ($i = 0; $i < $this->spreadSheet->getSheetCount(); ++$i) {
298 128
            $this->stringTable = $this->getWriterPartStringTable()->createStringTable($this->spreadSheet->getSheet($i), $this->stringTable);
299
        }
300
301
        // Create styles dictionaries
302 128
        $this->styleHashTable->addFromSource($this->getWriterPartStyle()->allStyles($this->spreadSheet));
303 128
        $this->stylesConditionalHashTable->addFromSource($this->getWriterPartStyle()->allConditionalStyles($this->spreadSheet));
304 128
        $this->fillHashTable->addFromSource($this->getWriterPartStyle()->allFills($this->spreadSheet));
305 128
        $this->fontHashTable->addFromSource($this->getWriterPartStyle()->allFonts($this->spreadSheet));
306 128
        $this->bordersHashTable->addFromSource($this->getWriterPartStyle()->allBorders($this->spreadSheet));
307 128
        $this->numFmtHashTable->addFromSource($this->getWriterPartStyle()->allNumberFormats($this->spreadSheet));
308
309
        // Create drawing dictionary
310 128
        $this->drawingHashTable->addFromSource($this->getWriterPartDrawing()->allDrawings($this->spreadSheet));
311
312 128
        $options = new Archive();
313 128
        $options->setEnableZip64(false);
314 128
        $options->setOutputStream($this->fileHandle);
315
316 128
        $this->zip = new ZipStream(null, $options);
317
318
        // Add [Content_Types].xml to ZIP file
319 128
        $this->addZipFile('[Content_Types].xml', $this->getWriterPartContentTypes()->writeContentTypes($this->spreadSheet, $this->includeCharts));
320
321
        //if hasMacros, add the vbaProject.bin file, Certificate file(if exists)
322 128
        if ($this->spreadSheet->hasMacros()) {
323 1
            $macrosCode = $this->spreadSheet->getMacrosCode();
324 1
            if ($macrosCode !== null) {
0 ignored issues
show
introduced by
The condition $macrosCode !== null is always true.
Loading history...
325
                // we have the code ?
326 1
                $this->addZipFile('xl/vbaProject.bin', $macrosCode); //allways in 'xl', allways named vbaProject.bin
327 1
                if ($this->spreadSheet->hasMacrosCertificate()) {
328
                    //signed macros ?
329
                    // Yes : add the certificate file and the related rels file
330
                    $this->addZipFile('xl/vbaProjectSignature.bin', $this->spreadSheet->getMacrosCertificate());
331
                    $this->addZipFile('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 128
        if ($this->spreadSheet->hasRibbon()) {
337
            $tmpRibbonTarget = $this->spreadSheet->getRibbonXMLData('target');
338
            $this->addZipFile($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
                    $this->addZipFile($tmpRootPath . $aPath, $aContent);
344
                }
345
                //the rels for files
346
                $this->addZipFile($tmpRootPath . '_rels/' . basename($tmpRibbonTarget) . '.rels', $this->getWriterPartRelsRibbon()->writeRibbonRelationships($this->spreadSheet));
347
            }
348
        }
349
350
        // Add relationships to ZIP file
351 128
        $this->addZipFile('_rels/.rels', $this->getWriterPartRels()->writeRelationships($this->spreadSheet));
352 128
        $this->addZipFile('xl/_rels/workbook.xml.rels', $this->getWriterPartRels()->writeWorkbookRelationships($this->spreadSheet));
353
354
        // Add document properties to ZIP file
355 128
        $this->addZipFile('docProps/app.xml', $this->getWriterPartDocProps()->writeDocPropsApp($this->spreadSheet));
356 128
        $this->addZipFile('docProps/core.xml', $this->getWriterPartDocProps()->writeDocPropsCore($this->spreadSheet));
357 128
        $customPropertiesPart = $this->getWriterPartDocProps()->writeDocPropsCustom($this->spreadSheet);
358 128
        if ($customPropertiesPart !== null) {
0 ignored issues
show
introduced by
The condition $customPropertiesPart !== null is always true.
Loading history...
359 3
            $this->addZipFile('docProps/custom.xml', $customPropertiesPart);
360
        }
361
362
        // Add theme to ZIP file
363 128
        $this->addZipFile('xl/theme/theme1.xml', $this->getWriterPartTheme()->writeTheme($this->spreadSheet));
364
365
        // Add string table to ZIP file
366 128
        $this->addZipFile('xl/sharedStrings.xml', $this->getWriterPartStringTable()->writeStringTable($this->stringTable));
367
368
        // Add styles to ZIP file
369 128
        $this->addZipFile('xl/styles.xml', $this->getWriterPartStyle()->writeStyles($this->spreadSheet));
370
371
        // Add workbook to ZIP file
372 128
        $this->addZipFile('xl/workbook.xml', $this->getWriterPartWorkbook()->writeWorkbook($this->spreadSheet, $this->preCalculateFormulas));
373
374 128
        $chartCount = 0;
375
        // Add worksheets
376 128
        for ($i = 0; $i < $this->spreadSheet->getSheetCount(); ++$i) {
377 128
            $this->addZipFile('xl/worksheets/sheet' . ($i + 1) . '.xml', $this->getWriterPartWorksheet()->writeWorksheet($this->spreadSheet->getSheet($i), $this->stringTable, $this->includeCharts));
378 128
            if ($this->includeCharts) {
379 15
                $charts = $this->spreadSheet->getSheet($i)->getChartCollection();
380 15
                if (count($charts) > 0) {
381 15
                    foreach ($charts as $chart) {
382 15
                        $this->addZipFile('xl/charts/chart' . ($chartCount + 1) . '.xml', $this->getWriterPartChart()->writeChart($chart, $this->preCalculateFormulas));
383 15
                        ++$chartCount;
384
                    }
385
                }
386
            }
387
        }
388
389 128
        $chartRef1 = 0;
390
        // Add worksheet relationships (drawings, ...)
391 128
        for ($i = 0; $i < $this->spreadSheet->getSheetCount(); ++$i) {
392
            // Add relationships
393 128
            $this->addZipFile('xl/worksheets/_rels/sheet' . ($i + 1) . '.xml.rels', $this->getWriterPartRels()->writeWorksheetRelationships($this->spreadSheet->getSheet($i), ($i + 1), $this->includeCharts));
394
395
            // Add unparsedLoadedData
396 128
            $sheetCodeName = $this->spreadSheet->getSheet($i)->getCodeName();
397 128
            $unparsedLoadedData = $this->spreadSheet->getUnparsedLoadedData();
398 128
            if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['ctrlProps'])) {
399 1
                foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['ctrlProps'] as $ctrlProp) {
400 1
                    $this->addZipFile($ctrlProp['filePath'], $ctrlProp['content']);
401
                }
402
            }
403 128
            if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['printerSettings'])) {
404 7
                foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['printerSettings'] as $ctrlProp) {
405 7
                    $this->addZipFile($ctrlProp['filePath'], $ctrlProp['content']);
406
                }
407
            }
408
409 128
            $drawings = $this->spreadSheet->getSheet($i)->getDrawingCollection();
410 128
            $drawingCount = count($drawings);
411 128
            if ($this->includeCharts) {
412 15
                $chartCount = $this->spreadSheet->getSheet($i)->getChartCount();
413
            }
414
415
            // Add drawing and image relationship parts
416 128
            if (($drawingCount > 0) || ($chartCount > 0)) {
417
                // Drawing relationships
418 29
                $this->addZipFile('xl/drawings/_rels/drawing' . ($i + 1) . '.xml.rels', $this->getWriterPartRels()->writeDrawingRelationships($this->spreadSheet->getSheet($i), $chartRef1, $this->includeCharts));
419
420
                // Drawings
421 29
                $this->addZipFile('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPartDrawing()->writeDrawings($this->spreadSheet->getSheet($i), $this->includeCharts));
422 103
            } elseif (isset($unparsedLoadedData['sheets'][$sheetCodeName]['drawingAlternateContents'])) {
423
                // Drawings
424 1
                $this->addZipFile('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPartDrawing()->writeDrawings($this->spreadSheet->getSheet($i), $this->includeCharts));
425
            }
426
427
            // Add unparsed drawings
428 128
            if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['Drawings'])) {
429 2
                foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['Drawings'] as $relId => $drawingXml) {
430 2
                    $drawingFile = array_search($relId, $unparsedLoadedData['sheets'][$sheetCodeName]['drawingOriginalIds']);
431 2
                    if ($drawingFile !== false) {
432 2
                        $drawingFile = ltrim($drawingFile, '.');
433 2
                        $this->addZipFile('xl' . $drawingFile, $drawingXml);
434
                    }
435
                }
436
            }
437
438
            // Add comment relationship parts
439 128
            if (count($this->spreadSheet->getSheet($i)->getComments()) > 0) {
440
                // VML Comments
441 11
                $this->addZipFile('xl/drawings/vmlDrawing' . ($i + 1) . '.vml', $this->getWriterPartComments()->writeVMLComments($this->spreadSheet->getSheet($i)));
442
443
                // Comments
444 11
                $this->addZipFile('xl/comments' . ($i + 1) . '.xml', $this->getWriterPartComments()->writeComments($this->spreadSheet->getSheet($i)));
445
            }
446
447
            // Add unparsed relationship parts
448 128
            if (isset($unparsedLoadedData['sheets'][$sheetCodeName]['vmlDrawings'])) {
449 1
                foreach ($unparsedLoadedData['sheets'][$sheetCodeName]['vmlDrawings'] as $vmlDrawing) {
450 1
                    $this->addZipFile($vmlDrawing['filePath'], $vmlDrawing['content']);
451
                }
452
            }
453
454
            // Add header/footer relationship parts
455 128
            if (count($this->spreadSheet->getSheet($i)->getHeaderFooter()->getImages()) > 0) {
456
                // VML Drawings
457 1
                $this->addZipFile('xl/drawings/vmlDrawingHF' . ($i + 1) . '.vml', $this->getWriterPartDrawing()->writeVMLHeaderFooterImages($this->spreadSheet->getSheet($i)));
458
459
                // VML Drawing relationships
460 1
                $this->addZipFile('xl/drawings/_rels/vmlDrawingHF' . ($i + 1) . '.vml.rels', $this->getWriterPartRels()->writeHeaderFooterDrawingRelationships($this->spreadSheet->getSheet($i)));
461
462
                // Media
463 1
                foreach ($this->spreadSheet->getSheet($i)->getHeaderFooter()->getImages() as $image) {
464 1
                    $this->addZipFile('xl/media/' . $image->getIndexedFilename(), file_get_contents($image->getPath()));
465
                }
466
            }
467
        }
468
469
        // Add media
470 128
        for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) {
471 15
            if ($this->getDrawingHashTable()->getByIndex($i) instanceof WorksheetDrawing) {
472 9
                $imageContents = null;
473 9
                $imagePath = $this->getDrawingHashTable()->getByIndex($i)->getPath();
474 9
                if (strpos($imagePath, 'zip://') !== false) {
475 5
                    $imagePath = substr($imagePath, 6);
476 5
                    $imagePathSplitted = explode('#', $imagePath);
477
478 5
                    $imageZip = new ZipArchive();
479 5
                    $imageZip->open($imagePathSplitted[0]);
480 5
                    $imageContents = $imageZip->getFromName($imagePathSplitted[1]);
481 5
                    $imageZip->close();
482 5
                    unset($imageZip);
483
                } else {
484 5
                    $imageContents = file_get_contents($imagePath);
485
                }
486
487 9
                $this->addZipFile('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents);
488 6
            } elseif ($this->getDrawingHashTable()->getByIndex($i) instanceof MemoryDrawing) {
489 6
                ob_start();
490 6
                call_user_func(
491 6
                    $this->getDrawingHashTable()->getByIndex($i)->getRenderingFunction(),
492 6
                    $this->getDrawingHashTable()->getByIndex($i)->getImageResource()
493
                );
494 6
                $imageContents = ob_get_contents();
495 6
                ob_end_clean();
496
497 6
                $this->addZipFile('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents);
498
            }
499
        }
500
501 128
        Functions::setReturnDateType($saveDateReturnType);
502 128
        Calculation::getInstance($this->spreadSheet)->getDebugLog()->setWriteDebugLog($saveDebugLog);
503
504
        // Close file
505
        try {
506 128
            $this->zip->finish();
507
        } catch (OverflowException $e) {
508
            throw new WriterException('Could not close resource.');
509
        }
510
511 128
        $this->maybeCloseFileHandle();
512 128
    }
513
514
    /**
515
     * Get Spreadsheet object.
516
     *
517
     * @return Spreadsheet
518
     */
519 128
    public function getSpreadsheet()
520
    {
521 128
        return $this->spreadSheet;
522
    }
523
524
    /**
525
     * Set Spreadsheet object.
526
     *
527
     * @param Spreadsheet $spreadsheet PhpSpreadsheet object
528
     *
529
     * @return $this
530
     */
531 129
    public function setSpreadsheet(Spreadsheet $spreadsheet)
532
    {
533 129
        $this->spreadSheet = $spreadsheet;
534
535 129
        return $this;
536
    }
537
538
    /**
539
     * Get string table.
540
     *
541
     * @return string[]
542
     */
543
    public function getStringTable()
544
    {
545
        return $this->stringTable;
546
    }
547
548
    /**
549
     * Get Style HashTable.
550
     *
551
     * @return HashTable<\PhpOffice\PhpSpreadsheet\Style\Style>
552
     */
553
    public function getStyleHashTable()
554
    {
555
        return $this->styleHashTable;
556
    }
557
558
    /**
559
     * Get Conditional HashTable.
560
     *
561
     * @return HashTable<Conditional>
562
     */
563 128
    public function getStylesConditionalHashTable()
564
    {
565 128
        return $this->stylesConditionalHashTable;
566
    }
567
568
    /**
569
     * Get Fill HashTable.
570
     *
571
     * @return HashTable<Fill>
572
     */
573 128
    public function getFillHashTable()
574
    {
575 128
        return $this->fillHashTable;
576
    }
577
578
    /**
579
     * Get \PhpOffice\PhpSpreadsheet\Style\Font HashTable.
580
     *
581
     * @return HashTable<Font>
582
     */
583 128
    public function getFontHashTable()
584
    {
585 128
        return $this->fontHashTable;
586
    }
587
588
    /**
589
     * Get Borders HashTable.
590
     *
591
     * @return HashTable<Borders>
592
     */
593 128
    public function getBordersHashTable()
594
    {
595 128
        return $this->bordersHashTable;
596
    }
597
598
    /**
599
     * Get NumberFormat HashTable.
600
     *
601
     * @return HashTable<NumberFormat>
602
     */
603 128
    public function getNumFmtHashTable()
604
    {
605 128
        return $this->numFmtHashTable;
606
    }
607
608
    /**
609
     * Get \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\BaseDrawing HashTable.
610
     *
611
     * @return HashTable<BaseDrawing>
612
     */
613 128
    public function getDrawingHashTable()
614
    {
615 128
        return $this->drawingHashTable;
616
    }
617
618
    /**
619
     * Get Office2003 compatibility.
620
     *
621
     * @return bool
622
     */
623 128
    public function getOffice2003Compatibility()
624
    {
625 128
        return $this->office2003compatibility;
626
    }
627
628
    /**
629
     * Set Office2003 compatibility.
630
     *
631
     * @param bool $pValue Office2003 compatibility?
632
     *
633
     * @return $this
634
     */
635
    public function setOffice2003Compatibility($pValue)
636
    {
637
        $this->office2003compatibility = $pValue;
638
639
        return $this;
640
    }
641
642
    private $pathNames = [];
643
644 128
    private function addZipFile(string $path, string $content): void
645
    {
646 128
        if (!in_array($path, $this->pathNames)) {
647 128
            $this->pathNames[] = $path;
648 128
            $this->zip->addFile($path, $content);
649
        }
650 128
    }
651
}
652