8889841cPK[4Thumbnails.phpnu[ */ class Comment { public static function write(XMLWriter $objWriter, Cell $cell): void { $comments = $cell->getWorksheet()->getComments(); if (!isset($comments[$cell->getCoordinate()])) { return; } $comment = $comments[$cell->getCoordinate()]; $objWriter->startElement('office:annotation'); $objWriter->writeAttribute('svg:width', $comment->getWidth()); $objWriter->writeAttribute('svg:height', $comment->getHeight()); $objWriter->writeAttribute('svg:x', $comment->getMarginLeft()); $objWriter->writeAttribute('svg:y', $comment->getMarginTop()); $objWriter->writeElement('dc:creator', $comment->getAuthor()); $objWriter->writeElement('text:p', $comment->getText()->getPlainText()); $objWriter->endElement(); } } PK[bCell/Style.phpnu[writer = $writer; } private function mapHorizontalAlignment(string $horizontalAlignment): string { switch ($horizontalAlignment) { case Alignment::HORIZONTAL_CENTER: case Alignment::HORIZONTAL_CENTER_CONTINUOUS: case Alignment::HORIZONTAL_DISTRIBUTED: return 'center'; case Alignment::HORIZONTAL_RIGHT: return 'end'; case Alignment::HORIZONTAL_FILL: case Alignment::HORIZONTAL_JUSTIFY: return 'justify'; } return 'start'; } private function mapVerticalAlignment(string $verticalAlignment): string { switch ($verticalAlignment) { case Alignment::VERTICAL_TOP: return 'top'; case Alignment::VERTICAL_CENTER: return 'middle'; case Alignment::VERTICAL_DISTRIBUTED: case Alignment::VERTICAL_JUSTIFY: return 'automatic'; } return 'bottom'; } private function writeFillStyle(Fill $fill): void { switch ($fill->getFillType()) { case Fill::FILL_SOLID: $this->writer->writeAttribute('fo:background-color', sprintf( '#%s', strtolower($fill->getStartColor()->getRGB()) )); break; case Fill::FILL_GRADIENT_LINEAR: case Fill::FILL_GRADIENT_PATH: /// TODO :: To be implemented break; case Fill::FILL_NONE: default: } } private function writeCellProperties(CellStyle $style): void { // Align $hAlign = $style->getAlignment()->getHorizontal(); $vAlign = $style->getAlignment()->getVertical(); $wrap = $style->getAlignment()->getWrapText(); $this->writer->startElement('style:table-cell-properties'); if (!empty($vAlign) || $wrap) { if (!empty($vAlign)) { $vAlign = $this->mapVerticalAlignment($vAlign); $this->writer->writeAttribute('style:vertical-align', $vAlign); } if ($wrap) { $this->writer->writeAttribute('fo:wrap-option', 'wrap'); } } $this->writer->writeAttribute('style:rotation-align', 'none'); // Fill if ($fill = $style->getFill()) { $this->writeFillStyle($fill); } $this->writer->endElement(); if (!empty($hAlign)) { $hAlign = $this->mapHorizontalAlignment($hAlign); $this->writer->startElement('style:paragraph-properties'); $this->writer->writeAttribute('fo:text-align', $hAlign); $this->writer->endElement(); } } protected function mapUnderlineStyle(Font $font): string { switch ($font->getUnderline()) { case Font::UNDERLINE_DOUBLE: case Font::UNDERLINE_DOUBLEACCOUNTING: return'double'; case Font::UNDERLINE_SINGLE: case Font::UNDERLINE_SINGLEACCOUNTING: return'single'; } return 'none'; } protected function writeTextProperties(CellStyle $style): void { // Font $this->writer->startElement('style:text-properties'); $font = $style->getFont(); if ($font->getBold()) { $this->writer->writeAttribute('fo:font-weight', 'bold'); $this->writer->writeAttribute('style:font-weight-complex', 'bold'); $this->writer->writeAttribute('style:font-weight-asian', 'bold'); } if ($font->getItalic()) { $this->writer->writeAttribute('fo:font-style', 'italic'); } if ($color = $font->getColor()) { $this->writer->writeAttribute('fo:color', sprintf('#%s', $color->getRGB())); } if ($family = $font->getName()) { $this->writer->writeAttribute('fo:font-family', $family); } if ($size = $font->getSize()) { $this->writer->writeAttribute('fo:font-size', sprintf('%.1Fpt', $size)); } if ($font->getUnderline() && $font->getUnderline() !== Font::UNDERLINE_NONE) { $this->writer->writeAttribute('style:text-underline-style', 'solid'); $this->writer->writeAttribute('style:text-underline-width', 'auto'); $this->writer->writeAttribute('style:text-underline-color', 'font-color'); $underline = $this->mapUnderlineStyle($font); $this->writer->writeAttribute('style:text-underline-type', $underline); } $this->writer->endElement(); // Close style:text-properties } public function write(CellStyle $style): void { $this->writer->startElement('style:style'); $this->writer->writeAttribute('style:name', self::CELL_STYLE_PREFIX . $style->getIndex()); $this->writer->writeAttribute('style:family', 'table-cell'); $this->writer->writeAttribute('style:parent-style-name', 'Default'); // Alignment, fill colour, etc $this->writeCellProperties($style); // style:text-properties $this->writeTextProperties($style); // End $this->writer->endElement(); // Close style:style } } PK[CPL,4,4 Content.phpnu[ */ class Content extends WriterPart { const NUMBER_COLS_REPEATED_MAX = 1024; const NUMBER_ROWS_REPEATED_MAX = 1048576; private $formulaConvertor; /** * Set parent Ods writer. */ public function __construct(Ods $writer) { parent::__construct($writer); $this->formulaConvertor = new Formula($this->getParentWriter()->getSpreadsheet()->getDefinedNames()); } /** * Write content.xml to XML format. * * @return string XML Output */ public function write(): string { $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header $objWriter->startDocument('1.0', 'UTF-8'); // Content $objWriter->startElement('office:document-content'); $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); $objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0'); $objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0'); $objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0'); $objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'); $objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'); $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); $objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0'); $objWriter->writeAttribute('xmlns:presentation', 'urn:oasis:names:tc:opendocument:xmlns:presentation:1.0'); $objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'); $objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0'); $objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0'); $objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML'); $objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0'); $objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0'); $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); $objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer'); $objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc'); $objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events'); $objWriter->writeAttribute('xmlns:xforms', 'http://www.w3.org/2002/xforms'); $objWriter->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema'); $objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report'); $objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2'); $objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); $objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table'); $objWriter->writeAttribute('xmlns:field', 'urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0'); $objWriter->writeAttribute('xmlns:formx', 'urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0'); $objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/'); $objWriter->writeAttribute('office:version', '1.2'); $objWriter->writeElement('office:scripts'); $objWriter->writeElement('office:font-face-decls'); // Styles XF $objWriter->startElement('office:automatic-styles'); $this->writeXfStyles($objWriter, $this->getParentWriter()->getSpreadsheet()); $objWriter->endElement(); $objWriter->startElement('office:body'); $objWriter->startElement('office:spreadsheet'); $objWriter->writeElement('table:calculation-settings'); $this->writeSheets($objWriter); (new AutoFilters($objWriter, $this->getParentWriter()->getSpreadsheet()))->write(); // Defined names (ranges and formulae) (new NamedExpressions($objWriter, $this->getParentWriter()->getSpreadsheet(), $this->formulaConvertor))->write(); $objWriter->endElement(); $objWriter->endElement(); $objWriter->endElement(); return $objWriter->getData(); } /** * Write sheets. */ private function writeSheets(XMLWriter $objWriter): void { $spreadsheet = $this->getParentWriter()->getSpreadsheet(); /** @var Spreadsheet $spreadsheet */ $sheetCount = $spreadsheet->getSheetCount(); for ($i = 0; $i < $sheetCount; ++$i) { $objWriter->startElement('table:table'); $objWriter->writeAttribute('table:name', $spreadsheet->getSheet($i)->getTitle()); $objWriter->writeElement('office:forms'); $objWriter->startElement('table:table-column'); $objWriter->writeAttribute('table:number-columns-repeated', self::NUMBER_COLS_REPEATED_MAX); $objWriter->endElement(); $this->writeRows($objWriter, $spreadsheet->getSheet($i)); $objWriter->endElement(); } } /** * Write rows of the specified sheet. */ private function writeRows(XMLWriter $objWriter, Worksheet $sheet): void { $numberRowsRepeated = self::NUMBER_ROWS_REPEATED_MAX; $span_row = 0; $rows = $sheet->getRowIterator(); while ($rows->valid()) { --$numberRowsRepeated; $row = $rows->current(); if ($row->getCellIterator()->valid()) { if ($span_row) { $objWriter->startElement('table:table-row'); if ($span_row > 1) { $objWriter->writeAttribute('table:number-rows-repeated', $span_row); } $objWriter->startElement('table:table-cell'); $objWriter->writeAttribute('table:number-columns-repeated', self::NUMBER_COLS_REPEATED_MAX); $objWriter->endElement(); $objWriter->endElement(); $span_row = 0; } $objWriter->startElement('table:table-row'); $this->writeCells($objWriter, $row); $objWriter->endElement(); } else { ++$span_row; } $rows->next(); } } /** * Write cells of the specified row. */ private function writeCells(XMLWriter $objWriter, Row $row): void { $numberColsRepeated = self::NUMBER_COLS_REPEATED_MAX; $prevColumn = -1; $cells = $row->getCellIterator(); while ($cells->valid()) { /** @var \PhpOffice\PhpSpreadsheet\Cell\Cell $cell */ $cell = $cells->current(); $column = Coordinate::columnIndexFromString($cell->getColumn()) - 1; $this->writeCellSpan($objWriter, $column, $prevColumn); $objWriter->startElement('table:table-cell'); $this->writeCellMerge($objWriter, $cell); // Style XF $style = $cell->getXfIndex(); if ($style !== null) { $objWriter->writeAttribute('table:style-name', Style::CELL_STYLE_PREFIX . $style); } switch ($cell->getDataType()) { case DataType::TYPE_BOOL: $objWriter->writeAttribute('office:value-type', 'boolean'); $objWriter->writeAttribute('office:value', $cell->getValue()); $objWriter->writeElement('text:p', $cell->getValue()); break; case DataType::TYPE_ERROR: $objWriter->writeAttribute('table:formula', 'of:=#NULL!'); $objWriter->writeAttribute('office:value-type', 'string'); $objWriter->writeAttribute('office:string-value', ''); $objWriter->writeElement('text:p', '#NULL!'); break; case DataType::TYPE_FORMULA: $formulaValue = $cell->getValue(); if ($this->getParentWriter()->getPreCalculateFormulas()) { try { $formulaValue = $cell->getCalculatedValue(); } catch (Exception $e) { // don't do anything } } $objWriter->writeAttribute('table:formula', $this->formulaConvertor->convertFormula($cell->getValue())); if (is_numeric($formulaValue)) { $objWriter->writeAttribute('office:value-type', 'float'); } else { $objWriter->writeAttribute('office:value-type', 'string'); } $objWriter->writeAttribute('office:value', $formulaValue); $objWriter->writeElement('text:p', $formulaValue); break; case DataType::TYPE_NUMERIC: $objWriter->writeAttribute('office:value-type', 'float'); $objWriter->writeAttribute('office:value', $cell->getValue()); $objWriter->writeElement('text:p', $cell->getValue()); break; case DataType::TYPE_INLINE: // break intentionally omitted case DataType::TYPE_STRING: $objWriter->writeAttribute('office:value-type', 'string'); $objWriter->writeElement('text:p', $cell->getValue()); break; } Comment::write($objWriter, $cell); $objWriter->endElement(); $prevColumn = $column; $cells->next(); } $numberColsRepeated = $numberColsRepeated - $prevColumn - 1; if ($numberColsRepeated > 0) { if ($numberColsRepeated > 1) { $objWriter->startElement('table:table-cell'); $objWriter->writeAttribute('table:number-columns-repeated', $numberColsRepeated); $objWriter->endElement(); } else { $objWriter->writeElement('table:table-cell'); } } } /** * Write span. * * @param int $curColumn * @param int $prevColumn */ private function writeCellSpan(XMLWriter $objWriter, $curColumn, $prevColumn): void { $diff = $curColumn - $prevColumn - 1; if (1 === $diff) { $objWriter->writeElement('table:table-cell'); } elseif ($diff > 1) { $objWriter->startElement('table:table-cell'); $objWriter->writeAttribute('table:number-columns-repeated', $diff); $objWriter->endElement(); } } /** * Write XF cell styles. */ private function writeXfStyles(XMLWriter $writer, Spreadsheet $spreadsheet): void { $styleWriter = new Style($writer); foreach ($spreadsheet->getCellXfCollection() as $style) { $styleWriter->write($style); } } /** * Write attributes for merged cell. */ private function writeCellMerge(XMLWriter $objWriter, Cell $cell): void { if (!$cell->isMergeRangeValueCell()) { return; } $mergeRange = Coordinate::splitRange($cell->getMergeRange()); [$startCell, $endCell] = $mergeRange[0]; $start = Coordinate::coordinateFromString($startCell); $end = Coordinate::coordinateFromString($endCell); $columnSpan = Coordinate::columnIndexFromString($end[0]) - Coordinate::columnIndexFromString($start[0]) + 1; $rowSpan = ((int) $end[1]) - ((int) $start[1]) + 1; $objWriter->writeAttribute('table:number-columns-spanned', $columnSpan); $objWriter->writeAttribute('table:number-rows-spanned', $rowSpan); } } PK[+]AutoFilters.phpnu[objWriter = $objWriter; $this->spreadsheet = $spreadsheet; } public function write(): void { $wrapperWritten = false; $sheetCount = $this->spreadsheet->getSheetCount(); for ($i = 0; $i < $sheetCount; ++$i) { $worksheet = $this->spreadsheet->getSheet($i); $autofilter = $worksheet->getAutoFilter(); if ($autofilter !== null && !empty($autofilter->getRange())) { if ($wrapperWritten === false) { $this->objWriter->startElement('table:database-ranges'); $wrapperWritten = true; } $this->objWriter->startElement('table:database-range'); $this->objWriter->writeAttribute('table:orientation', 'column'); $this->objWriter->writeAttribute('table:display-filter-buttons', 'true'); $this->objWriter->writeAttribute( 'table:target-range-address', $this->formatRange($worksheet, $autofilter) ); $this->objWriter->endElement(); } } if ($wrapperWritten === true) { $this->objWriter->endElement(); } } protected function formatRange(Worksheet $worksheet, Autofilter $autofilter): string { $title = $worksheet->getTitle(); $range = $autofilter->getRange(); return "'{$title}'.{$range}"; } } PK[+hp22 Mimetype.phpnu[objWriter = $objWriter; $this->spreadsheet = $spreadsheet; $this->formulaConvertor = $formulaConvertor; } public function write(): string { $this->objWriter->startElement('table:named-expressions'); $this->writeExpressions(); $this->objWriter->endElement(); return ''; } private function writeExpressions(): void { $definedNames = $this->spreadsheet->getDefinedNames(); foreach ($definedNames as $definedName) { if ($definedName->isFormula()) { $this->objWriter->startElement('table:named-expression'); $this->writeNamedFormula($definedName, $this->spreadsheet->getActiveSheet()); } else { $this->objWriter->startElement('table:named-range'); $this->writeNamedRange($definedName); } $this->objWriter->endElement(); } } private function writeNamedFormula(DefinedName $definedName, Worksheet $defaultWorksheet): void { $title = ($definedName->getWorksheet() !== null) ? $definedName->getWorksheet()->getTitle() : $defaultWorksheet->getTitle(); $this->objWriter->writeAttribute('table:name', $definedName->getName()); $this->objWriter->writeAttribute( 'table:expression', $this->formulaConvertor->convertFormula($definedName->getValue(), $title) ); $this->objWriter->writeAttribute('table:base-cell-address', $this->convertAddress( $definedName, "'" . $title . "'!\$A\$1" )); } private function writeNamedRange(DefinedName $definedName): void { $baseCell = '$A$1'; $ws = $definedName->getWorksheet(); if ($ws !== null) { $baseCell = "'" . $ws->getTitle() . "'!$baseCell"; } $this->objWriter->writeAttribute('table:name', $definedName->getName()); $this->objWriter->writeAttribute('table:base-cell-address', $this->convertAddress( $definedName, $baseCell )); $this->objWriter->writeAttribute('table:cell-range-address', $this->convertAddress($definedName, $definedName->getValue())); } private function convertAddress(DefinedName $definedName, string $address): string { $splitCount = preg_match_all( '/' . Calculation::CALCULATION_REGEXP_CELLREF_RELATIVE . '/mui', $address, $splitRanges, PREG_OFFSET_CAPTURE ); $lengths = array_map('strlen', array_column($splitRanges[0], 0)); $offsets = array_column($splitRanges[0], 1); $worksheets = $splitRanges[2]; $columns = $splitRanges[6]; $rows = $splitRanges[7]; while ($splitCount > 0) { --$splitCount; $length = $lengths[$splitCount]; $offset = $offsets[$splitCount]; $worksheet = $worksheets[$splitCount][0]; $column = $columns[$splitCount][0]; $row = $rows[$splitCount][0]; $newRange = ''; if (empty($worksheet)) { if (($offset === 0) || ($address[$offset - 1] !== ':')) { // We need a worksheet $ws = $definedName->getWorksheet(); if ($ws !== null) { $worksheet = $ws->getTitle(); } } } else { $worksheet = str_replace("''", "'", trim($worksheet, "'")); } if (!empty($worksheet)) { $newRange = "'" . str_replace("'", "''", $worksheet) . "'."; } if (!empty($column)) { $newRange .= $column; } if (!empty($row)) { $newRange .= $row; } $address = substr($address, 0, $offset) . $newRange . substr($address, $offset + $length); } if (substr($address, 0, 1) === '=') { $address = substr($address, 1); } return $address; } } PK[::7Meta.phpnu[getParentWriter()->getSpreadsheet(); $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header $objWriter->startDocument('1.0', 'UTF-8'); // Meta $objWriter->startElement('office:document-meta'); $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); $objWriter->writeAttribute('office:version', '1.2'); $objWriter->startElement('office:meta'); $objWriter->writeElement('meta:initial-creator', $spreadsheet->getProperties()->getCreator()); $objWriter->writeElement('dc:creator', $spreadsheet->getProperties()->getCreator()); $created = $spreadsheet->getProperties()->getCreated(); $date = Date::dateTimeFromTimestamp("$created"); $date->setTimeZone(Date::getDefaultOrLocalTimeZone()); $objWriter->writeElement('meta:creation-date', $date->format(DATE_W3C)); $created = $spreadsheet->getProperties()->getModified(); $date = Date::dateTimeFromTimestamp("$created"); $date->setTimeZone(Date::getDefaultOrLocalTimeZone()); $objWriter->writeElement('dc:date', $date->format(DATE_W3C)); $objWriter->writeElement('dc:title', $spreadsheet->getProperties()->getTitle()); $objWriter->writeElement('dc:description', $spreadsheet->getProperties()->getDescription()); $objWriter->writeElement('dc:subject', $spreadsheet->getProperties()->getSubject()); $objWriter->writeElement('meta:keyword', $spreadsheet->getProperties()->getKeywords()); // Don't know if this changed over time, but the keywords are all // in a single declaration now. //$keywords = explode(' ', $spreadsheet->getProperties()->getKeywords()); //foreach ($keywords as $keyword) { // $objWriter->writeElement('meta:keyword', $keyword); //} // $objWriter->startElement('meta:user-defined'); $objWriter->writeAttribute('meta:name', 'Company'); $objWriter->writeRaw($spreadsheet->getProperties()->getCompany()); $objWriter->endElement(); $objWriter->startElement('meta:user-defined'); $objWriter->writeAttribute('meta:name', 'category'); $objWriter->writeRaw($spreadsheet->getProperties()->getCategory()); $objWriter->endElement(); self::writeDocPropsCustom($objWriter, $spreadsheet); $objWriter->endElement(); $objWriter->endElement(); return $objWriter->getData(); } private static function writeDocPropsCustom(XMLWriter $objWriter, Spreadsheet $spreadsheet): void { $customPropertyList = $spreadsheet->getProperties()->getCustomProperties(); foreach ($customPropertyList as $key => $customProperty) { $propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customProperty); $propertyType = $spreadsheet->getProperties()->getCustomPropertyType($customProperty); $objWriter->startElement('meta:user-defined'); $objWriter->writeAttribute('meta:name', $customProperty); switch ($propertyType) { case Properties::PROPERTY_TYPE_INTEGER: case Properties::PROPERTY_TYPE_FLOAT: $objWriter->writeAttribute('meta:value-type', 'float'); $objWriter->writeRawData($propertyValue); break; case Properties::PROPERTY_TYPE_BOOLEAN: $objWriter->writeAttribute('meta:value-type', 'boolean'); $objWriter->writeRawData($propertyValue ? 'true' : 'false'); break; case Properties::PROPERTY_TYPE_DATE: $objWriter->writeAttribute('meta:value-type', 'date'); $dtobj = Date::dateTimeFromTimestamp($propertyValue ?? 0); $objWriter->writeRawData($dtobj->format(DATE_W3C)); break; default: $objWriter->writeRawData($propertyValue); break; } $objWriter->endElement(); } } } PK[bb Formula.phpnu[definedNames[] = $definedName->getName(); } } public function convertFormula(string $formula, string $worksheetName = ''): string { $formula = $this->convertCellReferences($formula, $worksheetName); $formula = $this->convertDefinedNames($formula); if (substr($formula, 0, 1) !== '=') { $formula = '=' . $formula; } return 'of:' . $formula; } private function convertDefinedNames(string $formula): string { $splitCount = preg_match_all( '/' . Calculation::CALCULATION_REGEXP_DEFINEDNAME . '/mui', $formula, $splitRanges, PREG_OFFSET_CAPTURE ); $lengths = array_map('strlen', array_column($splitRanges[0], 0)); $offsets = array_column($splitRanges[0], 1); $values = array_column($splitRanges[0], 0); while ($splitCount > 0) { --$splitCount; $length = $lengths[$splitCount]; $offset = $offsets[$splitCount]; $value = $values[$splitCount]; if (in_array($value, $this->definedNames, true)) { $formula = substr($formula, 0, $offset) . '$$' . $value . substr($formula, $offset + $length); } } return $formula; } private function convertCellReferences(string $formula, string $worksheetName): string { $splitCount = preg_match_all( '/' . Calculation::CALCULATION_REGEXP_CELLREF_RELATIVE . '/mui', $formula, $splitRanges, PREG_OFFSET_CAPTURE ); $lengths = array_map('strlen', array_column($splitRanges[0], 0)); $offsets = array_column($splitRanges[0], 1); $worksheets = $splitRanges[2]; $columns = $splitRanges[6]; $rows = $splitRanges[7]; // Replace any commas in the formula with semi-colons for Ods // If by chance there are commas in worksheet names, then they will be "fixed" again in the loop // because we've already extracted worksheet names with our preg_match_all() $formula = str_replace(',', ';', $formula); while ($splitCount > 0) { --$splitCount; $length = $lengths[$splitCount]; $offset = $offsets[$splitCount]; $worksheet = $worksheets[$splitCount][0]; $column = $columns[$splitCount][0]; $row = $rows[$splitCount][0]; $newRange = ''; if (empty($worksheet)) { if (($offset === 0) || ($formula[$offset - 1] !== ':')) { // We need a worksheet $worksheet = $worksheetName; } } else { $worksheet = str_replace("''", "'", trim($worksheet, "'")); } if (!empty($worksheet)) { $newRange = "['" . str_replace("'", "''", $worksheet) . "'"; } elseif (substr($formula, $offset - 1, 1) !== ':') { $newRange = '['; } $newRange .= '.'; if (!empty($column)) { $newRange .= $column; } if (!empty($row)) { $newRange .= $row; } // close the wrapping [] unless this is the first part of a range $newRange .= substr($formula, $offset + $length, 1) !== ':' ? ']' : ''; $formula = substr($formula, 0, $offset) . $newRange . substr($formula, $offset + $length); } return $formula; } } PK[r`` Settings.phpnu[getParentWriter()->getUseDiskCaching()) { $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header $objWriter->startDocument('1.0', 'UTF-8'); // Settings $objWriter->startElement('office:document-settings'); $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); $objWriter->writeAttribute('xmlns:config', 'urn:oasis:names:tc:opendocument:xmlns:config:1.0'); $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); $objWriter->writeAttribute('office:version', '1.2'); $objWriter->startElement('office:settings'); $objWriter->startElement('config:config-item-set'); $objWriter->writeAttribute('config:name', 'ooo:view-settings'); $objWriter->startElement('config:config-item-map-indexed'); $objWriter->writeAttribute('config:name', 'Views'); $objWriter->startElement('config:config-item-map-entry'); $spreadsheet = $this->getParentWriter()->getSpreadsheet(); $objWriter->startElement('config:config-item'); $objWriter->writeAttribute('config:name', 'ViewId'); $objWriter->writeAttribute('config:type', 'string'); $objWriter->text('view1'); $objWriter->endElement(); // ViewId $objWriter->startElement('config:config-item-map-named'); $objWriter->writeAttribute('config:name', 'Tables'); foreach ($spreadsheet->getWorksheetIterator() as $ws) { $objWriter->startElement('config:config-item-map-entry'); $objWriter->writeAttribute('config:name', $ws->getTitle()); $selected = $ws->getSelectedCells(); if (preg_match('/^([a-z]+)([0-9]+)/i', $selected, $matches) === 1) { $colSel = Coordinate::columnIndexFromString($matches[1]) - 1; $rowSel = (int) $matches[2] - 1; $objWriter->startElement('config:config-item'); $objWriter->writeAttribute('config:name', 'CursorPositionX'); $objWriter->writeAttribute('config:type', 'int'); $objWriter->text($colSel); $objWriter->endElement(); $objWriter->startElement('config:config-item'); $objWriter->writeAttribute('config:name', 'CursorPositionY'); $objWriter->writeAttribute('config:type', 'int'); $objWriter->text($rowSel); $objWriter->endElement(); } $objWriter->endElement(); // config:config-item-map-entry } $objWriter->endElement(); // config:config-item-map-named $wstitle = $spreadsheet->getActiveSheet()->getTitle(); $objWriter->startElement('config:config-item'); $objWriter->writeAttribute('config:name', 'ActiveTable'); $objWriter->writeAttribute('config:type', 'string'); $objWriter->text($wstitle); $objWriter->endElement(); // config:config-item ActiveTable $objWriter->endElement(); // config:config-item-map-entry $objWriter->endElement(); // config:config-item-map-indexed Views $objWriter->endElement(); // config:config-item-set ooo:view-settings $objWriter->startElement('config:config-item-set'); $objWriter->writeAttribute('config:name', 'ooo:configuration-settings'); $objWriter->endElement(); // config:config-item-set ooo:configuration-settings $objWriter->endElement(); // office:settings $objWriter->endElement(); // office:document-settings return $objWriter->getData(); } } PK[x11WriterPart.phpnu[parentWriter; } /** * Set parent Ods writer. */ public function __construct(Ods $writer) { $this->parentWriter = $writer; } abstract public function write(): string; } PK[Fv:kk Styles.phpnu[getParentWriter()->getUseDiskCaching()) { $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header $objWriter->startDocument('1.0', 'UTF-8'); // Content $objWriter->startElement('office:document-styles'); $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); $objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0'); $objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0'); $objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0'); $objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'); $objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'); $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); $objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0'); $objWriter->writeAttribute('xmlns:presentation', 'urn:oasis:names:tc:opendocument:xmlns:presentation:1.0'); $objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'); $objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0'); $objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0'); $objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML'); $objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0'); $objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0'); $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); $objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer'); $objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc'); $objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events'); $objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report'); $objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2'); $objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); $objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table'); $objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/'); $objWriter->writeAttribute('office:version', '1.2'); $objWriter->writeElement('office:font-face-decls'); $objWriter->writeElement('office:styles'); $objWriter->writeElement('office:automatic-styles'); $objWriter->writeElement('office:master-styles'); $objWriter->endElement(); return $objWriter->getData(); } } PK[S MetaInf.phpnu[getParentWriter()->getUseDiskCaching()) { $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header $objWriter->startDocument('1.0', 'UTF-8'); // Manifest $objWriter->startElement('manifest:manifest'); $objWriter->writeAttribute('xmlns:manifest', 'urn:oasis:names:tc:opendocument:xmlns:manifest:1.0'); $objWriter->writeAttribute('manifest:version', '1.2'); $objWriter->startElement('manifest:file-entry'); $objWriter->writeAttribute('manifest:full-path', '/'); $objWriter->writeAttribute('manifest:version', '1.2'); $objWriter->writeAttribute('manifest:media-type', 'application/vnd.oasis.opendocument.spreadsheet'); $objWriter->endElement(); $objWriter->startElement('manifest:file-entry'); $objWriter->writeAttribute('manifest:full-path', 'meta.xml'); $objWriter->writeAttribute('manifest:media-type', 'text/xml'); $objWriter->endElement(); $objWriter->startElement('manifest:file-entry'); $objWriter->writeAttribute('manifest:full-path', 'settings.xml'); $objWriter->writeAttribute('manifest:media-type', 'text/xml'); $objWriter->endElement(); $objWriter->startElement('manifest:file-entry'); $objWriter->writeAttribute('manifest:full-path', 'content.xml'); $objWriter->writeAttribute('manifest:media-type', 'text/xml'); $objWriter->endElement(); $objWriter->startElement('manifest:file-entry'); $objWriter->writeAttribute('manifest:full-path', 'Thumbnails/thumbnail.png'); $objWriter->writeAttribute('manifest:media-type', 'image/png'); $objWriter->endElement(); $objWriter->startElement('manifest:file-entry'); $objWriter->writeAttribute('manifest:full-path', 'styles.xml'); $objWriter->writeAttribute('manifest:media-type', 'text/xml'); $objWriter->endElement(); $objWriter->endElement(); return $objWriter->getData(); } } PK[r'PageSettings.phpnu[setDomNameSpaces($styleDom); $this->readPageSettingStyles($styleDom); $this->readStyleMasterLookup($styleDom); } private function setDomNameSpaces(DOMDocument $styleDom): void { $this->officeNs = $styleDom->lookupNamespaceUri('office'); $this->stylesNs = $styleDom->lookupNamespaceUri('style'); $this->stylesFo = $styleDom->lookupNamespaceUri('fo'); } private function readPageSettingStyles(DOMDocument $styleDom): void { $styles = $styleDom->getElementsByTagNameNS($this->officeNs, 'automatic-styles') ->item(0) ->getElementsByTagNameNS($this->stylesNs, 'page-layout'); foreach ($styles as $styleSet) { $styleName = $styleSet->getAttributeNS($this->stylesNs, 'name'); $pageLayoutProperties = $styleSet->getElementsByTagNameNS($this->stylesNs, 'page-layout-properties')[0]; $styleOrientation = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'print-orientation'); $styleScale = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'scale-to'); $stylePrintOrder = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'print-page-order'); $centered = $pageLayoutProperties->getAttributeNS($this->stylesNs, 'table-centering'); $marginLeft = $pageLayoutProperties->getAttributeNS($this->stylesFo, 'margin-left'); $marginRight = $pageLayoutProperties->getAttributeNS($this->stylesFo, 'margin-right'); $marginTop = $pageLayoutProperties->getAttributeNS($this->stylesFo, 'margin-top'); $marginBottom = $pageLayoutProperties->getAttributeNS($this->stylesFo, 'margin-bottom'); $header = $styleSet->getElementsByTagNameNS($this->stylesNs, 'header-style')[0]; $headerProperties = $header->getElementsByTagNameNS($this->stylesNs, 'header-footer-properties')[0]; $marginHeader = isset($headerProperties) ? $headerProperties->getAttributeNS($this->stylesFo, 'min-height') : null; $footer = $styleSet->getElementsByTagNameNS($this->stylesNs, 'footer-style')[0]; $footerProperties = $footer->getElementsByTagNameNS($this->stylesNs, 'header-footer-properties')[0]; $marginFooter = isset($footerProperties) ? $footerProperties->getAttributeNS($this->stylesFo, 'min-height') : null; $this->pageLayoutStyles[$styleName] = (object) [ 'orientation' => $styleOrientation ?: PageSetup::ORIENTATION_DEFAULT, 'scale' => $styleScale ?: 100, 'printOrder' => $stylePrintOrder, 'horizontalCentered' => $centered === 'horizontal' || $centered === 'both', 'verticalCentered' => $centered === 'vertical' || $centered === 'both', // margin size is already stored in inches, so no UOM conversion is required 'marginLeft' => (float) $marginLeft ?? 0.7, 'marginRight' => (float) $marginRight ?? 0.7, 'marginTop' => (float) $marginTop ?? 0.3, 'marginBottom' => (float) $marginBottom ?? 0.3, 'marginHeader' => (float) $marginHeader ?? 0.45, 'marginFooter' => (float) $marginFooter ?? 0.45, ]; } } private function readStyleMasterLookup(DOMDocument $styleDom): void { $styleMasterLookup = $styleDom->getElementsByTagNameNS($this->officeNs, 'master-styles') ->item(0) ->getElementsByTagNameNS($this->stylesNs, 'master-page'); foreach ($styleMasterLookup as $styleMasterSet) { $styleMasterName = $styleMasterSet->getAttributeNS($this->stylesNs, 'name'); $pageLayoutName = $styleMasterSet->getAttributeNS($this->stylesNs, 'page-layout-name'); $this->masterPrintStylesCrossReference[$styleMasterName] = $pageLayoutName; } } public function readStyleCrossReferences(DOMDocument $contentDom): void { $styleXReferences = $contentDom->getElementsByTagNameNS($this->officeNs, 'automatic-styles') ->item(0) ->getElementsByTagNameNS($this->stylesNs, 'style'); foreach ($styleXReferences as $styleXreferenceSet) { $styleXRefName = $styleXreferenceSet->getAttributeNS($this->stylesNs, 'name'); $stylePageLayoutName = $styleXreferenceSet->getAttributeNS($this->stylesNs, 'master-page-name'); if (!empty($stylePageLayoutName)) { $this->masterStylesCrossReference[$styleXRefName] = $stylePageLayoutName; } } } public function setPrintSettingsForWorksheet(Worksheet $worksheet, string $styleName): void { if (!array_key_exists($styleName, $this->masterStylesCrossReference)) { return; } $masterStyleName = $this->masterStylesCrossReference[$styleName]; if (!array_key_exists($masterStyleName, $this->masterPrintStylesCrossReference)) { return; } $printSettingsIndex = $this->masterPrintStylesCrossReference[$masterStyleName]; if (!array_key_exists($printSettingsIndex, $this->pageLayoutStyles)) { return; } $printSettings = $this->pageLayoutStyles[$printSettingsIndex]; $worksheet->getPageSetup() ->setOrientation($printSettings->orientation ?? PageSetup::ORIENTATION_DEFAULT) ->setPageOrder($printSettings->printOrder === 'ltr' ? PageSetup::PAGEORDER_OVER_THEN_DOWN : PageSetup::PAGEORDER_DOWN_THEN_OVER) ->setScale((int) trim($printSettings->scale, '%')) ->setHorizontalCentered($printSettings->horizontalCentered) ->setVerticalCentered($printSettings->verticalCentered); $worksheet->getPageMargins() ->setLeft($printSettings->marginLeft) ->setRight($printSettings->marginRight) ->setTop($printSettings->marginTop) ->setBottom($printSettings->marginBottom) ->setHeader($printSettings->marginHeader) ->setFooter($printSettings->marginFooter); } } PK[00AutoFilter.phpnu[readAutoFilters($workbookData); } protected function readAutoFilters(DOMElement $workbookData): void { $databases = $workbookData->getElementsByTagNameNS($this->tableNs, 'database-ranges'); foreach ($databases as $autofilters) { foreach ($autofilters->childNodes as $autofilter) { $autofilterRange = $this->getAttributeValue($autofilter, 'target-range-address'); if ($autofilterRange !== null) { $baseAddress = $this->convertToExcelAddressValue($autofilterRange); $this->spreadsheet->getActiveSheet()->setAutoFilter($baseAddress); } } } } protected function getAttributeValue(?DOMNode $node, string $attributeName): ?string { if ($node !== null && $node->attributes !== null) { $attribute = $node->attributes->getNamedItemNS( $this->tableNs, $attributeName ); if ($attribute !== null) { return $attribute->nodeValue; } } return null; } } PK[GvProperties.phpnu[spreadsheet = $spreadsheet; } public function load(SimpleXMLElement $xml, $namespacesMeta): void { $docProps = $this->spreadsheet->getProperties(); $officeProperty = $xml->children($namespacesMeta['office']); foreach ($officeProperty as $officePropertyData) { // @var \SimpleXMLElement $officePropertyData if (isset($namespacesMeta['dc'])) { $officePropertiesDC = $officePropertyData->children($namespacesMeta['dc']); $this->setCoreProperties($docProps, $officePropertiesDC); } $officePropertyMeta = []; if (isset($namespacesMeta['dc'])) { $officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']); } foreach ($officePropertyMeta as $propertyName => $propertyValue) { $this->setMetaProperties($namespacesMeta, $propertyValue, $propertyName, $docProps); } } } private function setCoreProperties(DocumentProperties $docProps, SimpleXMLElement $officePropertyDC): void { foreach ($officePropertyDC as $propertyName => $propertyValue) { $propertyValue = (string) $propertyValue; switch ($propertyName) { case 'title': $docProps->setTitle($propertyValue); break; case 'subject': $docProps->setSubject($propertyValue); break; case 'creator': $docProps->setCreator($propertyValue); $docProps->setLastModifiedBy($propertyValue); break; case 'date': $docProps->setModified($propertyValue); break; case 'description': $docProps->setDescription($propertyValue); break; } } } private function setMetaProperties( $namespacesMeta, SimpleXMLElement $propertyValue, $propertyName, DocumentProperties $docProps ): void { $propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']); $propertyValue = (string) $propertyValue; switch ($propertyName) { case 'initial-creator': $docProps->setCreator($propertyValue); break; case 'keyword': $docProps->setKeywords($propertyValue); break; case 'creation-date': $docProps->setCreated($propertyValue); break; case 'user-defined': $this->setUserDefinedProperty($propertyValueAttributes, $propertyValue, $docProps); break; } } private function setUserDefinedProperty($propertyValueAttributes, $propertyValue, DocumentProperties $docProps): void { $propertyValueName = ''; $propertyValueType = DocumentProperties::PROPERTY_TYPE_STRING; foreach ($propertyValueAttributes as $key => $value) { if ($key == 'name') { $propertyValueName = (string) $value; } elseif ($key == 'value-type') { switch ($value) { case 'date': $propertyValue = DocumentProperties::convertProperty($propertyValue, 'date'); $propertyValueType = DocumentProperties::PROPERTY_TYPE_DATE; break; case 'boolean': $propertyValue = DocumentProperties::convertProperty($propertyValue, 'bool'); $propertyValueType = DocumentProperties::PROPERTY_TYPE_BOOLEAN; break; case 'float': $propertyValue = DocumentProperties::convertProperty($propertyValue, 'r4'); $propertyValueType = DocumentProperties::PROPERTY_TYPE_FLOAT; break; default: $propertyValueType = DocumentProperties::PROPERTY_TYPE_STRING; } } } $docProps->setCustomProperty($propertyValueName, $propertyValue, $propertyValueType); } } PK[y DefinedNames.phpnu[readDefinedRanges($workbookData); $this->readDefinedExpressions($workbookData); } /** * Read any Named Ranges that are defined in this spreadsheet. */ protected function readDefinedRanges(DOMElement $workbookData): void { $namedRanges = $workbookData->getElementsByTagNameNS($this->tableNs, 'named-range'); foreach ($namedRanges as $definedNameElement) { $definedName = $definedNameElement->getAttributeNS($this->tableNs, 'name'); $baseAddress = $definedNameElement->getAttributeNS($this->tableNs, 'base-cell-address'); $range = $definedNameElement->getAttributeNS($this->tableNs, 'cell-range-address'); $baseAddress = $this->convertToExcelAddressValue($baseAddress); $range = $this->convertToExcelAddressValue($range); $this->addDefinedName($baseAddress, $definedName, $range); } } /** * Read any Named Formulae that are defined in this spreadsheet. */ protected function readDefinedExpressions(DOMElement $workbookData): void { $namedExpressions = $workbookData->getElementsByTagNameNS($this->tableNs, 'named-expression'); foreach ($namedExpressions as $definedNameElement) { $definedName = $definedNameElement->getAttributeNS($this->tableNs, 'name'); $baseAddress = $definedNameElement->getAttributeNS($this->tableNs, 'base-cell-address'); $expression = $definedNameElement->getAttributeNS($this->tableNs, 'expression'); $baseAddress = $this->convertToExcelAddressValue($baseAddress); $expression = substr($expression, strpos($expression, ':=') + 1); $expression = $this->convertToExcelFormulaValue($expression); $this->addDefinedName($baseAddress, $definedName, $expression); } } /** * Assess scope and store the Defined Name. */ private function addDefinedName(string $baseAddress, string $definedName, string $value): void { [$sheetReference] = Worksheet::extractSheetTitle($baseAddress, true); $worksheet = $this->spreadsheet->getSheetByName($sheetReference); // Worksheet might still be null if we're only loading selected sheets rather than the full spreadsheet if ($worksheet !== null) { $this->spreadsheet->addDefinedName(DefinedName::createInstance((string) $definedName, $worksheet, $value)); } } } PK[V V BaseReader.phpnu[spreadsheet = $spreadsheet; $this->tableNs = $tableNs; } abstract public function read(DOMElement $workbookData): void; protected function convertToExcelAddressValue(string $openOfficeAddress): string { $excelAddress = $openOfficeAddress; // Cell range 3-d reference // As we don't support 3-d ranges, we're just going to take a quick and dirty approach // and assume that the second worksheet reference is the same as the first $excelAddress = preg_replace('/\$?([^\.]+)\.([^\.]+):\$?([^\.]+)\.([^\.]+)/miu', '$1!$2:$4', $excelAddress); // Cell range reference in another sheet $excelAddress = preg_replace('/\$?([^\.]+)\.([^\.]+):\.([^\.]+)/miu', '$1!$2:$3', $excelAddress ?? ''); // Cell reference in another sheet $excelAddress = preg_replace('/\$?([^\.]+)\.([^\.]+)/miu', '$1!$2', $excelAddress ?? ''); // Cell range reference $excelAddress = preg_replace('/\.([^\.]+):\.([^\.]+)/miu', '$1:$2', $excelAddress ?? ''); // Simple cell reference $excelAddress = preg_replace('/\.([^\.]+)/miu', '$1', $excelAddress ?? ''); return $excelAddress ?? ''; } protected function convertToExcelFormulaValue(string $openOfficeFormula): string { $temp = explode('"', $openOfficeFormula); $tKey = false; foreach ($temp as &$value) { // @var string $value // Only replace in alternate array entries (i.e. non-quoted blocks) if ($tKey = !$tKey) { // Cell range reference in another sheet $value = preg_replace('/\[\$?([^\.]+)\.([^\.]+):\.([^\.]+)\]/miu', '$1!$2:$3', $value); // Cell reference in another sheet $value = preg_replace('/\[\$?([^\.]+)\.([^\.]+)\]/miu', '$1!$2', $value ?? ''); // Cell range reference $value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/miu', '$1:$2', $value ?? ''); // Simple cell reference $value = preg_replace('/\[\.([^\.]+)\]/miu', '$1', $value ?? ''); // Convert references to defined names/formulae $value = str_replace('$$', '', $value ?? ''); $value = Calculation::translateSeparator(';', ',', $value, $inBraces); } } // Then rebuild the formula string $excelFormula = implode('"', $temp); return $excelFormula; } } PK[4Thumbnails.phpnu[PK[MCell/Comment.phpnu[PK[bCell/Style.phpnu[PK[CPL,4,4 xContent.phpnu[PK[+]PAutoFilters.phpnu[PK[+hp22 XMimetype.phpnu[PK[w SS,ZNamedExpressions.phpnu[PK[::7lMeta.phpnu[PK[bb Formula.phpnu[PK[r`` Settings.phpnu[PK[x11.WriterPart.phpnu[PK[Fv:kk Styles.phpnu[PK[S BMetaInf.phpnu[PK[r'BPageSettings.phpnu[PK[00PAutoFilter.phpnu[PK[GvProperties.phpnu[PK[y DefinedNames.phpnu[PK[V V  BaseReader.phpnu[PKr