Merge branch 'master' into add-editorconfig

This commit is contained in:
Mark Baker 2022-10-15 21:14:16 +02:00 committed by GitHub
commit b7385e2053
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 132 additions and 89 deletions

View File

@ -18,23 +18,39 @@ class Namespaces
const THEME = 'http://schemas.openxmlformats.org/package/2006/relationships/theme';
const THEME2 = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme';
const COMPATIBILITY = 'http://schemas.openxmlformats.org/markup-compatibility/2006';
const MAIN = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main';
const RELATIONSHIPS_DRAWING = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing';
const DRAWINGML = 'http://schemas.openxmlformats.org/drawingml/2006/main';
const CHART = 'http://schemas.openxmlformats.org/drawingml/2006/chart';
const CHART_ALTERNATE = 'http://schemas.microsoft.com/office/drawing/2007/8/2/chart';
const RELATIONSHIPS_CHART = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart';
const SPREADSHEET_DRAWING = 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing';
const SCHEMA_OFFICE_DOCUMENT = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships';
const COMMENTS = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments';
//const CUSTOM_PROPERTIES = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties';
const RELATIONSHIPS_CUSTOM_PROPERTIES = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties';
//const EXTENDED_PROPERTIES = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties';
const RELATIONSHIPS_EXTENDED_PROPERTIES = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties';
const RELATIONSHIPS_CTRLPROP = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp';
const CUSTOM_PROPERTIES = 'http://schemas.openxmlformats.org/officeDocument/2006/custom-properties';
const EXTENDED_PROPERTIES = 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties';
const PROPERTIES_VTYPES = 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes';
const HYPERLINK = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink';
@ -58,13 +74,29 @@ class Namespaces
const VBA = 'http://schemas.microsoft.com/office/2006/relationships/vbaProject';
const VBA_SIGNATURE = 'http://schemas.microsoft.com/office/2006/relationships/vbaProject';
const DATA_VALIDATIONS1 = 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/main';
const DATA_VALIDATIONS2 = 'http://schemas.microsoft.com/office/excel/2006/main';
const CONTENT_TYPES = 'http://schemas.openxmlformats.org/package/2006/content-types';
const RELATIONSHIPS_PRINTER_SETTINGS = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings';
const RELATIONSHIPS_TABLE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/table';
const SPREADSHEETML_AC = 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac';
const DC_ELEMENTS = 'http://purl.org/dc/elements/1.1/';
const DC_TERMS = 'http://purl.org/dc/terms';
const DC_TERMS = 'http://purl.org/dc/terms/';
const DC_DCMITYPE = 'http://purl.org/dc/dcmitype/';
const SCHEMA_INSTANCE = 'http://www.w3.org/2001/XMLSchema-instance';
const URN_EXCEL = 'urn:schemas-microsoft-com:office:excel';
const URN_MSOFFICE = 'urn:schemas-microsoft-com:office:office';

View File

@ -12,6 +12,7 @@ use PhpOffice\PhpSpreadsheet\Chart\PlotArea;
use PhpOffice\PhpSpreadsheet\Chart\Properties;
use PhpOffice\PhpSpreadsheet\Chart\Title;
use PhpOffice\PhpSpreadsheet\Chart\TrendLine;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces;
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
use PhpOffice\PhpSpreadsheet\Writer\Exception as WriterException;
@ -48,9 +49,9 @@ class Chart extends WriterPart
// c:chartSpace
$objWriter->startElement('c:chartSpace');
$objWriter->writeAttribute('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart');
$objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
$objWriter->writeAttribute('xmlns:c', Namespaces::CHART);
$objWriter->writeAttribute('xmlns:a', Namespaces::DRAWINGML);
$objWriter->writeAttribute('xmlns:r', Namespaces::SCHEMA_OFFICE_DOCUMENT);
$objWriter->startElement('c:date1904');
$objWriter->writeAttribute('val', '0');
@ -1553,11 +1554,11 @@ class Chart extends WriterPart
private function writeAlternateContent(XMLWriter $objWriter): void
{
$objWriter->startElement('mc:AlternateContent');
$objWriter->writeAttribute('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
$objWriter->writeAttribute('xmlns:mc', Namespaces::COMPATIBILITY);
$objWriter->startElement('mc:Choice');
$objWriter->writeAttribute('Requires', 'c14');
$objWriter->writeAttribute('xmlns:c14', 'http://schemas.microsoft.com/office/drawing/2007/8/2/chart');
$objWriter->writeAttribute('xmlns:c14', Namespaces::CHART_ALTERNATE);
$objWriter->startElement('c14:style');
$objWriter->writeAttribute('val', '102');

View File

@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Comment;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces;
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
class Comments extends WriterPart
@ -40,7 +41,7 @@ class Comments extends WriterPart
// comments
$objWriter->startElement('comments');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
$objWriter->writeAttribute('xmlns', Namespaces::MAIN);
// Loop through authors
$objWriter->startElement('authors');
@ -107,9 +108,9 @@ class Comments extends WriterPart
// xml
$objWriter->startElement('xml');
$objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
$objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
$objWriter->writeAttribute('xmlns:x', 'urn:schemas-microsoft-com:office:excel');
$objWriter->writeAttribute('xmlns:v', Namespaces::URN_VML);
$objWriter->writeAttribute('xmlns:o', Namespaces::URN_MSOFFICE);
$objWriter->writeAttribute('xmlns:x', Namespaces::URN_EXCEL);
// o:shapelayout
$objWriter->startElement('o:shapelayout');

View File

@ -2,6 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces;
use PhpOffice\PhpSpreadsheet\Shared\File;
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
@ -32,7 +33,7 @@ class ContentTypes extends WriterPart
// Types
$objWriter->startElement('Types');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');
$objWriter->writeAttribute('xmlns', Namespaces::CONTENT_TYPES);
// Theme
$this->writeOverrideContentType($objWriter, '/xl/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml');

View File

@ -8,7 +8,7 @@ use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\DefinedName;
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet as ActualWorksheet;
class DefinedNames
{
@ -98,7 +98,7 @@ class DefinedNames
/**
* Write Defined Name for autoFilter.
*/
private function writeNamedRangeForAutofilter(Worksheet $worksheet, int $worksheetId = 0): void
private function writeNamedRangeForAutofilter(ActualWorksheet $worksheet, int $worksheetId = 0): void
{
// NamedRange for autoFilter
$autoFilterRange = $worksheet->getAutoFilter()->getRange();
@ -112,7 +112,7 @@ class DefinedNames
$range = Coordinate::splitRange($autoFilterRange);
$range = $range[0];
// Strip any worksheet ref so we can make the cell ref absolute
[, $range[0]] = Worksheet::extractSheetTitle($range[0], true);
[, $range[0]] = ActualWorksheet::extractSheetTitle($range[0], true);
$range[0] = Coordinate::absoluteCoordinate($range[0]);
if (count($range) > 1) {
@ -129,7 +129,7 @@ class DefinedNames
/**
* Write Defined Name for PrintTitles.
*/
private function writeNamedRangeForPrintTitles(Worksheet $worksheet, int $worksheetId = 0): void
private function writeNamedRangeForPrintTitles(ActualWorksheet $worksheet, int $worksheetId = 0): void
{
// NamedRange for PrintTitles
if ($worksheet->getPageSetup()->isColumnsToRepeatAtLeftSet() || $worksheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
@ -167,7 +167,7 @@ class DefinedNames
/**
* Write Defined Name for PrintTitles.
*/
private function writeNamedRangeForPrintArea(Worksheet $worksheet, int $worksheetId = 0): void
private function writeNamedRangeForPrintArea(ActualWorksheet $worksheet, int $worksheetId = 0): void
{
// NamedRange for PrintArea
if ($worksheet->getPageSetup()->isPrintAreaSet()) {

View File

@ -3,6 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Document\Properties;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
@ -29,8 +30,8 @@ class DocProps extends WriterPart
// Properties
$objWriter->startElement('Properties');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties');
$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
$objWriter->writeAttribute('xmlns', Namespaces::EXTENDED_PROPERTIES);
$objWriter->writeAttribute('xmlns:vt', Namespaces::PROPERTIES_VTYPES);
// Application
$objWriter->writeElement('Application', 'Microsoft Excel');
@ -124,11 +125,11 @@ class DocProps extends WriterPart
// cp:coreProperties
$objWriter->startElement('cp:coreProperties');
$objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
$objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
$objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
$objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$objWriter->writeAttribute('xmlns:cp', Namespaces::CORE_PROPERTIES2);
$objWriter->writeAttribute('xmlns:dc', Namespaces::DC_ELEMENTS);
$objWriter->writeAttribute('xmlns:dcterms', Namespaces::DC_TERMS);
$objWriter->writeAttribute('xmlns:dcmitype', Namespaces::DC_DCMITYPE);
$objWriter->writeAttribute('xmlns:xsi', Namespaces::SCHEMA_INSTANCE);
// dc:creator
$objWriter->writeElement('dc:creator', $spreadsheet->getProperties()->getCreator());
@ -198,8 +199,8 @@ class DocProps extends WriterPart
// cp:coreProperties
$objWriter->startElement('Properties');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/custom-properties');
$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
$objWriter->writeAttribute('xmlns', Namespaces::CUSTOM_PROPERTIES);
$objWriter->writeAttribute('xmlns:vt', Namespaces::PROPERTIES_VTYPES);
foreach ($customPropertyList as $key => $customProperty) {
$propertyValue = $spreadsheet->getProperties()->getCustomPropertyValue($customProperty);

View File

@ -3,6 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces;
use PhpOffice\PhpSpreadsheet\Shared\Drawing as SharedDrawing;
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
@ -34,8 +35,8 @@ class Drawing extends WriterPart
// xdr:wsDr
$objWriter->startElement('xdr:wsDr');
$objWriter->writeAttribute('xmlns:xdr', 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing');
$objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
$objWriter->writeAttribute('xmlns:xdr', Namespaces::SPREADSHEET_DRAWING);
$objWriter->writeAttribute('xmlns:a', Namespaces::DRAWINGML);
// Loop through images and write drawings
$i = 1;
@ -159,10 +160,10 @@ class Drawing extends WriterPart
$objWriter->startElement('a:graphic');
$objWriter->startElement('a:graphicData');
$objWriter->writeAttribute('uri', 'http://schemas.openxmlformats.org/drawingml/2006/chart');
$objWriter->writeAttribute('uri', Namespaces::CHART);
$objWriter->startElement('c:chart');
$objWriter->writeAttribute('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart');
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
$objWriter->writeAttribute('xmlns:c', Namespaces::CHART);
$objWriter->writeAttribute('xmlns:r', Namespaces::SCHEMA_OFFICE_DOCUMENT);
$objWriter->writeAttribute('r:id', 'rId' . $relationId);
$objWriter->endElement();
$objWriter->endElement();
@ -265,7 +266,7 @@ class Drawing extends WriterPart
// a:blip
$objWriter->startElement('a:blip');
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
$objWriter->writeAttribute('xmlns:r', Namespaces::SCHEMA_OFFICE_DOCUMENT);
$objWriter->writeAttribute('r:embed', 'rId' . $relationId);
$objWriter->endElement();
@ -362,9 +363,9 @@ class Drawing extends WriterPart
// xml
$objWriter->startElement('xml');
$objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
$objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
$objWriter->writeAttribute('xmlns:x', 'urn:schemas-microsoft-com:office:excel');
$objWriter->writeAttribute('xmlns:v', Namespaces::URN_VML);
$objWriter->writeAttribute('xmlns:o', Namespaces::URN_MSOFFICE);
$objWriter->writeAttribute('xmlns:x', Namespaces::URN_EXCEL);
// o:shapelayout
$objWriter->startElement('o:shapelayout');
@ -558,7 +559,7 @@ class Drawing extends WriterPart
}
$objWriter->startElement('a:hlinkClick');
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
$objWriter->writeAttribute('xmlns:r', Namespaces::SCHEMA_OFFICE_DOCUMENT);
$objWriter->writeAttribute('r:id', 'rId' . $hlinkClickId);
$objWriter->endElement();
}

View File

@ -2,6 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces;
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing;
@ -30,7 +31,7 @@ class Rels extends WriterPart
// Relationships
$objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
$objWriter->writeAttribute('xmlns', Namespaces::RELATIONSHIPS);
$customPropertyList = $spreadsheet->getProperties()->getCustomProperties();
if (!empty($customPropertyList)) {
@ -38,7 +39,7 @@ class Rels extends WriterPart
$this->writeRelationship(
$objWriter,
4,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties',
Namespaces::RELATIONSHIPS_CUSTOM_PROPERTIES,
'docProps/custom.xml'
);
}
@ -47,7 +48,7 @@ class Rels extends WriterPart
$this->writeRelationship(
$objWriter,
3,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',
Namespaces::RELATIONSHIPS_EXTENDED_PROPERTIES,
'docProps/app.xml'
);
@ -55,7 +56,7 @@ class Rels extends WriterPart
$this->writeRelationship(
$objWriter,
2,
'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
Namespaces::CORE_PROPERTIES,
'docProps/core.xml'
);
@ -63,7 +64,7 @@ class Rels extends WriterPart
$this->writeRelationship(
$objWriter,
1,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
Namespaces::OFFICE_DOCUMENT,
'xl/workbook.xml'
);
// a custom UI in workbook ?
@ -72,7 +73,7 @@ class Rels extends WriterPart
$this->writeRelationShip(
$objWriter,
5,
'http://schemas.microsoft.com/office/2006/relationships/ui/extensibility',
Namespaces::EXTENSIBILITY,
is_string($target) ? $target : ''
);
}
@ -102,13 +103,13 @@ class Rels extends WriterPart
// Relationships
$objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
$objWriter->writeAttribute('xmlns', Namespaces::RELATIONSHIPS);
// Relationship styles.xml
$this->writeRelationship(
$objWriter,
1,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles',
Namespaces::STYLES,
'styles.xml'
);
@ -116,7 +117,7 @@ class Rels extends WriterPart
$this->writeRelationship(
$objWriter,
2,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
Namespaces::THEME2,
'theme/theme1.xml'
);
@ -124,7 +125,7 @@ class Rels extends WriterPart
$this->writeRelationship(
$objWriter,
3,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings',
Namespaces::SHARED_STRINGS,
'sharedStrings.xml'
);
@ -134,7 +135,7 @@ class Rels extends WriterPart
$this->writeRelationship(
$objWriter,
($i + 1 + 3),
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet',
Namespaces::WORKSHEET,
'worksheets/sheet' . ($i + 1) . '.xml'
);
}
@ -144,7 +145,7 @@ class Rels extends WriterPart
$this->writeRelationShip(
$objWriter,
($i + 1 + 3),
'http://schemas.microsoft.com/office/2006/relationships/vbaProject',
Namespaces::VBA,
'vbaProject.bin'
);
++$i; //increment i if needed for an another relation
@ -183,7 +184,7 @@ class Rels extends WriterPart
// Relationships
$objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
$objWriter->writeAttribute('xmlns', Namespaces::RELATIONSHIPS);
// Write drawing relationships?
$drawingOriginalIds = [];
@ -215,7 +216,7 @@ class Rels extends WriterPart
$this->writeRelationship(
$objWriter,
$rId,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing',
Namespaces::RELATIONSHIPS_DRAWING,
$relPath
);
}
@ -227,7 +228,7 @@ class Rels extends WriterPart
$this->writeRelationship(
$objWriter,
'_hyperlink_' . $i,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink',
Namespaces::HYPERLINK,
$hyperlink->getUrl(),
'External'
);
@ -242,14 +243,14 @@ class Rels extends WriterPart
$this->writeRelationship(
$objWriter,
'_comments_vml' . $i,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing',
Namespaces::VML,
'../drawings/vmlDrawing' . $worksheetId . '.vml'
);
$this->writeRelationship(
$objWriter,
'_comments' . $i,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments',
Namespaces::COMMENTS,
'../comments' . $worksheetId . '.xml'
);
}
@ -260,7 +261,7 @@ class Rels extends WriterPart
$this->writeRelationship(
$objWriter,
'_table_' . $i,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/table',
Namespaces::RELATIONSHIPS_TABLE,
'../tables/table' . $tableRef++ . '.xml'
);
}
@ -271,14 +272,14 @@ class Rels extends WriterPart
$this->writeRelationship(
$objWriter,
'_headerfooter_vml' . $i,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing',
Namespaces::VML,
'../drawings/vmlDrawingHF' . $worksheetId . '.vml'
);
}
$this->writeUnparsedRelationship($worksheet, $objWriter, 'ctrlProps', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp');
$this->writeUnparsedRelationship($worksheet, $objWriter, 'vmlDrawings', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing');
$this->writeUnparsedRelationship($worksheet, $objWriter, 'printerSettings', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings');
$this->writeUnparsedRelationship($worksheet, $objWriter, 'ctrlProps', Namespaces::RELATIONSHIPS_CTRLPROP);
$this->writeUnparsedRelationship($worksheet, $objWriter, 'vmlDrawings', Namespaces::VML);
$this->writeUnparsedRelationship($worksheet, $objWriter, 'printerSettings', Namespaces::RELATIONSHIPS_PRINTER_SETTINGS);
$objWriter->endElement();
@ -325,7 +326,7 @@ class Rels extends WriterPart
// Relationships
$objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
$objWriter->writeAttribute('xmlns', Namespaces::RELATIONSHIPS);
// Loop through images and write relationships
$i = 1;
@ -340,7 +341,7 @@ class Rels extends WriterPart
$this->writeRelationship(
$objWriter,
$i,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
Namespaces::IMAGE,
'../media/' . $drawing->getIndexedFilename()
);
@ -359,7 +360,7 @@ class Rels extends WriterPart
$this->writeRelationship(
$objWriter,
$i++,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart',
Namespaces::RELATIONSHIPS_CHART,
'../charts/chart' . ++$chartRef . '.xml'
);
}
@ -391,7 +392,7 @@ class Rels extends WriterPart
// Relationships
$objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
$objWriter->writeAttribute('xmlns', Namespaces::RELATIONSHIPS);
// Loop through images and write relationships
foreach ($worksheet->getHeaderFooter()->getImages() as $key => $value) {
@ -399,7 +400,7 @@ class Rels extends WriterPart
$this->writeRelationship(
$objWriter,
$key,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
Namespaces::IMAGE,
'../media/' . $value->getIndexedFilename()
);
}
@ -424,7 +425,7 @@ class Rels extends WriterPart
// Relationships
$objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
$objWriter->writeAttribute('xmlns', Namespaces::RELATIONSHIPS);
// Loop through images and write relationships
foreach ($worksheet->getComments() as $comment) {
@ -436,7 +437,7 @@ class Rels extends WriterPart
$this->writeRelationship(
$objWriter,
$bgImage->getImageIndex(),
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
Namespaces::IMAGE,
'../media/' . $bgImage->getMediaFilename()
);
}
@ -483,7 +484,7 @@ class Rels extends WriterPart
$this->writeRelationship(
$objWriter,
$i,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink',
Namespaces::HYPERLINK,
$drawing->getHyperlink()->getUrl(),
$drawing->getHyperlink()->getTypeHyperlink()
);

View File

@ -2,6 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces;
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
@ -27,13 +28,13 @@ class RelsRibbon extends WriterPart
// Relationships
$objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
$objWriter->writeAttribute('xmlns', Namespaces::RELATIONSHIPS);
$localRels = $spreadsheet->getRibbonBinObjects('names');
if (is_array($localRels)) {
foreach ($localRels as $aId => $aTarget) {
$objWriter->startElement('Relationship');
$objWriter->writeAttribute('Id', $aId);
$objWriter->writeAttribute('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image');
$objWriter->writeAttribute('Type', Namespaces::IMAGE);
$objWriter->writeAttribute('Target', $aTarget);
$objWriter->endElement();
}

View File

@ -2,6 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces;
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
@ -27,10 +28,10 @@ class RelsVBA extends WriterPart
// Relationships
$objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
$objWriter->writeAttribute('xmlns', Namespaces::RELATIONSHIPS);
$objWriter->startElement('Relationship');
$objWriter->writeAttribute('Id', 'rId1');
$objWriter->writeAttribute('Type', 'http://schemas.microsoft.com/office/2006/relationships/vbaProjectSignature');
$objWriter->writeAttribute('Type', Namespaces::VBA_SIGNATURE);
$objWriter->writeAttribute('Target', 'vbaProjectSignature.bin');
$objWriter->endElement();
$objWriter->endElement();

View File

@ -5,28 +5,26 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Cell\Cell;
use PhpOffice\PhpSpreadsheet\Cell\DataType;
use PhpOffice\PhpSpreadsheet\Chart\ChartColor;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces;
use PhpOffice\PhpSpreadsheet\RichText\RichText;
use PhpOffice\PhpSpreadsheet\RichText\Run;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet as ActualWorksheet;
class StringTable extends WriterPart
{
/**
* Create worksheet stringtable.
*
* @param Worksheet $worksheet Worksheet
* @param string[] $existingTable Existing table to eventually merge with
*
* @return string[] String table for worksheet
*/
public function createStringTable(Worksheet $worksheet, $existingTable = null)
public function createStringTable(ActualWorksheet $worksheet, $existingTable = null)
{
// Create string lookup table
$aStringTable = [];
$cellCollection = null;
$aFlippedStringTable = null; // For faster lookup
// Is an existing table given?
if (($existingTable !== null) && is_array($existingTable)) {
@ -85,7 +83,7 @@ class StringTable extends WriterPart
// String table
$objWriter->startElement('sst');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
$objWriter->writeAttribute('xmlns', Namespaces::MAIN);
$objWriter->writeAttribute('uniqueCount', (string) count($stringTable));
// Loop through string table

View File

@ -2,6 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
@ -37,7 +38,7 @@ class Style extends WriterPart
// styleSheet
$objWriter->startElement('styleSheet');
$objWriter->writeAttribute('xml:space', 'preserve');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
$objWriter->writeAttribute('xmlns', Namespaces::MAIN);
// numFmts
$objWriter->startElement('numFmts');

View File

@ -3,6 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces;
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
use PhpOffice\PhpSpreadsheet\Worksheet\Table as WorksheetTable;
@ -34,7 +35,7 @@ class Table extends WriterPart
$objWriter->startElement('table');
$objWriter->writeAttribute('xml:space', 'preserve');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
$objWriter->writeAttribute('xmlns', Namespaces::MAIN);
$objWriter->writeAttribute('id', (string) $tableRef);
$objWriter->writeAttribute('name', $name);
$objWriter->writeAttribute('displayName', $table->getName() ?: $name);

View File

@ -2,6 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces;
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
@ -121,7 +122,7 @@ class Theme extends WriterPart
// a:theme
$objWriter->startElement('a:theme');
$objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
$objWriter->writeAttribute('xmlns:a', Namespaces::DRAWINGML);
$objWriter->writeAttribute('name', 'Office Theme');
// a:themeElements

View File

@ -2,6 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
@ -32,8 +33,8 @@ class Workbook extends WriterPart
// workbook
$objWriter->startElement('workbook');
$objWriter->writeAttribute('xml:space', 'preserve');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
$objWriter->writeAttribute('xmlns', Namespaces::MAIN);
$objWriter->writeAttribute('xmlns:r', Namespaces::SCHEMA_OFFICE_DOCUMENT);
// fileVersion
$this->writeFileVersion($objWriter);

View File

@ -5,6 +5,7 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Calculation\Information\ErrorValue;
use PhpOffice\PhpSpreadsheet\Cell\Cell;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx\Namespaces;
use PhpOffice\PhpSpreadsheet\RichText\RichText;
use PhpOffice\PhpSpreadsheet\Settings;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
@ -41,15 +42,15 @@ class Worksheet extends WriterPart
// Worksheet
$objWriter->startElement('worksheet');
$objWriter->writeAttribute('xml:space', 'preserve');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
$objWriter->writeAttribute('xmlns', Namespaces::MAIN);
$objWriter->writeAttribute('xmlns:r', Namespaces::SCHEMA_OFFICE_DOCUMENT);
$objWriter->writeAttribute('xmlns:xdr', 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing');
$objWriter->writeAttribute('xmlns:x14', 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/main');
$objWriter->writeAttribute('xmlns:xm', 'http://schemas.microsoft.com/office/excel/2006/main');
$objWriter->writeAttribute('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
$objWriter->writeAttribute('xmlns:xdr', Namespaces::SPREADSHEET_DRAWING);
$objWriter->writeAttribute('xmlns:x14', Namespaces::DATA_VALIDATIONS1);
$objWriter->writeAttribute('xmlns:xm', Namespaces::DATA_VALIDATIONS2);
$objWriter->writeAttribute('xmlns:mc', Namespaces::COMPATIBILITY);
$objWriter->writeAttribute('mc:Ignorable', 'x14ac');
$objWriter->writeAttribute('xmlns:x14ac', 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac');
$objWriter->writeAttribute('xmlns:x14ac', Namespaces::SPREADSHEETML_AC);
// sheetPr
$this->writeSheetPr($objWriter, $worksheet);