| Línea 14... |
Línea 14... |
| 14 |
use OpenSpout\Writer\Common\Helper\FileSystemWithRootFolderHelperInterface;
|
14 |
use OpenSpout\Writer\Common\Helper\FileSystemWithRootFolderHelperInterface;
|
| 15 |
use OpenSpout\Writer\Common\Helper\ZipHelper;
|
15 |
use OpenSpout\Writer\Common\Helper\ZipHelper;
|
| 16 |
use OpenSpout\Writer\XLSX\Manager\Style\StyleManager;
|
16 |
use OpenSpout\Writer\XLSX\Manager\Style\StyleManager;
|
| 17 |
use OpenSpout\Writer\XLSX\MergeCell;
|
17 |
use OpenSpout\Writer\XLSX\MergeCell;
|
| 18 |
use OpenSpout\Writer\XLSX\Options;
|
18 |
use OpenSpout\Writer\XLSX\Options;
|
| - |
|
19 |
use OpenSpout\Writer\XLSX\Properties;
|
| Línea 19... |
Línea 20... |
| 19 |
|
20 |
|
| 20 |
/**
|
21 |
/**
|
| 21 |
* @internal
|
22 |
* @internal
|
| 22 |
*/
|
23 |
*/
|
| Línea 29... |
Línea 30... |
| 29 |
public const WORKSHEETS_FOLDER_NAME = 'worksheets';
|
30 |
public const WORKSHEETS_FOLDER_NAME = 'worksheets';
|
| Línea 30... |
Línea 31... |
| 30 |
|
31 |
|
| 31 |
public const RELS_FILE_NAME = '.rels';
|
32 |
public const RELS_FILE_NAME = '.rels';
|
| 32 |
public const APP_XML_FILE_NAME = 'app.xml';
|
33 |
public const APP_XML_FILE_NAME = 'app.xml';
|
| - |
|
34 |
public const CORE_XML_FILE_NAME = 'core.xml';
|
| 33 |
public const CORE_XML_FILE_NAME = 'core.xml';
|
35 |
public const CUSTOM_XML_FILE_NAME = 'custom.xml';
|
| 34 |
public const CONTENT_TYPES_XML_FILE_NAME = '[Content_Types].xml';
|
36 |
public const CONTENT_TYPES_XML_FILE_NAME = '[Content_Types].xml';
|
| 35 |
public const WORKBOOK_XML_FILE_NAME = 'workbook.xml';
|
37 |
public const WORKBOOK_XML_FILE_NAME = 'workbook.xml';
|
| 36 |
public const WORKBOOK_RELS_XML_FILE_NAME = 'workbook.xml.rels';
|
38 |
public const WORKBOOK_RELS_XML_FILE_NAME = 'workbook.xml.rels';
|
| Línea 45... |
Línea 47... |
| 45 |
private readonly CommonFileSystemHelper $baseFileSystemHelper;
|
47 |
private readonly CommonFileSystemHelper $baseFileSystemHelper;
|
| Línea 46... |
Línea 48... |
| 46 |
|
48 |
|
| 47 |
/** @var ZipHelper Helper to perform tasks with Zip archive */
|
49 |
/** @var ZipHelper Helper to perform tasks with Zip archive */
|
| Línea 48... |
Línea 50... |
| 48 |
private readonly ZipHelper $zipHelper;
|
50 |
private readonly ZipHelper $zipHelper;
|
| 49 |
|
51 |
|
| Línea 50... |
Línea 52... |
| 50 |
/** @var string document creator */
|
52 |
/** @var Properties document properties */
|
| 51 |
private readonly string $creator;
|
53 |
private readonly Properties $properties;
|
| Línea 52... |
Línea 54... |
| 52 |
|
54 |
|
| Línea 73... |
Línea 75... |
| 73 |
|
75 |
|
| 74 |
/** @var string Path to the temp folder, inside the root folder, where specific sheets content will be written to */
|
76 |
/** @var string Path to the temp folder, inside the root folder, where specific sheets content will be written to */
|
| Línea 75... |
Línea 77... |
| 75 |
private string $sheetsContentTempFolder;
|
77 |
private string $sheetsContentTempFolder;
|
| 76 |
|
78 |
|
| 77 |
/**
|
79 |
/**
|
| 78 |
* @param string $baseFolderPath The path of the base folder where all the I/O can occur
|
80 |
* @param string $baseFolderPath The path of the base folder where all the I/O can occur
|
| 79 |
* @param ZipHelper $zipHelper Helper to perform tasks with Zip archive
|
81 |
* @param ZipHelper $zipHelper Helper to perform tasks with Zip archive
|
| 80 |
* @param XLSX $escaper Used to escape XML data
|
82 |
* @param XLSX $escaper Used to escape XML data
|
| 81 |
* @param string $creator document creator
|
83 |
* @param Properties $properties document properies
|
| 82 |
*/
|
84 |
*/
|
| 83 |
public function __construct(string $baseFolderPath, ZipHelper $zipHelper, XLSX $escaper, string $creator)
|
85 |
public function __construct(string $baseFolderPath, ZipHelper $zipHelper, XLSX $escaper, Properties $properties)
|
| 84 |
{
|
86 |
{
|
| 85 |
$this->baseFileSystemHelper = new CommonFileSystemHelper($baseFolderPath);
|
87 |
$this->baseFileSystemHelper = new CommonFileSystemHelper($baseFolderPath);
|
| 86 |
$this->baseFolderRealPath = $this->baseFileSystemHelper->getBaseFolderRealPath();
|
88 |
$this->baseFolderRealPath = $this->baseFileSystemHelper->getBaseFolderRealPath();
|
| 87 |
$this->zipHelper = $zipHelper;
|
89 |
$this->zipHelper = $zipHelper;
|
| 88 |
$this->escaper = $escaper;
|
90 |
$this->escaper = $escaper;
|
| Línea 89... |
Línea 91... |
| 89 |
$this->creator = $creator;
|
91 |
$this->properties = $properties;
|
| 90 |
}
|
92 |
}
|
| 91 |
|
93 |
|
| Línea 166... |
Línea 168... |
| 166 |
$contentTypesXmlFileContents .= '<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" PartName="/xl/worksheets/sheet'.$worksheet->getId().'.xml"/>';
|
168 |
$contentTypesXmlFileContents .= '<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" PartName="/xl/worksheets/sheet'.$worksheet->getId().'.xml"/>';
|
| 167 |
$contentTypesXmlFileContents .= '<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml" PartName="/xl/comments'.$worksheet->getId().'.xml" />';
|
169 |
$contentTypesXmlFileContents .= '<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml" PartName="/xl/comments'.$worksheet->getId().'.xml" />';
|
| 168 |
}
|
170 |
}
|
| Línea 169... |
Línea 171... |
| 169 |
|
171 |
|
| 170 |
$contentTypesXmlFileContents .= <<<'EOD'
|
172 |
$contentTypesXmlFileContents .= <<<'EOD'
|
| 171 |
<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml" PartName="/xl/styles.xml"/>
|
173 |
<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml" PartName="/xl/styles.xml"/>
|
| 172 |
<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml" PartName="/xl/sharedStrings.xml"/>
|
174 |
<Override ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml" PartName="/xl/sharedStrings.xml"/>
|
| 173 |
<Override ContentType="application/vnd.openxmlformats-package.core-properties+xml" PartName="/docProps/core.xml"/>
|
175 |
<Override ContentType="application/vnd.openxmlformats-package.core-properties+xml" PartName="/docProps/core.xml"/>
|
| - |
|
176 |
<Override ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml" PartName="/docProps/app.xml"/>
|
| - |
|
177 |
EOD;
|
| - |
|
178 |
|
| - |
|
179 |
if ([] !== $this->properties->customProperties) {
|
| - |
|
180 |
$contentTypesXmlFileContents .= <<<'EOD'
|
| - |
|
181 |
<Override ContentType="application/vnd.openxmlformats-officedocument.custom-properties+xml" PartName="/docProps/custom.xml" />
|
| - |
|
182 |
EOD;
|
| - |
|
183 |
}
|
| - |
|
184 |
|
| 174 |
<Override ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml" PartName="/docProps/app.xml"/>
|
185 |
$contentTypesXmlFileContents .= <<<'EOD'
|
| 175 |
</Types>
|
186 |
</Types>
|
| Línea 176... |
Línea 187... |
| 176 |
EOD;
|
187 |
EOD;
|
| Línea 183... |
Línea 194... |
| 183 |
/**
|
194 |
/**
|
| 184 |
* Creates the "workbook.xml" file under the "xl" folder.
|
195 |
* Creates the "workbook.xml" file under the "xl" folder.
|
| 185 |
*
|
196 |
*
|
| 186 |
* @param Worksheet[] $worksheets
|
197 |
* @param Worksheet[] $worksheets
|
| 187 |
*/
|
198 |
*/
|
| 188 |
public function createWorkbookFile(array $worksheets): self
|
199 |
public function createWorkbookFile(Options $options, array $worksheets): self
|
| 189 |
{
|
200 |
{
|
| 190 |
$workbookXmlFileContents = <<<'EOD'
|
201 |
$workbookXmlFileContents = <<<'EOD'
|
| 191 |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
202 |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
| 192 |
<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
|
203 |
<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
|
| - |
|
204 |
EOD;
|
| - |
|
205 |
|
| - |
|
206 |
if (null !== $options->getWorkbookProtection()) {
|
| - |
|
207 |
$workbookXmlFileContents .= $options->getWorkbookProtection()->getXml();
|
| - |
|
208 |
}
|
| - |
|
209 |
|
| - |
|
210 |
$workbookXmlFileContents .= <<<'EOD'
|
| 193 |
<sheets>
|
211 |
<sheets>
|
| 194 |
EOD;
|
212 |
EOD;
|
| Línea 195... |
Línea 213... |
| 195 |
|
213 |
|
| 196 |
/** @var Worksheet $worksheet */
|
214 |
/** @var Worksheet $worksheet */
|
| Línea 210... |
Línea 228... |
| 210 |
/** @var Worksheet $worksheet */
|
228 |
/** @var Worksheet $worksheet */
|
| 211 |
foreach ($worksheets as $worksheet) {
|
229 |
foreach ($worksheets as $worksheet) {
|
| 212 |
$sheet = $worksheet->getExternalSheet();
|
230 |
$sheet = $worksheet->getExternalSheet();
|
| 213 |
if (null !== $autofilter = $sheet->getAutoFilter()) {
|
231 |
if (null !== $autofilter = $sheet->getAutoFilter()) {
|
| 214 |
$worksheetName = $sheet->getName();
|
232 |
$worksheetName = $sheet->getName();
|
| 215 |
$name = sprintf(
|
233 |
$name = \sprintf(
|
| 216 |
'\'%s\'!$%s$%s:$%s$%s',
|
234 |
'\'%s\'!$%s$%s:$%s$%s',
|
| 217 |
$this->escaper->escape($worksheetName),
|
235 |
$this->escaper->escape($worksheetName),
|
| 218 |
CellHelper::getColumnLettersFromColumnIndex($autofilter->fromColumnIndex),
|
236 |
CellHelper::getColumnLettersFromColumnIndex($autofilter->fromColumnIndex),
|
| 219 |
$autofilter->fromRow,
|
237 |
$autofilter->fromRow,
|
| 220 |
CellHelper::getColumnLettersFromColumnIndex($autofilter->toColumnIndex),
|
238 |
CellHelper::getColumnLettersFromColumnIndex($autofilter->toColumnIndex),
|
| Línea 319... |
Línea 337... |
| 319 |
|
337 |
|
| 320 |
$sheet = $worksheet->getExternalSheet();
|
338 |
$sheet = $worksheet->getExternalSheet();
|
| Línea 321... |
Línea 339... |
| 321 |
fwrite($worksheetFilePointer, self::SHEET_XML_FILE_HEADER);
|
339 |
fwrite($worksheetFilePointer, self::SHEET_XML_FILE_HEADER);
|
| 322 |
|
- |
|
| 323 |
// AutoFilter tags
|
340 |
|
| 324 |
$range = '';
|
- |
|
| 325 |
if (null !== $autofilter = $sheet->getAutoFilter()) {
|
- |
|
| 326 |
$range = sprintf(
|
- |
|
| 327 |
'%s%s:%s%s',
|
- |
|
| 328 |
CellHelper::getColumnLettersFromColumnIndex($autofilter->fromColumnIndex),
|
- |
|
| 329 |
$autofilter->fromRow,
|
- |
|
| 330 |
CellHelper::getColumnLettersFromColumnIndex($autofilter->toColumnIndex),
|
- |
|
| 331 |
$autofilter->toRow
|
341 |
// AutoFilter tags
|
| 332 |
);
|
342 |
if (null !== $autofilter = $sheet->getAutoFilter()) {
|
| 333 |
if (isset($pageSetup) && $pageSetup->fitToPage) {
|
343 |
if (isset($pageSetup) && $pageSetup->fitToPage) {
|
| 334 |
fwrite($worksheetFilePointer, '<sheetPr filterMode="false"><pageSetUpPr fitToPage="true"/></sheetPr>');
|
344 |
fwrite($worksheetFilePointer, '<sheetPr filterMode="false"><pageSetUpPr fitToPage="true"/></sheetPr>');
|
| 335 |
} else {
|
345 |
} else {
|
| 336 |
fwrite($worksheetFilePointer, '<sheetPr filterMode="false"><pageSetUpPr fitToPage="false"/></sheetPr>');
|
- |
|
| 337 |
}
|
346 |
fwrite($worksheetFilePointer, '<sheetPr filterMode="false"><pageSetUpPr fitToPage="false"/></sheetPr>');
|
| 338 |
fwrite($worksheetFilePointer, sprintf('<dimension ref="%s"/>', $range));
|
347 |
}
|
| 339 |
} elseif (isset($pageSetup) && $pageSetup->fitToPage) {
|
348 |
} elseif (isset($pageSetup) && $pageSetup->fitToPage) {
|
| - |
|
349 |
fwrite($worksheetFilePointer, '<sheetPr><pageSetUpPr fitToPage="true"/></sheetPr>');
|
| - |
|
350 |
}
|
| - |
|
351 |
$sheetRange = \sprintf(
|
| - |
|
352 |
'%s%s:%s%s',
|
| - |
|
353 |
CellHelper::getColumnLettersFromColumnIndex(0),
|
| - |
|
354 |
1,
|
| - |
|
355 |
CellHelper::getColumnLettersFromColumnIndex($worksheet->getMaxNumColumns() - 1),
|
| - |
|
356 |
$worksheet->getLastWrittenRowIndex()
|
| 340 |
fwrite($worksheetFilePointer, '<sheetPr><pageSetUpPr fitToPage="true"/></sheetPr>');
|
357 |
);
|
| 341 |
}
|
358 |
fwrite($worksheetFilePointer, \sprintf('<dimension ref="%s"/>', $sheetRange));
|
| 342 |
if (null !== ($sheetView = $sheet->getSheetView())) {
|
359 |
if (null !== ($sheetView = $sheet->getSheetView())) {
|
| 343 |
fwrite($worksheetFilePointer, '<sheetViews>'.$sheetView->getXml().'</sheetViews>');
|
360 |
fwrite($worksheetFilePointer, '<sheetViews>'.$sheetView->getXml().'</sheetViews>');
|
| 344 |
}
|
361 |
}
|
| Línea 348... |
Línea 365... |
| 348 |
|
365 |
|
| 349 |
$worksheetFilePath = $worksheet->getFilePath();
|
366 |
$worksheetFilePath = $worksheet->getFilePath();
|
| 350 |
$this->copyFileContentsToTarget($worksheetFilePath, $worksheetFilePointer);
|
367 |
$this->copyFileContentsToTarget($worksheetFilePath, $worksheetFilePointer);
|
| Línea -... |
Línea 368... |
| - |
|
368 |
fwrite($worksheetFilePointer, '</sheetData>');
|
| - |
|
369 |
|
| - |
|
370 |
if (null !== $sheet->getSheetProtection()) {
|
| - |
|
371 |
fwrite($worksheetFilePointer, $sheet->getSheetProtection()->getXml());
|
| 351 |
fwrite($worksheetFilePointer, '</sheetData>');
|
372 |
}
|
| 352 |
|
373 |
|
| - |
|
374 |
// AutoFilter tag
|
| - |
|
375 |
if (null !== $autofilter) {
|
| - |
|
376 |
$autoFilterRange = \sprintf(
|
| - |
|
377 |
'%s%s:%s%s',
|
| - |
|
378 |
CellHelper::getColumnLettersFromColumnIndex($autofilter->fromColumnIndex),
|
| - |
|
379 |
$autofilter->fromRow,
|
| - |
|
380 |
CellHelper::getColumnLettersFromColumnIndex($autofilter->toColumnIndex),
|
| 353 |
// AutoFilter tag
|
381 |
$autofilter->toRow
|
| 354 |
if ('' !== $range) {
|
382 |
);
|
| Línea 355... |
Línea 383... |
| 355 |
fwrite($worksheetFilePointer, sprintf('<autoFilter ref="%s"/>', $range));
|
383 |
fwrite($worksheetFilePointer, \sprintf('<autoFilter ref="%s"/>', $autoFilterRange));
|
| 356 |
}
|
384 |
}
|
| 357 |
|
385 |
|
| Línea 363... |
Línea 391... |
| 363 |
if ([] !== $mergeCells) {
|
391 |
if ([] !== $mergeCells) {
|
| 364 |
$mergeCellString = '<mergeCells count="'.\count($mergeCells).'">';
|
392 |
$mergeCellString = '<mergeCells count="'.\count($mergeCells).'">';
|
| 365 |
foreach ($mergeCells as $mergeCell) {
|
393 |
foreach ($mergeCells as $mergeCell) {
|
| 366 |
$topLeft = CellHelper::getColumnLettersFromColumnIndex($mergeCell->topLeftColumn).$mergeCell->topLeftRow;
|
394 |
$topLeft = CellHelper::getColumnLettersFromColumnIndex($mergeCell->topLeftColumn).$mergeCell->topLeftRow;
|
| 367 |
$bottomRight = CellHelper::getColumnLettersFromColumnIndex($mergeCell->bottomRightColumn).$mergeCell->bottomRightRow;
|
395 |
$bottomRight = CellHelper::getColumnLettersFromColumnIndex($mergeCell->bottomRightColumn).$mergeCell->bottomRightRow;
|
| 368 |
$mergeCellString .= sprintf(
|
396 |
$mergeCellString .= \sprintf(
|
| 369 |
'<mergeCell ref="%s:%s"/>',
|
397 |
'<mergeCell ref="%s:%s"/>',
|
| 370 |
$topLeft,
|
398 |
$topLeft,
|
| 371 |
$bottomRight
|
399 |
$bottomRight
|
| 372 |
);
|
400 |
);
|
| 373 |
}
|
401 |
}
|
| Línea 583... |
Línea 611... |
| 583 |
*
|
611 |
*
|
| 584 |
* @throws IOException If unable to create the file
|
612 |
* @throws IOException If unable to create the file
|
| 585 |
*/
|
613 |
*/
|
| 586 |
private function createRelsFile(): self
|
614 |
private function createRelsFile(): self
|
| 587 |
{
|
615 |
{
|
| - |
|
616 |
$relationshipsXmlContents = <<<'EOD'
|
| - |
|
617 |
<Relationship Id="rIdWorkbook" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>
|
| - |
|
618 |
<Relationship Id="rIdCore" Type="http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>
|
| - |
|
619 |
<Relationship Id="rIdApp" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>
|
| - |
|
620 |
EOD;
|
| - |
|
621 |
|
| - |
|
622 |
if ([] !== $this->properties->customProperties) {
|
| - |
|
623 |
$relationshipsXmlContents .= <<<'EOD'
|
| - |
|
624 |
<Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties" Target="docProps/custom.xml"/>
|
| - |
|
625 |
EOD;
|
| - |
|
626 |
}
|
| - |
|
627 |
|
| 588 |
$relsFileContents = <<<'EOD'
|
628 |
$relsFileContents = <<<EOD
|
| 589 |
<?xml version="1.0" encoding="UTF-8"?>
|
629 |
<?xml version="1.0" encoding="UTF-8"?>
|
| 590 |
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
630 |
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">{$relationshipsXmlContents}</Relationships>
|
| 591 |
<Relationship Id="rIdWorkbook" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>
|
- |
|
| 592 |
<Relationship Id="rIdCore" Type="http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>
|
- |
|
| 593 |
<Relationship Id="rIdApp" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>
|
- |
|
| 594 |
</Relationships>
|
- |
|
| 595 |
EOD;
|
631 |
EOD;
|
| Línea 596... |
Línea 632... |
| 596 |
|
632 |
|
| Línea 597... |
Línea 633... |
| 597 |
$this->createFileWithContents($this->relsFolder, self::RELS_FILE_NAME, $relsFileContents);
|
633 |
$this->createFileWithContents($this->relsFolder, self::RELS_FILE_NAME, $relsFileContents);
|
| Línea 609... |
Línea 645... |
| 609 |
$this->docPropsFolder = $this->createFolder($this->rootFolder, self::DOC_PROPS_FOLDER_NAME);
|
645 |
$this->docPropsFolder = $this->createFolder($this->rootFolder, self::DOC_PROPS_FOLDER_NAME);
|
| Línea 610... |
Línea 646... |
| 610 |
|
646 |
|
| 611 |
$this->createAppXmlFile();
|
647 |
$this->createAppXmlFile();
|
| Línea -... |
Línea 648... |
| - |
|
648 |
$this->createCoreXmlFile();
|
| - |
|
649 |
|
| - |
|
650 |
if ([] !== $this->properties->customProperties) {
|
| - |
|
651 |
$this->createCustomXmlFile();
|
| 612 |
$this->createCoreXmlFile();
|
652 |
}
|
| 613 |
|
653 |
|
| Línea 614... |
Línea 654... |
| 614 |
return $this;
|
654 |
return $this;
|
| 615 |
}
|
655 |
}
|
| Línea 622... |
Línea 662... |
| 622 |
private function createAppXmlFile(): self
|
662 |
private function createAppXmlFile(): self
|
| 623 |
{
|
663 |
{
|
| 624 |
$appXmlFileContents = <<<EOD
|
664 |
$appXmlFileContents = <<<EOD
|
| 625 |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
665 |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
| 626 |
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties">
|
666 |
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties">
|
| 627 |
<Application>{$this->creator}</Application>
|
667 |
<Application>{$this->properties->application}</Application>
|
| 628 |
<TotalTime>0</TotalTime>
|
668 |
<TotalTime>0</TotalTime>
|
| 629 |
</Properties>
|
669 |
</Properties>
|
| 630 |
EOD;
|
670 |
EOD;
|
| Línea 631... |
Línea 671... |
| 631 |
|
671 |
|
| Línea 643... |
Línea 683... |
| 643 |
{
|
683 |
{
|
| 644 |
$createdDate = (new DateTimeImmutable())->format(DateTimeImmutable::W3C);
|
684 |
$createdDate = (new DateTimeImmutable())->format(DateTimeImmutable::W3C);
|
| 645 |
$coreXmlFileContents = <<<EOD
|
685 |
$coreXmlFileContents = <<<EOD
|
| 646 |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
686 |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
| 647 |
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
687 |
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
| - |
|
688 |
<dc:title>{$this->properties->title}</dc:title>
|
| - |
|
689 |
<dc:subject>{$this->properties->subject}</dc:subject>
|
| - |
|
690 |
<dc:creator>{$this->properties->creator}</dc:creator>
|
| - |
|
691 |
<cp:lastModifiedBy>{$this->properties->lastModifiedBy}</cp:lastModifiedBy>
|
| - |
|
692 |
<cp:keywords>{$this->properties->keywords}</cp:keywords>
|
| - |
|
693 |
<dc:description>{$this->properties->description}</dc:description>
|
| - |
|
694 |
<cp:category>{$this->properties->category}</cp:category>
|
| - |
|
695 |
<dc:language>{$this->properties->language}</dc:language>
|
| 648 |
<dcterms:created xsi:type="dcterms:W3CDTF">{$createdDate}</dcterms:created>
|
696 |
<dcterms:created xsi:type="dcterms:W3CDTF">{$createdDate}</dcterms:created>
|
| 649 |
<dcterms:modified xsi:type="dcterms:W3CDTF">{$createdDate}</dcterms:modified>
|
697 |
<dcterms:modified xsi:type="dcterms:W3CDTF">{$createdDate}</dcterms:modified>
|
| 650 |
<cp:revision>0</cp:revision>
|
698 |
<cp:revision>0</cp:revision>
|
| 651 |
</cp:coreProperties>
|
699 |
</cp:coreProperties>
|
| 652 |
EOD;
|
700 |
EOD;
|
| Línea 655... |
Línea 703... |
| 655 |
|
703 |
|
| 656 |
return $this;
|
704 |
return $this;
|
| Línea 657... |
Línea 705... |
| 657 |
}
|
705 |
}
|
| - |
|
706 |
|
| - |
|
707 |
/**
|
| - |
|
708 |
* Creates the "custom.xml" file under the "docProps" folder.
|
| - |
|
709 |
*
|
| - |
|
710 |
* @throws IOException If unable to create the file
|
| - |
|
711 |
*/
|
| - |
|
712 |
private function createCustomXmlFile(): self
|
| - |
|
713 |
{
|
| - |
|
714 |
/** The pid must increment for each property, starting with 2 */
|
| - |
|
715 |
$pid = 2;
|
| - |
|
716 |
$propertiesXmlContents = '';
|
| - |
|
717 |
|
| - |
|
718 |
foreach ($this->properties->customProperties as $name => $value) {
|
| - |
|
719 |
$propertiesXmlContents .= <<<EOD
|
| - |
|
720 |
<property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="{$pid}" name="{$name}"><vt:lpwstr>{$value}</vt:lpwstr></property>
|
| - |
|
721 |
EOD;
|
| - |
|
722 |
|
| - |
|
723 |
++$pid;
|
| - |
|
724 |
}
|
| - |
|
725 |
|
| - |
|
726 |
$customXmlFileContents = <<<EOD
|
| - |
|
727 |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
| - |
|
728 |
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">{$propertiesXmlContents}</Properties>
|
| - |
|
729 |
EOD;
|
| - |
|
730 |
|
| - |
|
731 |
$this->createFileWithContents($this->docPropsFolder, self::CUSTOM_XML_FILE_NAME, $customXmlFileContents);
|
| - |
|
732 |
|
| - |
|
733 |
return $this;
|
| - |
|
734 |
}
|
| 658 |
|
735 |
|
| 659 |
/**
|
736 |
/**
|
| 660 |
* Creates the "xl" folder under the root folder as well as its subfolders.
|
737 |
* Creates the "xl" folder under the root folder as well as its subfolders.
|
| 661 |
*
|
738 |
*
|
| 662 |
* @throws IOException If unable to create at least one of the folders
|
739 |
* @throws IOException If unable to create at least one of the folders
|