Rename even more parameters

This commit is contained in:
Adrien Crivelli 2021-11-07 23:46:53 +09:00
parent 1b877abe54
commit 045db43d50
22 changed files with 709 additions and 711 deletions

View File

@ -2341,12 +2341,12 @@ parameters:
path: src/PhpSpreadsheet/Reader/Xls.php
-
message: "#^Parameter \\#1 \\$pValue of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\:\\:setShowSummaryBelow\\(\\) expects bool, int given\\.$#"
message: "#^Parameter \\#1 \\$showSummaryBelow of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\:\\:setShowSummaryBelow\\(\\) expects bool, int given\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xls.php
-
message: "#^Parameter \\#1 \\$pValue of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\:\\:setShowSummaryRight\\(\\) expects bool, int given\\.$#"
message: "#^Parameter \\#1 \\$showSummaryRight of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\:\\:setShowSummaryRight\\(\\) expects bool, int given\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xls.php
@ -2746,7 +2746,7 @@ parameters:
path: src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php
-
message: "#^Parameter \\#1 \\$pOperator of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\AutoFilter\\\\Column\\\\Rule\\:\\:setRule\\(\\) expects string, null given\\.$#"
message: "#^Parameter \\#1 \\$operator of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\AutoFilter\\\\Column\\\\Rule\\:\\:setRule\\(\\) expects string, null given\\.$#"
count: 2
path: src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php
@ -4621,17 +4621,17 @@ parameters:
path: src/PhpSpreadsheet/Worksheet/Worksheet.php
-
message: "#^Parameter \\#1 \\$pIndex of class PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension constructor expects int, null given\\.$#"
message: "#^Parameter \\#1 \\$index of class PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension constructor expects int, null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Worksheet/Worksheet.php
-
message: "#^Parameter \\#1 \\$pIndex of class PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension constructor expects string, null given\\.$#"
message: "#^Parameter \\#1 \\$index of class PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\ColumnDimension constructor expects string, null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Worksheet/Worksheet.php
-
message: "#^Parameter \\#1 \\$pRange of class PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\AutoFilter constructor expects string, null given\\.$#"
message: "#^Parameter \\#1 \\$range of class PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\AutoFilter constructor expects string, null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Worksheet/Worksheet.php
@ -4696,7 +4696,7 @@ parameters:
path: src/PhpSpreadsheet/Worksheet/Worksheet.php
-
message: "#^Parameter \\#1 \\$pRange of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\AutoFilter\\:\\:setRange\\(\\) expects string, null given\\.$#"
message: "#^Parameter \\#1 \\$range of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\AutoFilter\\:\\:setRange\\(\\) expects string, null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Worksheet/Worksheet.php
@ -4921,12 +4921,12 @@ parameters:
path: src/PhpSpreadsheet/Writer/Html.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowCellCss\\(\\) has parameter \\$colNum with no typehint specified\\.$#"
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowCellCss\\(\\) has parameter \\$columnNumber with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Html.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowCellCss\\(\\) has parameter \\$pRow with no typehint specified\\.$#"
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowCellCss\\(\\) has parameter \\$row with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Html.php
@ -4941,7 +4941,7 @@ parameters:
path: src/PhpSpreadsheet/Writer/Html.php
-
message: "#^Parameter \\#1 \\$pStyle of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:createCSSStyleFont\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Font, PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Font\\|null given\\.$#"
message: "#^Parameter \\#1 \\$font of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:createCSSStyleFont\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Font, PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Font\\|null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Html.php
@ -5051,7 +5051,7 @@ parameters:
path: src/PhpSpreadsheet/Writer/Html.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowWriteCell\\(\\) has parameter \\$pRow with no typehint specified\\.$#"
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowWriteCell\\(\\) has parameter \\$row with no typehint specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Html.php
@ -5676,7 +5676,7 @@ parameters:
path: src/PhpSpreadsheet/Writer/Xlsx/Drawing.php
-
message: "#^Parameter \\#2 \\$pChart of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Drawing\\:\\:writeChart\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart, PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false given\\.$#"
message: "#^Parameter \\#2 \\$chart of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Drawing\\:\\:writeChart\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart, PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false given\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Drawing.php
@ -5696,12 +5696,12 @@ parameters:
path: src/PhpSpreadsheet/Writer/Xlsx/Drawing.php
-
message: "#^Parameter \\#4 \\$pTarget of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Rels\\:\\:writeRelationship\\(\\) expects string, array\\|string\\|null given\\.$#"
message: "#^Parameter \\#4 \\$target of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Rels\\:\\:writeRelationship\\(\\) expects string, array\\|string\\|null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Rels.php
-
message: "#^Parameter \\#2 \\$pId of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Rels\\:\\:writeRelationship\\(\\) expects int, string given\\.$#"
message: "#^Parameter \\#2 \\$id of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Rels\\:\\:writeRelationship\\(\\) expects int, string given\\.$#"
count: 4
path: src/PhpSpreadsheet/Writer/Xlsx/Rels.php
@ -5811,22 +5811,22 @@ parameters:
path: src/PhpSpreadsheet/Writer/Xlsx/Style.php
-
message: "#^Parameter \\#2 \\$pNumberFormat of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Style\\:\\:writeNumFmt\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\NumberFormat, PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\NumberFormat\\|null given\\.$#"
message: "#^Parameter \\#2 \\$numberFormat of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Style\\:\\:writeNumFmt\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\NumberFormat, PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\NumberFormat\\|null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Style.php
-
message: "#^Parameter \\#2 \\$pFont of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Style\\:\\:writeFont\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Font, PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Font\\|null given\\.$#"
message: "#^Parameter \\#2 \\$font of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Style\\:\\:writeFont\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Font, PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Font\\|null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Style.php
-
message: "#^Parameter \\#2 \\$pFill of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Style\\:\\:writeFill\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Fill, PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Fill\\|null given\\.$#"
message: "#^Parameter \\#2 \\$fill of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Style\\:\\:writeFill\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Fill, PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Fill\\|null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Style.php
-
message: "#^Parameter \\#2 \\$pBorders of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Style\\:\\:writeBorder\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Borders, PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Borders\\|null given\\.$#"
message: "#^Parameter \\#2 \\$borders of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Style\\:\\:writeBorder\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Borders, PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Borders\\|null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Style.php
@ -5881,7 +5881,7 @@ parameters:
path: src/PhpSpreadsheet/Writer/Xlsx/Workbook.php
-
message: "#^Parameter \\#3 \\$pStringTable of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Worksheet\\:\\:writeSheetData\\(\\) expects array\\<string\\>, array\\<string\\>\\|null given\\.$#"
message: "#^Parameter \\#3 \\$stringTable of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Worksheet\\:\\:writeSheetData\\(\\) expects array\\<string\\>, array\\<string\\>\\|null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
@ -6151,7 +6151,7 @@ parameters:
path: tests/PhpSpreadsheetTests/Style/ConditionalTest.php
-
message: "#^Parameter \\#2 \\$pValue of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\AutoFilter\\\\Column\\:\\:setAttribute\\(\\) expects string, int given\\.$#"
message: "#^Parameter \\#2 \\$value of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\AutoFilter\\\\Column\\:\\:setAttribute\\(\\) expects string, int given\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Worksheet/AutoFilter/ColumnTest.php

View File

@ -282,7 +282,7 @@ abstract class Coordinate
'n' => 14, 'o' => 15, 'p' => 16, 'q' => 17, 'r' => 18, 's' => 19, 't' => 20, 'u' => 21, 'v' => 22, 'w' => 23, 'x' => 24, 'y' => 25, 'z' => 26,
];
// We also use the language construct isset() rather than the more costly strlen() function to match the length of $pString
// We also use the language construct isset() rather than the more costly strlen() function to match the length of $columnAddress
// for improved performance
if (isset($columnAddress[0])) {
if (!isset($columnAddress[1])) {

View File

@ -234,18 +234,18 @@ class ReferenceHelper
* Update data validations when inserting/deleting rows/columns.
*
* @param Worksheet $worksheet The worksheet that we're editing
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
* @param int $pNumCols Number of columns to insert/delete (negative values indicate deletion)
* @param int $pNumRows Number of rows to insert/delete (negative values indicate deletion)
* @param string $before Insert/Delete before this cell address (e.g. 'A1')
* @param int $numberOfColumns Number of columns to insert/delete (negative values indicate deletion)
* @param int $numberOfRows Number of rows to insert/delete (negative values indicate deletion)
*/
protected function adjustDataValidations(Worksheet $worksheet, $pBefore, $pNumCols, $pNumRows): void
protected function adjustDataValidations(Worksheet $worksheet, $before, $numberOfColumns, $numberOfRows): void
{
$aDataValidationCollection = $worksheet->getDataValidationCollection();
($pNumCols > 0 || $pNumRows > 0) ?
($numberOfColumns > 0 || $numberOfRows > 0) ?
uksort($aDataValidationCollection, ['self', 'cellReverseSort']) : uksort($aDataValidationCollection, ['self', 'cellSort']);
foreach ($aDataValidationCollection as $key => $value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
$newReference = $this->updateCellReference($key, $before, $numberOfColumns, $numberOfRows);
if ($key != $newReference) {
$worksheet->setDataValidation($newReference, $value);
$worksheet->setDataValidation($key, null);

View File

@ -197,27 +197,27 @@ class AutoFilter
/**
* Set AutoFilter.
*
* @param AutoFilter\Column|string $pColumn
* @param AutoFilter\Column|string $columnObjectOrString
* A simple string containing a Column ID like 'A' is permitted
*
* @return $this
*/
public function setColumn($pColumn)
public function setColumn($columnObjectOrString)
{
if ((is_string($pColumn)) && (!empty($pColumn))) {
$column = $pColumn;
} elseif (is_object($pColumn) && ($pColumn instanceof AutoFilter\Column)) {
$column = $pColumn->getColumnIndex();
if ((is_string($columnObjectOrString)) && (!empty($columnObjectOrString))) {
$column = $columnObjectOrString;
} elseif (is_object($columnObjectOrString) && ($columnObjectOrString instanceof AutoFilter\Column)) {
$column = $columnObjectOrString->getColumnIndex();
} else {
throw new PhpSpreadsheetException('Column is not within the autofilter range.');
}
$this->testColumnInRange($column);
if (is_string($pColumn)) {
$this->columns[$pColumn] = new AutoFilter\Column($pColumn, $this);
if (is_string($columnObjectOrString)) {
$this->columns[$columnObjectOrString] = new AutoFilter\Column($columnObjectOrString, $this);
} else {
$pColumn->setParent($this);
$this->columns[$column] = $pColumn;
$columnObjectOrString->setParent($this);
$this->columns[$column] = $columnObjectOrString;
}
ksort($this->columns);

View File

@ -284,31 +284,31 @@ class Rule
/**
* Set AutoFilter Rule Value.
*
* @param int|int[]|string|string[] $pValue
* @param int|int[]|string|string[] $value
*
* @return $this
*/
public function setValue($pValue)
public function setValue($value)
{
if (is_array($pValue)) {
if (is_array($value)) {
$grouping = -1;
foreach ($pValue as $key => $value) {
foreach ($value as $key => $v) {
// Validate array entries
if (!in_array($key, self::DATE_TIME_GROUPS)) {
// Remove any invalid entries from the value array
unset($pValue[$key]);
unset($value[$key]);
} else {
// Work out what the dateTime grouping will be
$grouping = max($grouping, array_search($key, self::DATE_TIME_GROUPS));
}
}
if (count($pValue) == 0) {
if (count($value) == 0) {
throw new PhpSpreadsheetException('Invalid rule value for column AutoFilter Rule.');
}
// Set the dateTime grouping that we've anticipated
$this->setGrouping(self::DATE_TIME_GROUPS[$grouping]);
}
$this->value = $pValue;
$this->value = $value;
return $this;
}

View File

@ -75,16 +75,16 @@ class SheetView
* Set ZoomScale.
* Valid values range from 10 to 400.
*
* @param int $pValue
* @param int $zoomScale
*
* @return $this
*/
public function setZoomScale($pValue)
public function setZoomScale($zoomScale)
{
// Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface,
// but it is apparently still able to handle any scale >= 1
if (($pValue >= 1) || $pValue === null) {
$this->zoomScale = $pValue;
if (($zoomScale >= 1) || $zoomScale === null) {
$this->zoomScale = $zoomScale;
} else {
throw new PhpSpreadsheetException('Scale must be greater than or equal to 1.');
}
@ -106,14 +106,14 @@ class SheetView
* Set ZoomScale.
* Valid values range from 10 to 400.
*
* @param int $pValue
* @param int $zoomScaleNormal
*
* @return $this
*/
public function setZoomScaleNormal($pValue)
public function setZoomScaleNormal($zoomScaleNormal)
{
if (($pValue >= 1) || $pValue === null) {
$this->zoomScaleNormal = $pValue;
if (($zoomScaleNormal >= 1) || $zoomScaleNormal === null) {
$this->zoomScaleNormal = $zoomScaleNormal;
} else {
throw new PhpSpreadsheetException('Scale must be greater than or equal to 1.');
}
@ -124,11 +124,11 @@ class SheetView
/**
* Set ShowZeroes setting.
*
* @param bool $pValue
* @param bool $showZeros
*/
public function setShowZeros($pValue): void
public function setShowZeros($showZeros): void
{
$this->showZeros = $pValue;
$this->showZeros = $showZeros;
}
/**
@ -157,18 +157,18 @@ class SheetView
* 'pageLayout' self::SHEETVIEW_PAGE_LAYOUT
* 'pageBreakPreview' self::SHEETVIEW_PAGE_BREAK_PREVIEW
*
* @param string $pValue
* @param string $sheetViewType
*
* @return $this
*/
public function setView($pValue)
public function setView($sheetViewType)
{
// MS Excel 2007 allows setting the view to 'normal', 'pageLayout' or 'pageBreakPreview' via the user interface
if ($pValue === null) {
$pValue = self::SHEETVIEW_NORMAL;
if ($sheetViewType === null) {
$sheetViewType = self::SHEETVIEW_NORMAL;
}
if (in_array($pValue, self::$sheetViewTypes)) {
$this->sheetviewType = $pValue;
if (in_array($sheetViewType, self::$sheetViewTypes)) {
$this->sheetviewType = $sheetViewType;
} else {
throw new PhpSpreadsheetException('Invalid sheetview layout type.');
}

File diff suppressed because it is too large Load Diff

View File

@ -149,13 +149,13 @@ class Csv extends BaseWriter
/**
* Set delimiter.
*
* @param string $pValue Delimiter, defaults to ','
* @param string $delimiter Delimiter, defaults to ','
*
* @return $this
*/
public function setDelimiter($pValue)
public function setDelimiter($delimiter)
{
$this->delimiter = $pValue;
$this->delimiter = $delimiter;
return $this;
}
@ -173,13 +173,13 @@ class Csv extends BaseWriter
/**
* Set enclosure.
*
* @param string $pValue Enclosure, defaults to "
* @param string $enclosure Enclosure, defaults to "
*
* @return $this
*/
public function setEnclosure($pValue = '"')
public function setEnclosure($enclosure = '"')
{
$this->enclosure = $pValue;
$this->enclosure = $enclosure;
return $this;
}
@ -197,13 +197,13 @@ class Csv extends BaseWriter
/**
* Set line ending.
*
* @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
* @param string $lineEnding Line ending, defaults to OS line ending (PHP_EOL)
*
* @return $this
*/
public function setLineEnding($pValue)
public function setLineEnding($lineEnding)
{
$this->lineEnding = $pValue;
$this->lineEnding = $lineEnding;
return $this;
}
@ -221,13 +221,13 @@ class Csv extends BaseWriter
/**
* Set whether BOM should be used.
*
* @param bool $pValue Use UTF-8 byte-order mark? Defaults to false
* @param bool $useBOM Use UTF-8 byte-order mark? Defaults to false
*
* @return $this
*/
public function setUseBOM($pValue)
public function setUseBOM($useBOM)
{
$this->useBOM = $pValue;
$this->useBOM = $useBOM;
return $this;
}
@ -245,13 +245,13 @@ class Csv extends BaseWriter
/**
* Set whether a separator line should be included as the first line of the file.
*
* @param bool $pValue Use separator line? Defaults to false
* @param bool $includeSeparatorLine Use separator line? Defaults to false
*
* @return $this
*/
public function setIncludeSeparatorLine($pValue)
public function setIncludeSeparatorLine($includeSeparatorLine)
{
$this->includeSeparatorLine = $pValue;
$this->includeSeparatorLine = $includeSeparatorLine;
return $this;
}
@ -269,14 +269,14 @@ class Csv extends BaseWriter
/**
* Set whether the file should be saved with full Excel Compatibility.
*
* @param bool $pValue Set the file to be written as a fully Excel compatible csv file
* @param bool $excelCompatibility Set the file to be written as a fully Excel compatible csv file
* Note that this overrides other settings such as useBOM, enclosure and delimiter
*
* @return $this
*/
public function setExcelCompatibility($pValue)
public function setExcelCompatibility($excelCompatibility)
{
$this->excelCompatibility = $pValue;
$this->excelCompatibility = $excelCompatibility;
return $this;
}
@ -294,13 +294,13 @@ class Csv extends BaseWriter
/**
* Set sheet index.
*
* @param int $pValue Sheet index
* @param int $sheetIndex Sheet index
*
* @return $this
*/
public function setSheetIndex($pValue)
public function setSheetIndex($sheetIndex)
{
$this->sheetIndex = $pValue;
$this->sheetIndex = $sheetIndex;
return $this;
}
@ -318,13 +318,13 @@ class Csv extends BaseWriter
/**
* Set output encoding.
*
* @param string $pValue Output encoding
* @param string $outputEnconding Output encoding
*
* @return $this
*/
public function setOutputEncoding($pValue)
public function setOutputEncoding($outputEnconding)
{
$this->outputEncoding = $pValue;
$this->outputEncoding = $outputEnconding;
return $this;
}
@ -361,10 +361,10 @@ class Csv extends BaseWriter
/**
* Write line to CSV file.
*
* @param resource $pFileHandle PHP filehandle
* @param array $pValues Array containing values in a row
* @param resource $fileHandle PHP filehandle
* @param array $values Array containing values in a row
*/
private function writeLine($pFileHandle, array $pValues): void
private function writeLine($fileHandle, array $values): void
{
// No leading delimiter
$delimiter = '';
@ -372,7 +372,7 @@ class Csv extends BaseWriter
// Build the line
$line = '';
foreach ($pValues as $element) {
foreach ($values as $element) {
$element = self::elementToString($element);
// Add delimiter
$line .= $delimiter;
@ -399,6 +399,6 @@ class Csv extends BaseWriter
if ($this->outputEncoding != '') {
$line = mb_convert_encoding($line, $this->outputEncoding);
}
fwrite($pFileHandle, $line);
fwrite($fileHandle, $line);
}
}

View File

@ -302,13 +302,13 @@ class Html extends BaseWriter
/**
* Set sheet index.
*
* @param int $pValue Sheet index
* @param int $sheetIndex Sheet index
*
* @return $this
*/
public function setSheetIndex($pValue)
public function setSheetIndex($sheetIndex)
{
$this->sheetIndex = $pValue;
$this->sheetIndex = $sheetIndex;
return $this;
}
@ -326,13 +326,13 @@ class Html extends BaseWriter
/**
* Set sheet index.
*
* @param bool $pValue Flag indicating whether the sheet navigation block should be generated or not
* @param bool $generateSheetNavigationBlock Flag indicating whether the sheet navigation block should be generated or not
*
* @return $this
*/
public function setGenerateSheetNavigationBlock($pValue)
public function setGenerateSheetNavigationBlock($generateSheetNavigationBlock)
{
$this->generateSheetNavigationBlock = (bool) $pValue;
$this->generateSheetNavigationBlock = (bool) $generateSheetNavigationBlock;
return $this;
}
@ -359,11 +359,11 @@ class Html extends BaseWriter
/**
* Generate HTML header.
*
* @param bool $pIncludeStyles Include styles?
* @param bool $includeStyles Include styles?
*
* @return string
*/
public function generateHTMLHeader($pIncludeStyles = false)
public function generateHTMLHeader($includeStyles = false)
{
// Construct HTML
$properties = $this->spreadsheet->getProperties();
@ -382,7 +382,7 @@ class Html extends BaseWriter
$html .= self::generateMeta($properties->getCompany(), 'company');
$html .= self::generateMeta($properties->getManager(), 'manager');
$html .= $pIncludeStyles ? $this->generateStyles(true) : $this->generatePageDeclarations(true);
$html .= $includeStyles ? $this->generateStyles(true) : $this->generatePageDeclarations(true);
$html .= ' </head>' . PHP_EOL;
$html .= '' . PHP_EOL;
@ -974,36 +974,34 @@ class Html extends BaseWriter
*
* @return array
*/
private function createCSSStyle(Style $pStyle)
private function createCSSStyle(Style $style)
{
// Create CSS
return array_merge(
$this->createCSSStyleAlignment($pStyle->getAlignment()),
$this->createCSSStyleBorders($pStyle->getBorders()),
$this->createCSSStyleFont($pStyle->getFont()),
$this->createCSSStyleFill($pStyle->getFill())
$this->createCSSStyleAlignment($style->getAlignment()),
$this->createCSSStyleBorders($style->getBorders()),
$this->createCSSStyleFont($style->getFont()),
$this->createCSSStyleFill($style->getFill())
);
}
/**
* Create CSS style (\PhpOffice\PhpSpreadsheet\Style\Alignment).
*
* @param Alignment $pStyle \PhpOffice\PhpSpreadsheet\Style\Alignment
* Create CSS style.
*
* @return array
*/
private function createCSSStyleAlignment(Alignment $pStyle)
private function createCSSStyleAlignment(Alignment $alignment)
{
// Construct CSS
$css = [];
// Create CSS
$css['vertical-align'] = $this->mapVAlign($pStyle->getVertical());
$textAlign = $this->mapHAlign($pStyle->getHorizontal());
$css['vertical-align'] = $this->mapVAlign($alignment->getVertical());
$textAlign = $this->mapHAlign($alignment->getHorizontal());
if ($textAlign) {
$css['text-align'] = $textAlign;
if (in_array($textAlign, ['left', 'right'])) {
$css['padding-' . $textAlign] = (string) ((int) $pStyle->getIndent() * 9) . 'px';
$css['padding-' . $textAlign] = (string) ((int) $alignment->getIndent() * 9) . 'px';
}
}
@ -1011,88 +1009,88 @@ class Html extends BaseWriter
}
/**
* Create CSS style (\PhpOffice\PhpSpreadsheet\Style\Font).
* Create CSS style.
*
* @return array
*/
private function createCSSStyleFont(Font $pStyle)
private function createCSSStyleFont(Font $font)
{
// Construct CSS
$css = [];
// Create CSS
if ($pStyle->getBold()) {
if ($font->getBold()) {
$css['font-weight'] = 'bold';
}
if ($pStyle->getUnderline() != Font::UNDERLINE_NONE && $pStyle->getStrikethrough()) {
if ($font->getUnderline() != Font::UNDERLINE_NONE && $font->getStrikethrough()) {
$css['text-decoration'] = 'underline line-through';
} elseif ($pStyle->getUnderline() != Font::UNDERLINE_NONE) {
} elseif ($font->getUnderline() != Font::UNDERLINE_NONE) {
$css['text-decoration'] = 'underline';
} elseif ($pStyle->getStrikethrough()) {
} elseif ($font->getStrikethrough()) {
$css['text-decoration'] = 'line-through';
}
if ($pStyle->getItalic()) {
if ($font->getItalic()) {
$css['font-style'] = 'italic';
}
$css['color'] = '#' . $pStyle->getColor()->getRGB();
$css['font-family'] = '\'' . $pStyle->getName() . '\'';
$css['font-size'] = $pStyle->getSize() . 'pt';
$css['color'] = '#' . $font->getColor()->getRGB();
$css['font-family'] = '\'' . $font->getName() . '\'';
$css['font-size'] = $font->getSize() . 'pt';
return $css;
}
/**
* Create CSS style (Borders).
* Create CSS style.
*
* @param Borders $pStyle Borders
* @param Borders $borders Borders
*
* @return array
*/
private function createCSSStyleBorders(Borders $pStyle)
private function createCSSStyleBorders(Borders $borders)
{
// Construct CSS
$css = [];
// Create CSS
$css['border-bottom'] = $this->createCSSStyleBorder($pStyle->getBottom());
$css['border-top'] = $this->createCSSStyleBorder($pStyle->getTop());
$css['border-left'] = $this->createCSSStyleBorder($pStyle->getLeft());
$css['border-right'] = $this->createCSSStyleBorder($pStyle->getRight());
$css['border-bottom'] = $this->createCSSStyleBorder($borders->getBottom());
$css['border-top'] = $this->createCSSStyleBorder($borders->getTop());
$css['border-left'] = $this->createCSSStyleBorder($borders->getLeft());
$css['border-right'] = $this->createCSSStyleBorder($borders->getRight());
return $css;
}
/**
* Create CSS style (Border).
* Create CSS style.
*
* @param Border $pStyle Border
* @param Border $border Border
*
* @return string
*/
private function createCSSStyleBorder(Border $pStyle)
private function createCSSStyleBorder(Border $border)
{
// Create CSS - add !important to non-none border styles for merged cells
$borderStyle = $this->mapBorderStyle($pStyle->getBorderStyle());
$borderStyle = $this->mapBorderStyle($border->getBorderStyle());
return $borderStyle . ' #' . $pStyle->getColor()->getRGB() . (($borderStyle == 'none') ? '' : ' !important');
return $borderStyle . ' #' . $border->getColor()->getRGB() . (($borderStyle == 'none') ? '' : ' !important');
}
/**
* Create CSS style (Fill).
*
* @param Fill $pStyle Fill
* @param Fill $fill Fill
*
* @return array
*/
private function createCSSStyleFill(Fill $pStyle)
private function createCSSStyleFill(Fill $fill)
{
// Construct HTML
$css = [];
// Create CSS
$value = $pStyle->getFillType() == Fill::FILL_NONE ?
'white' : '#' . $pStyle->getStartColor()->getRGB();
$value = $fill->getFillType() == Fill::FILL_NONE ?
'white' : '#' . $fill->getStartColor()->getRGB();
$css['background-color'] = $value;
return $css;
@ -1193,18 +1191,18 @@ class Html extends BaseWriter
* Generate row start.
*
* @param int $sheetIndex Sheet index (0-based)
* @param int $pRow row number
* @param int $row row number
*
* @return string
*/
private function generateRowStart(Worksheet $worksheet, $sheetIndex, $pRow)
private function generateRowStart(Worksheet $worksheet, $sheetIndex, $row)
{
$html = '';
if (count($worksheet->getBreaks()) > 0) {
$breaks = $worksheet->getBreaks();
// check if a break is needed before this row
if (isset($breaks['A' . $pRow])) {
if (isset($breaks['A' . $row])) {
// close table: </table>
$html .= $this->generateTableFooter();
if ($this->isPdf && $this->useInlineCss) {
@ -1219,10 +1217,10 @@ class Html extends BaseWriter
// Write row start
if (!$this->useInlineCss) {
$html .= ' <tr class="row' . $pRow . '">' . PHP_EOL;
$html .= ' <tr class="row' . $row . '">' . PHP_EOL;
} else {
$style = isset($this->cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow])
? $this->assembleCSS($this->cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow]) : '';
$style = isset($this->cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $row])
? $this->assembleCSS($this->cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $row]) : '';
$html .= ' <tr style="' . $style . '">' . PHP_EOL;
}
@ -1230,12 +1228,12 @@ class Html extends BaseWriter
return $html;
}
private function generateRowCellCss(Worksheet $worksheet, $cellAddress, $pRow, $colNum)
private function generateRowCellCss(Worksheet $worksheet, $cellAddress, $row, $columnNumber)
{
$cell = ($cellAddress > '') ? $worksheet->getCell($cellAddress) : '';
$coordinate = Coordinate::stringFromColumnIndex($colNum + 1) . ($pRow + 1);
$coordinate = Coordinate::stringFromColumnIndex($columnNumber + 1) . ($row + 1);
if (!$this->useInlineCss) {
$cssClass = 'column' . $colNum;
$cssClass = 'column' . $columnNumber;
} else {
$cssClass = [];
// The statements below do nothing.
@ -1381,7 +1379,7 @@ class Html extends BaseWriter
return $html;
}
private function generateRowWriteCell(&$html, Worksheet $worksheet, $coordinate, $cellType, $cellData, $colSpan, $rowSpan, $cssClass, $colNum, $sheetIndex, $pRow): void
private function generateRowWriteCell(&$html, Worksheet $worksheet, $coordinate, $cellType, $cellData, $colSpan, $rowSpan, $cssClass, $colNum, $sheetIndex, $row): void
{
// Image?
$htmlx = $this->writeImageInCell($worksheet, $coordinate);
@ -1416,8 +1414,8 @@ class Html extends BaseWriter
// We must also explicitly write the height of the <td> element because TCPDF
// does not recognize e.g. <tr style="height:50pt">
if (isset($this->cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow]['height'])) {
$height = $this->cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow]['height'];
if (isset($this->cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $row]['height'])) {
$height = $this->cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $row]['height'];
$xcssClass['height'] = $height;
}
//** end of redundant code **
@ -1444,22 +1442,22 @@ class Html extends BaseWriter
/**
* Generate row.
*
* @param array $pValues Array containing cells in a row
* @param int $pRow Row number (0-based)
* @param array $values Array containing cells in a row
* @param int $row Row number (0-based)
* @param string $cellType eg: 'td'
*
* @return string
*/
private function generateRow(Worksheet $worksheet, array $pValues, $pRow, $cellType)
private function generateRow(Worksheet $worksheet, array $values, $row, $cellType)
{
// Sheet index
$sheetIndex = $worksheet->getParent()->getIndex($worksheet);
$html = $this->generateRowStart($worksheet, $sheetIndex, $pRow);
$html = $this->generateRowStart($worksheet, $sheetIndex, $row);
// Write cells
$colNum = 0;
foreach ($pValues as $cellAddress) {
[$cell, $cssClass, $coordinate] = $this->generateRowCellCss($worksheet, $cellAddress, $pRow, $colNum);
foreach ($values as $cellAddress) {
[$cell, $cssClass, $coordinate] = $this->generateRowCellCss($worksheet, $cellAddress, $row, $colNum);
$colSpan = 1;
$rowSpan = 1;
@ -1473,20 +1471,20 @@ class Html extends BaseWriter
}
// Should the cell be written or is it swallowed by a rowspan or colspan?
$writeCell = !(isset($this->isSpannedCell[$worksheet->getParent()->getIndex($worksheet)][$pRow + 1][$colNum])
&& $this->isSpannedCell[$worksheet->getParent()->getIndex($worksheet)][$pRow + 1][$colNum]);
$writeCell = !(isset($this->isSpannedCell[$worksheet->getParent()->getIndex($worksheet)][$row + 1][$colNum])
&& $this->isSpannedCell[$worksheet->getParent()->getIndex($worksheet)][$row + 1][$colNum]);
// Colspan and Rowspan
$colspan = 1;
$rowspan = 1;
if (isset($this->isBaseCell[$worksheet->getParent()->getIndex($worksheet)][$pRow + 1][$colNum])) {
$spans = $this->isBaseCell[$worksheet->getParent()->getIndex($worksheet)][$pRow + 1][$colNum];
if (isset($this->isBaseCell[$worksheet->getParent()->getIndex($worksheet)][$row + 1][$colNum])) {
$spans = $this->isBaseCell[$worksheet->getParent()->getIndex($worksheet)][$row + 1][$colNum];
$rowSpan = $spans['rowspan'];
$colSpan = $spans['colspan'];
// Also apply style from last cell in merge to fix borders -
// relies on !important for non-none border declarations in createCSSStyleBorder
$endCellCoord = Coordinate::stringFromColumnIndex($colNum + $colSpan) . ($pRow + $rowSpan);
$endCellCoord = Coordinate::stringFromColumnIndex($colNum + $colSpan) . ($row + $rowSpan);
if (!$this->useInlineCss) {
$cssClass .= ' style' . $worksheet->getCell($endCellCoord)->getXfIndex();
}
@ -1494,7 +1492,7 @@ class Html extends BaseWriter
// Write
if ($writeCell) {
$this->generateRowWriteCell($html, $worksheet, $coordinate, $cellType, $cellData, $colSpan, $rowSpan, $cssClass, $colNum, $sheetIndex, $pRow);
$this->generateRowWriteCell($html, $worksheet, $coordinate, $cellType, $cellData, $colSpan, $rowSpan, $cssClass, $colNum, $sheetIndex, $row);
}
// Next column
@ -1513,10 +1511,10 @@ class Html extends BaseWriter
*
* @return string
*/
private function assembleCSS(array $pValue = [])
private function assembleCSS(array $values = [])
{
$pairs = [];
foreach ($pValue as $property => $value) {
foreach ($values as $property => $value) {
$pairs[] = $property . ':' . $value;
}
$string = implode('; ', $pairs);
@ -1537,13 +1535,13 @@ class Html extends BaseWriter
/**
* Set images root.
*
* @param string $pValue
* @param string $imagesRoot
*
* @return $this
*/
public function setImagesRoot($pValue)
public function setImagesRoot($imagesRoot)
{
$this->imagesRoot = $pValue;
$this->imagesRoot = $imagesRoot;
return $this;
}
@ -1561,13 +1559,13 @@ class Html extends BaseWriter
/**
* Set embed images.
*
* @param bool $pValue
* @param bool $embedImages
*
* @return $this
*/
public function setEmbedImages($pValue)
public function setEmbedImages($embedImages)
{
$this->embedImages = $pValue;
$this->embedImages = $embedImages;
return $this;
}
@ -1585,13 +1583,13 @@ class Html extends BaseWriter
/**
* Set use inline CSS?
*
* @param bool $pValue
* @param bool $useInlineCss
*
* @return $this
*/
public function setUseInlineCss($pValue)
public function setUseInlineCss($useInlineCss)
{
$this->useInlineCss = $pValue;
$this->useInlineCss = $useInlineCss;
return $this;
}
@ -1613,7 +1611,7 @@ class Html extends BaseWriter
/**
* Set use embedded CSS?
*
* @param bool $pValue
* @param bool $useEmbeddedCSS
*
* @return $this
*
@ -1621,9 +1619,9 @@ class Html extends BaseWriter
*
* @deprecated no longer used
*/
public function setUseEmbeddedCSS($pValue)
public function setUseEmbeddedCSS($useEmbeddedCSS)
{
$this->useEmbeddedCSS = $pValue;
$this->useEmbeddedCSS = $useEmbeddedCSS;
return $this;
}
@ -1631,32 +1629,32 @@ class Html extends BaseWriter
/**
* Add color to formatted string as inline style.
*
* @param string $pValue Plain formatted value without color
* @param string $pFormat Format code
* @param string $value Plain formatted value without color
* @param string $format Format code
*
* @return string
*/
public function formatColor($pValue, $pFormat)
public function formatColor($value, $format)
{
// Color information, e.g. [Red] is always at the beginning
$color = null; // initialize
$matches = [];
$color_regex = '/^\\[[a-zA-Z]+\\]/';
if (preg_match($color_regex, $pFormat, $matches)) {
if (preg_match($color_regex, $format, $matches)) {
$color = str_replace(['[', ']'], '', $matches[0]);
$color = strtolower($color);
}
// convert to PCDATA
$value = htmlspecialchars($pValue, Settings::htmlEntityFlags());
$result = htmlspecialchars($value, Settings::htmlEntityFlags());
// color span tag
if ($color !== null) {
$value = '<span style="color:' . $color . '">' . $value . '</span>';
$result = '<span style="color:' . $color . '">' . $result . '</span>';
}
return $value;
return $result;
}
/**

View File

@ -408,13 +408,13 @@ class Workbook extends BIFFwriter
* Assemble worksheets into a workbook and send the BIFF data to an OLE
* storage.
*
* @param array $pWorksheetSizes The sizes in bytes of the binary worksheet streams
* @param array $worksheetSizes The sizes in bytes of the binary worksheet streams
*
* @return string Binary data for workbook stream
*/
public function writeWorkbook(array $pWorksheetSizes)
public function writeWorkbook(array $worksheetSizes)
{
$this->worksheetSizes = $pWorksheetSizes;
$this->worksheetSizes = $worksheetSizes;
// Calculate the number of selected worksheet tabs and call the finalization
// methods for each worksheet
@ -523,9 +523,9 @@ class Workbook extends BIFFwriter
$this->writeStyle();
}
private function parseDefinedNameValue(DefinedName $pDefinedName): string
private function parseDefinedNameValue(DefinedName $definedName): string
{
$definedRange = $pDefinedName->getValue();
$definedRange = $definedName->getValue();
$splitCount = preg_match_all(
'/' . Calculation::CALCULATION_REGEXP_CELLREF . '/mui',
$definedRange,
@ -552,7 +552,7 @@ class Workbook extends BIFFwriter
if (empty($worksheet)) {
if (($offset === 0) || ($definedRange[$offset - 1] !== ':')) {
// We should have a worksheet
$worksheet = $pDefinedName->getWorksheet() ? $pDefinedName->getWorksheet()->getTitle() : null;
$worksheet = $definedName->getWorksheet() ? $definedName->getWorksheet()->getTitle() : null;
}
} else {
$worksheet = str_replace("''", "'", trim($worksheet, "'"));
@ -1185,10 +1185,10 @@ class Workbook extends BIFFwriter
/**
* Set Escher object.
*
* @param \PhpOffice\PhpSpreadsheet\Shared\Escher $pValue
* @param \PhpOffice\PhpSpreadsheet\Shared\Escher $escher
*/
public function setEscher(?\PhpOffice\PhpSpreadsheet\Shared\Escher $pValue = null): void
public function setEscher(?\PhpOffice\PhpSpreadsheet\Shared\Escher $escher = null): void
{
$this->escher = $pValue;
$this->escher = $escher;
}
}

View File

@ -2518,11 +2518,11 @@ class Worksheet extends BIFFwriter
/**
* Set Escher object.
*
* @param \PhpOffice\PhpSpreadsheet\Shared\Escher $pValue
* @param \PhpOffice\PhpSpreadsheet\Shared\Escher $escher
*/
public function setEscher(?\PhpOffice\PhpSpreadsheet\Shared\Escher $pValue = null): void
public function setEscher(?\PhpOffice\PhpSpreadsheet\Shared\Escher $escher = null): void
{
$this->escher = $pValue;
$this->escher = $escher;
}
/**

View File

@ -640,13 +640,13 @@ class Xlsx extends BaseWriter
/**
* Set Office2003 compatibility.
*
* @param bool $pValue Office2003 compatibility?
* @param bool $office2003compatibility Office2003 compatibility?
*
* @return $this
*/
public function setOffice2003Compatibility($pValue)
public function setOffice2003Compatibility($office2003compatibility)
{
$this->office2003compatibility = $pValue;
$this->office2003compatibility = $office2003compatibility;
return $this;
}

View File

@ -30,7 +30,7 @@ class Chart extends WriterPart
*
* @return string XML Output
*/
public function writeChart(\PhpOffice\PhpSpreadsheet\Chart\Chart $pChart, $calculateCellValues = true)
public function writeChart(\PhpOffice\PhpSpreadsheet\Chart\Chart $chart, $calculateCellValues = true)
{
$this->calculateCellValues = $calculateCellValues;
@ -43,7 +43,7 @@ class Chart extends WriterPart
}
// Ensure that data series values are up-to-date before we save
if ($this->calculateCellValues) {
$pChart->refresh();
$chart->refresh();
}
// XML header
@ -69,22 +69,22 @@ class Chart extends WriterPart
$objWriter->startElement('c:chart');
$this->writeTitle($objWriter, $pChart->getTitle());
$this->writeTitle($objWriter, $chart->getTitle());
$objWriter->startElement('c:autoTitleDeleted');
$objWriter->writeAttribute('val', 0);
$objWriter->endElement();
$this->writePlotArea($objWriter, $pChart->getPlotArea(), $pChart->getXAxisLabel(), $pChart->getYAxisLabel(), $pChart->getChartAxisX(), $pChart->getChartAxisY(), $pChart->getMajorGridlines(), $pChart->getMinorGridlines());
$this->writePlotArea($objWriter, $chart->getPlotArea(), $chart->getXAxisLabel(), $chart->getYAxisLabel(), $chart->getChartAxisX(), $chart->getChartAxisY(), $chart->getMajorGridlines(), $chart->getMinorGridlines());
$this->writeLegend($objWriter, $pChart->getLegend());
$this->writeLegend($objWriter, $chart->getLegend());
$objWriter->startElement('c:plotVisOnly');
$objWriter->writeAttribute('val', (int) $pChart->getPlotVisibleOnly());
$objWriter->writeAttribute('val', (int) $chart->getPlotVisibleOnly());
$objWriter->endElement();
$objWriter->startElement('c:dispBlanksAs');
$objWriter->writeAttribute('val', $pChart->getDisplayBlanksAs());
$objWriter->writeAttribute('val', $chart->getDisplayBlanksAs());
$objWriter->endElement();
$objWriter->startElement('c:showDLblsOverMax');

View File

@ -13,7 +13,7 @@ class Comments extends WriterPart
*
* @return string XML Output
*/
public function writeComments(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet)
public function writeComments(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet)
{
// Create XML writer
$objWriter = null;
@ -27,7 +27,7 @@ class Comments extends WriterPart
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Comments cache
$comments = $pWorksheet->getComments();
$comments = $worksheet->getComments();
// Authors cache
$authors = [];
@ -67,19 +67,19 @@ class Comments extends WriterPart
*
* @param XMLWriter $objWriter XML Writer
* @param string $cellReference Cell reference
* @param Comment $pComment Comment
* @param array $pAuthors Array of authors
* @param Comment $comment Comment
* @param array $authors Array of authors
*/
private function writeComment(XMLWriter $objWriter, $cellReference, Comment $pComment, array $pAuthors): void
private function writeComment(XMLWriter $objWriter, $cellReference, Comment $comment, array $authors): void
{
// comment
$objWriter->startElement('comment');
$objWriter->writeAttribute('ref', $cellReference);
$objWriter->writeAttribute('authorId', $pAuthors[$pComment->getAuthor()]);
$objWriter->writeAttribute('authorId', $authors[$comment->getAuthor()]);
// text
$objWriter->startElement('text');
$this->getParentWriter()->getWriterPartstringtable()->writeRichText($objWriter, $pComment->getText());
$this->getParentWriter()->getWriterPartstringtable()->writeRichText($objWriter, $comment->getText());
$objWriter->endElement();
$objWriter->endElement();
@ -90,7 +90,7 @@ class Comments extends WriterPart
*
* @return string XML Output
*/
public function writeVMLComments(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet)
public function writeVMLComments(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet)
{
// Create XML writer
$objWriter = null;
@ -104,7 +104,7 @@ class Comments extends WriterPart
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Comments cache
$comments = $pWorksheet->getComments();
$comments = $worksheet->getComments();
// xml
$objWriter->startElement('xml');
@ -160,9 +160,9 @@ class Comments extends WriterPart
*
* @param XMLWriter $objWriter XML Writer
* @param string $cellReference Cell reference, eg: 'A1'
* @param Comment $pComment Comment
* @param Comment $comment Comment
*/
private function writeVMLComment(XMLWriter $objWriter, $cellReference, Comment $pComment): void
private function writeVMLComment(XMLWriter $objWriter, $cellReference, Comment $comment): void
{
// Metadata
[$column, $row] = Coordinate::indexesFromString($cellReference);
@ -173,13 +173,13 @@ class Comments extends WriterPart
$objWriter->startElement('v:shape');
$objWriter->writeAttribute('id', '_x0000_s' . $id);
$objWriter->writeAttribute('type', '#_x0000_t202');
$objWriter->writeAttribute('style', 'position:absolute;margin-left:' . $pComment->getMarginLeft() . ';margin-top:' . $pComment->getMarginTop() . ';width:' . $pComment->getWidth() . ';height:' . $pComment->getHeight() . ';z-index:1;visibility:' . ($pComment->getVisible() ? 'visible' : 'hidden'));
$objWriter->writeAttribute('fillcolor', '#' . $pComment->getFillColor()->getRGB());
$objWriter->writeAttribute('style', 'position:absolute;margin-left:' . $comment->getMarginLeft() . ';margin-top:' . $comment->getMarginTop() . ';width:' . $comment->getWidth() . ';height:' . $comment->getHeight() . ';z-index:1;visibility:' . ($comment->getVisible() ? 'visible' : 'hidden'));
$objWriter->writeAttribute('fillcolor', '#' . $comment->getFillColor()->getRGB());
$objWriter->writeAttribute('o:insetmode', 'auto');
// v:fill
$objWriter->startElement('v:fill');
$objWriter->writeAttribute('color2', '#' . $pComment->getFillColor()->getRGB());
$objWriter->writeAttribute('color2', '#' . $comment->getFillColor()->getRGB());
$objWriter->endElement();
// v:shadow

View File

@ -183,35 +183,35 @@ class ContentTypes extends WriterPart
/**
* Get image mime type.
*
* @param string $pFile Filename
* @param string $filename Filename
*
* @return string Mime Type
*/
private function getImageMimeType($pFile)
private function getImageMimeType($filename)
{
if (File::fileExists($pFile)) {
$image = getimagesize($pFile);
if (File::fileExists($filename)) {
$image = getimagesize($filename);
return image_type_to_mime_type((is_array($image) && count($image) >= 3) ? $image[2] : 0);
}
throw new WriterException("File $pFile does not exist");
throw new WriterException("File $filename does not exist");
}
/**
* Write Default content type.
*
* @param XMLWriter $objWriter XML Writer
* @param string $pPartname Part name
* @param string $pContentType Content type
* @param string $partName Part name
* @param string $contentType Content type
*/
private function writeDefaultContentType(XMLWriter $objWriter, $pPartname, $pContentType): void
private function writeDefaultContentType(XMLWriter $objWriter, $partName, $contentType): void
{
if ($pPartname != '' && $pContentType != '') {
if ($partName != '' && $contentType != '') {
// Write content type
$objWriter->startElement('Default');
$objWriter->writeAttribute('Extension', $pPartname);
$objWriter->writeAttribute('ContentType', $pContentType);
$objWriter->writeAttribute('Extension', $partName);
$objWriter->writeAttribute('ContentType', $contentType);
$objWriter->endElement();
} else {
throw new WriterException('Invalid parameters passed.');
@ -222,16 +222,16 @@ class ContentTypes extends WriterPart
* Write Override content type.
*
* @param XMLWriter $objWriter XML Writer
* @param string $pPartname Part name
* @param string $pContentType Content type
* @param string $partName Part name
* @param string $contentType Content type
*/
private function writeOverrideContentType(XMLWriter $objWriter, $pPartname, $pContentType): void
private function writeOverrideContentType(XMLWriter $objWriter, $partName, $contentType): void
{
if ($pPartname != '' && $pContentType != '') {
if ($partName != '' && $contentType != '') {
// Write content type
$objWriter->startElement('Override');
$objWriter->writeAttribute('PartName', $pPartname);
$objWriter->writeAttribute('ContentType', $pContentType);
$objWriter->writeAttribute('PartName', $partName);
$objWriter->writeAttribute('ContentType', $contentType);
$objWriter->endElement();
} else {
throw new WriterException('Invalid parameters passed.');

View File

@ -66,13 +66,13 @@ class DefinedNames
/**
* Write Defined Name for named range.
*/
private function writeDefinedName(DefinedName $pDefinedName): void
private function writeDefinedName(DefinedName $definedName): void
{
// definedName for named range
$local = -1;
if ($pDefinedName->getLocalOnly() && $pDefinedName->getScope() !== null) {
if ($definedName->getLocalOnly() && $definedName->getScope() !== null) {
try {
$local = $pDefinedName->getScope()->getParent()->getIndex($pDefinedName->getScope());
$local = $definedName->getScope()->getParent()->getIndex($definedName->getScope());
} catch (Exception $e) {
// See issue 2266 - deleting sheet which contains
// defined names will cause Exception above.
@ -80,7 +80,7 @@ class DefinedNames
}
}
$this->objWriter->startElement('definedName');
$this->objWriter->writeAttribute('name', $pDefinedName->getName());
$this->objWriter->writeAttribute('name', $definedName->getName());
if ($local >= 0) {
$this->objWriter->writeAttribute(
'localSheetId',
@ -88,7 +88,7 @@ class DefinedNames
);
}
$definedRange = $this->getDefinedRange($pDefinedName);
$definedRange = $this->getDefinedRange($definedName);
$this->objWriter->writeRawData($definedRange);
@ -189,9 +189,9 @@ class DefinedNames
}
}
private function getDefinedRange(DefinedName $pDefinedName): string
private function getDefinedRange(DefinedName $definedName): string
{
$definedRange = $pDefinedName->getValue();
$definedRange = $definedName->getValue();
$splitCount = preg_match_all(
'/' . Calculation::CALCULATION_REGEXP_CELLREF_RELATIVE . '/mui',
$definedRange,
@ -218,7 +218,7 @@ class DefinedNames
if (empty($worksheet)) {
if (($offset === 0) || ($definedRange[$offset - 1] !== ':')) {
// We should have a worksheet
$ws = $pDefinedName->getWorksheet();
$ws = $definedName->getWorksheet();
$worksheet = ($ws === null) ? null : $ws->getTitle();
}
} else {

View File

@ -18,7 +18,7 @@ class Drawing extends WriterPart
*
* @return string XML Output
*/
public function writeDrawings(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet, $includeCharts = false)
public function writeDrawings(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet, $includeCharts = false)
{
// Create XML writer
$objWriter = null;
@ -38,7 +38,7 @@ class Drawing extends WriterPart
// Loop through images and write drawings
$i = 1;
$iterator = $pWorksheet->getDrawingCollection()->getIterator();
$iterator = $worksheet->getDrawingCollection()->getIterator();
while ($iterator->valid()) {
/** @var BaseDrawing $pDrawing */
$pDrawing = $iterator->current();
@ -52,19 +52,19 @@ class Drawing extends WriterPart
}
if ($includeCharts) {
$chartCount = $pWorksheet->getChartCount();
$chartCount = $worksheet->getChartCount();
// Loop through charts and write the chart position
if ($chartCount > 0) {
for ($c = 0; $c < $chartCount; ++$c) {
$this->writeChart($objWriter, $pWorksheet->getChartByIndex($c), $c + $i);
$this->writeChart($objWriter, $worksheet->getChartByIndex($c), $c + $i);
}
}
}
// unparsed AlternateContent
$unparsedLoadedData = $pWorksheet->getParent()->getUnparsedLoadedData();
if (isset($unparsedLoadedData['sheets'][$pWorksheet->getCodeName()]['drawingAlternateContents'])) {
foreach ($unparsedLoadedData['sheets'][$pWorksheet->getCodeName()]['drawingAlternateContents'] as $drawingAlternateContent) {
$unparsedLoadedData = $worksheet->getParent()->getUnparsedLoadedData();
if (isset($unparsedLoadedData['sheets'][$worksheet->getCodeName()]['drawingAlternateContents'])) {
foreach ($unparsedLoadedData['sheets'][$worksheet->getCodeName()]['drawingAlternateContents'] as $drawingAlternateContent) {
$objWriter->writeRaw($drawingAlternateContent);
}
}
@ -79,13 +79,13 @@ class Drawing extends WriterPart
* Write drawings to XML format.
*
* @param XMLWriter $objWriter XML Writer
* @param int $pRelationId
* @param int $relationId
*/
public function writeChart(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Chart\Chart $pChart, $pRelationId = -1): void
public function writeChart(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Chart\Chart $chart, $relationId = -1): void
{
$tl = $pChart->getTopLeftPosition();
$tl = $chart->getTopLeftPosition();
$tlColRow = Coordinate::indexesFromString($tl['cell']);
$br = $pChart->getBottomRightPosition();
$br = $chart->getBottomRightPosition();
$brColRow = Coordinate::indexesFromString($br['cell']);
$objWriter->startElement('xdr:twoCellAnchor');
@ -107,8 +107,8 @@ class Drawing extends WriterPart
$objWriter->writeAttribute('macro', '');
$objWriter->startElement('xdr:nvGraphicFramePr');
$objWriter->startElement('xdr:cNvPr');
$objWriter->writeAttribute('name', 'Chart ' . $pRelationId);
$objWriter->writeAttribute('id', 1025 * $pRelationId);
$objWriter->writeAttribute('name', 'Chart ' . $relationId);
$objWriter->writeAttribute('id', 1025 * $relationId);
$objWriter->endElement();
$objWriter->startElement('xdr:cNvGraphicFramePr');
$objWriter->startElement('a:graphicFrameLocks');
@ -133,7 +133,7 @@ class Drawing extends WriterPart
$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('r:id', 'rId' . $pRelationId);
$objWriter->writeAttribute('r:id', 'rId' . $relationId);
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
@ -149,29 +149,29 @@ class Drawing extends WriterPart
* Write drawings to XML format.
*
* @param XMLWriter $objWriter XML Writer
* @param int $pRelationId
* @param int $relationId
* @param null|int $hlinkClickId
*/
public function writeDrawing(XMLWriter $objWriter, BaseDrawing $pDrawing, $pRelationId = -1, $hlinkClickId = null): void
public function writeDrawing(XMLWriter $objWriter, BaseDrawing $drawing, $relationId = -1, $hlinkClickId = null): void
{
if ($pRelationId >= 0) {
if ($relationId >= 0) {
// xdr:oneCellAnchor
$objWriter->startElement('xdr:oneCellAnchor');
// Image location
$aCoordinates = Coordinate::indexesFromString($pDrawing->getCoordinates());
$aCoordinates = Coordinate::indexesFromString($drawing->getCoordinates());
// xdr:from
$objWriter->startElement('xdr:from');
$objWriter->writeElement('xdr:col', $aCoordinates[0] - 1);
$objWriter->writeElement('xdr:colOff', \PhpOffice\PhpSpreadsheet\Shared\Drawing::pixelsToEMU($pDrawing->getOffsetX()));
$objWriter->writeElement('xdr:colOff', \PhpOffice\PhpSpreadsheet\Shared\Drawing::pixelsToEMU($drawing->getOffsetX()));
$objWriter->writeElement('xdr:row', $aCoordinates[1] - 1);
$objWriter->writeElement('xdr:rowOff', \PhpOffice\PhpSpreadsheet\Shared\Drawing::pixelsToEMU($pDrawing->getOffsetY()));
$objWriter->writeElement('xdr:rowOff', \PhpOffice\PhpSpreadsheet\Shared\Drawing::pixelsToEMU($drawing->getOffsetY()));
$objWriter->endElement();
// xdr:ext
$objWriter->startElement('xdr:ext');
$objWriter->writeAttribute('cx', \PhpOffice\PhpSpreadsheet\Shared\Drawing::pixelsToEMU($pDrawing->getWidth()));
$objWriter->writeAttribute('cy', \PhpOffice\PhpSpreadsheet\Shared\Drawing::pixelsToEMU($pDrawing->getHeight()));
$objWriter->writeAttribute('cx', \PhpOffice\PhpSpreadsheet\Shared\Drawing::pixelsToEMU($drawing->getWidth()));
$objWriter->writeAttribute('cy', \PhpOffice\PhpSpreadsheet\Shared\Drawing::pixelsToEMU($drawing->getHeight()));
$objWriter->endElement();
// xdr:pic
@ -182,9 +182,9 @@ class Drawing extends WriterPart
// xdr:cNvPr
$objWriter->startElement('xdr:cNvPr');
$objWriter->writeAttribute('id', $pRelationId);
$objWriter->writeAttribute('name', $pDrawing->getName());
$objWriter->writeAttribute('descr', $pDrawing->getDescription());
$objWriter->writeAttribute('id', $relationId);
$objWriter->writeAttribute('name', $drawing->getName());
$objWriter->writeAttribute('descr', $drawing->getDescription());
//a:hlinkClick
$this->writeHyperLinkDrawing($objWriter, $hlinkClickId);
@ -209,7 +209,7 @@ class Drawing extends WriterPart
// a:blip
$objWriter->startElement('a:blip');
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
$objWriter->writeAttribute('r:embed', 'rId' . $pRelationId);
$objWriter->writeAttribute('r:embed', 'rId' . $relationId);
$objWriter->endElement();
// a:stretch
@ -224,7 +224,7 @@ class Drawing extends WriterPart
// a:xfrm
$objWriter->startElement('a:xfrm');
$objWriter->writeAttribute('rot', \PhpOffice\PhpSpreadsheet\Shared\Drawing::degreesToAngle($pDrawing->getRotation()));
$objWriter->writeAttribute('rot', \PhpOffice\PhpSpreadsheet\Shared\Drawing::degreesToAngle($drawing->getRotation()));
$objWriter->endElement();
// a:prstGeom
@ -236,25 +236,25 @@ class Drawing extends WriterPart
$objWriter->endElement();
if ($pDrawing->getShadow()->getVisible()) {
if ($drawing->getShadow()->getVisible()) {
// a:effectLst
$objWriter->startElement('a:effectLst');
// a:outerShdw
$objWriter->startElement('a:outerShdw');
$objWriter->writeAttribute('blurRad', \PhpOffice\PhpSpreadsheet\Shared\Drawing::pixelsToEMU($pDrawing->getShadow()->getBlurRadius()));
$objWriter->writeAttribute('dist', \PhpOffice\PhpSpreadsheet\Shared\Drawing::pixelsToEMU($pDrawing->getShadow()->getDistance()));
$objWriter->writeAttribute('dir', \PhpOffice\PhpSpreadsheet\Shared\Drawing::degreesToAngle($pDrawing->getShadow()->getDirection()));
$objWriter->writeAttribute('algn', $pDrawing->getShadow()->getAlignment());
$objWriter->writeAttribute('blurRad', \PhpOffice\PhpSpreadsheet\Shared\Drawing::pixelsToEMU($drawing->getShadow()->getBlurRadius()));
$objWriter->writeAttribute('dist', \PhpOffice\PhpSpreadsheet\Shared\Drawing::pixelsToEMU($drawing->getShadow()->getDistance()));
$objWriter->writeAttribute('dir', \PhpOffice\PhpSpreadsheet\Shared\Drawing::degreesToAngle($drawing->getShadow()->getDirection()));
$objWriter->writeAttribute('algn', $drawing->getShadow()->getAlignment());
$objWriter->writeAttribute('rotWithShape', '0');
// a:srgbClr
$objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', $pDrawing->getShadow()->getColor()->getRGB());
$objWriter->writeAttribute('val', $drawing->getShadow()->getColor()->getRGB());
// a:alpha
$objWriter->startElement('a:alpha');
$objWriter->writeAttribute('val', $pDrawing->getShadow()->getAlpha() * 1000);
$objWriter->writeAttribute('val', $drawing->getShadow()->getAlpha() * 1000);
$objWriter->endElement();
$objWriter->endElement();
@ -281,7 +281,7 @@ class Drawing extends WriterPart
*
* @return string XML Output
*/
public function writeVMLHeaderFooterImages(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet)
public function writeVMLHeaderFooterImages(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet)
{
// Create XML writer
$objWriter = null;
@ -295,7 +295,7 @@ class Drawing extends WriterPart
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Header/footer images
$images = $pWorksheet->getHeaderFooter()->getImages();
$images = $worksheet->getHeaderFooter()->getImages();
// xml
$objWriter->startElement('xml');
@ -425,32 +425,32 @@ class Drawing extends WriterPart
* Write VML comment to XML format.
*
* @param XMLWriter $objWriter XML Writer
* @param string $pReference Reference
* @param HeaderFooterDrawing $pImage Image
* @param string $reference Reference
* @param HeaderFooterDrawing $image Image
*/
private function writeVMLHeaderFooterImage(XMLWriter $objWriter, $pReference, HeaderFooterDrawing $pImage): void
private function writeVMLHeaderFooterImage(XMLWriter $objWriter, $reference, HeaderFooterDrawing $image): void
{
// Calculate object id
preg_match('{(\d+)}', md5($pReference), $m);
preg_match('{(\d+)}', md5($reference), $m);
$id = 1500 + ((int) substr($m[1], 0, 2) * 1);
// Calculate offset
$width = $pImage->getWidth();
$height = $pImage->getHeight();
$marginLeft = $pImage->getOffsetX();
$marginTop = $pImage->getOffsetY();
$width = $image->getWidth();
$height = $image->getHeight();
$marginLeft = $image->getOffsetX();
$marginTop = $image->getOffsetY();
// v:shape
$objWriter->startElement('v:shape');
$objWriter->writeAttribute('id', $pReference);
$objWriter->writeAttribute('id', $reference);
$objWriter->writeAttribute('o:spid', '_x0000_s' . $id);
$objWriter->writeAttribute('type', '#_x0000_t75');
$objWriter->writeAttribute('style', "position:absolute;margin-left:{$marginLeft}px;margin-top:{$marginTop}px;width:{$width}px;height:{$height}px;z-index:1");
// v:imagedata
$objWriter->startElement('v:imagedata');
$objWriter->writeAttribute('o:relid', 'rId' . $pReference);
$objWriter->writeAttribute('o:title', $pImage->getName());
$objWriter->writeAttribute('o:relid', 'rId' . $reference);
$objWriter->writeAttribute('o:title', $image->getName());
$objWriter->endElement();
// o:lock

View File

@ -160,12 +160,12 @@ class Rels extends WriterPart
* rId1 - Drawings
* rId_hyperlink_x - Hyperlinks
*
* @param int $pWorksheetId
* @param int $worksheetId
* @param bool $includeCharts Flag indicating if we should write charts
*
* @return string XML Output
*/
public function writeWorksheetRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet, $pWorksheetId = 1, $includeCharts = false)
public function writeWorksheetRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet, $worksheetId = 1, $includeCharts = false)
{
// Create XML writer
$objWriter = null;
@ -184,18 +184,18 @@ class Rels extends WriterPart
// Write drawing relationships?
$drawingOriginalIds = [];
$unparsedLoadedData = $pWorksheet->getParent()->getUnparsedLoadedData();
if (isset($unparsedLoadedData['sheets'][$pWorksheet->getCodeName()]['drawingOriginalIds'])) {
$drawingOriginalIds = $unparsedLoadedData['sheets'][$pWorksheet->getCodeName()]['drawingOriginalIds'];
$unparsedLoadedData = $worksheet->getParent()->getUnparsedLoadedData();
if (isset($unparsedLoadedData['sheets'][$worksheet->getCodeName()]['drawingOriginalIds'])) {
$drawingOriginalIds = $unparsedLoadedData['sheets'][$worksheet->getCodeName()]['drawingOriginalIds'];
}
if ($includeCharts) {
$charts = $pWorksheet->getChartCollection();
$charts = $worksheet->getChartCollection();
} else {
$charts = [];
}
if (($pWorksheet->getDrawingCollection()->count() > 0) || (count($charts) > 0) || $drawingOriginalIds) {
if (($worksheet->getDrawingCollection()->count() > 0) || (count($charts) > 0) || $drawingOriginalIds) {
$rId = 1;
// Use original $relPath to get original $rId.
@ -208,7 +208,7 @@ class Rels extends WriterPart
}
// Generate new $relPath to write drawing relationship
$relPath = '../drawings/drawing' . $pWorksheetId . '.xml';
$relPath = '../drawings/drawing' . $worksheetId . '.xml';
$this->writeRelationship(
$objWriter,
$rId,
@ -219,7 +219,7 @@ class Rels extends WriterPart
// Write hyperlink relationships?
$i = 1;
foreach ($pWorksheet->getHyperlinkCollection() as $hyperlink) {
foreach ($worksheet->getHyperlinkCollection() as $hyperlink) {
if (!$hyperlink->isInternal()) {
$this->writeRelationship(
$objWriter,
@ -235,50 +235,50 @@ class Rels extends WriterPart
// Write comments relationship?
$i = 1;
if (count($pWorksheet->getComments()) > 0) {
if (count($worksheet->getComments()) > 0) {
$this->writeRelationship(
$objWriter,
'_comments_vml' . $i,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing',
'../drawings/vmlDrawing' . $pWorksheetId . '.vml'
'../drawings/vmlDrawing' . $worksheetId . '.vml'
);
$this->writeRelationship(
$objWriter,
'_comments' . $i,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments',
'../comments' . $pWorksheetId . '.xml'
'../comments' . $worksheetId . '.xml'
);
}
// Write header/footer relationship?
$i = 1;
if (count($pWorksheet->getHeaderFooter()->getImages()) > 0) {
if (count($worksheet->getHeaderFooter()->getImages()) > 0) {
$this->writeRelationship(
$objWriter,
'_headerfooter_vml' . $i,
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing',
'../drawings/vmlDrawingHF' . $pWorksheetId . '.vml'
'../drawings/vmlDrawingHF' . $worksheetId . '.vml'
);
}
$this->writeUnparsedRelationship($pWorksheet, $objWriter, 'ctrlProps', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp');
$this->writeUnparsedRelationship($pWorksheet, $objWriter, 'vmlDrawings', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing');
$this->writeUnparsedRelationship($pWorksheet, $objWriter, 'printerSettings', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings');
$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');
$objWriter->endElement();
return $objWriter->getData();
}
private function writeUnparsedRelationship(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet, XMLWriter $objWriter, $relationship, $type): void
private function writeUnparsedRelationship(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet, XMLWriter $objWriter, $relationship, $type): void
{
$unparsedLoadedData = $pWorksheet->getParent()->getUnparsedLoadedData();
if (!isset($unparsedLoadedData['sheets'][$pWorksheet->getCodeName()][$relationship])) {
$unparsedLoadedData = $worksheet->getParent()->getUnparsedLoadedData();
if (!isset($unparsedLoadedData['sheets'][$worksheet->getCodeName()][$relationship])) {
return;
}
foreach ($unparsedLoadedData['sheets'][$pWorksheet->getCodeName()][$relationship] as $rId => $value) {
foreach ($unparsedLoadedData['sheets'][$worksheet->getCodeName()][$relationship] as $rId => $value) {
$this->writeRelationship(
$objWriter,
$rId,
@ -296,7 +296,7 @@ class Rels extends WriterPart
*
* @return string XML Output
*/
public function writeDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet, &$chartRef, $includeCharts = false)
public function writeDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet, &$chartRef, $includeCharts = false)
{
// Create XML writer
$objWriter = null;
@ -315,7 +315,7 @@ class Rels extends WriterPart
// Loop through images and write relationships
$i = 1;
$iterator = $pWorksheet->getDrawingCollection()->getIterator();
$iterator = $worksheet->getDrawingCollection()->getIterator();
while ($iterator->valid()) {
if (
$iterator->current() instanceof \PhpOffice\PhpSpreadsheet\Worksheet\Drawing
@ -340,7 +340,7 @@ class Rels extends WriterPart
if ($includeCharts) {
// Loop through charts and write relationships
$chartCount = $pWorksheet->getChartCount();
$chartCount = $worksheet->getChartCount();
if ($chartCount > 0) {
for ($c = 0; $c < $chartCount; ++$c) {
$this->writeRelationship(
@ -363,7 +363,7 @@ class Rels extends WriterPart
*
* @return string XML Output
*/
public function writeHeaderFooterDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet)
public function writeHeaderFooterDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet)
{
// Create XML writer
$objWriter = null;
@ -381,7 +381,7 @@ class Rels extends WriterPart
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
// Loop through images and write relationships
foreach ($pWorksheet->getHeaderFooter()->getImages() as $key => $value) {
foreach ($worksheet->getHeaderFooter()->getImages() as $key => $value) {
// Write relationship for image drawing
$this->writeRelationship(
$objWriter,
@ -400,22 +400,22 @@ class Rels extends WriterPart
* Write Override content type.
*
* @param XMLWriter $objWriter XML Writer
* @param int $pId Relationship ID. rId will be prepended!
* @param string $pType Relationship type
* @param string $pTarget Relationship target
* @param string $pTargetMode Relationship target mode
* @param int $id Relationship ID. rId will be prepended!
* @param string $type Relationship type
* @param string $target Relationship target
* @param string $targetMode Relationship target mode
*/
private function writeRelationship(XMLWriter $objWriter, $pId, $pType, $pTarget, $pTargetMode = ''): void
private function writeRelationship(XMLWriter $objWriter, $id, $type, $target, $targetMode = ''): void
{
if ($pType != '' && $pTarget != '') {
if ($type != '' && $target != '') {
// Write relationship
$objWriter->startElement('Relationship');
$objWriter->writeAttribute('Id', 'rId' . $pId);
$objWriter->writeAttribute('Type', $pType);
$objWriter->writeAttribute('Target', $pTarget);
$objWriter->writeAttribute('Id', 'rId' . $id);
$objWriter->writeAttribute('Type', $type);
$objWriter->writeAttribute('Target', $target);
if ($pTargetMode != '') {
$objWriter->writeAttribute('TargetMode', $pTargetMode);
if ($targetMode != '') {
$objWriter->writeAttribute('TargetMode', $targetMode);
}
$objWriter->endElement();

View File

@ -63,11 +63,11 @@ class StringTable extends WriterPart
/**
* Write string table to XML format.
*
* @param string[] $pStringTable
* @param string[] $stringTable
*
* @return string XML Output
*/
public function writeStringTable(array $pStringTable)
public function writeStringTable(array $stringTable)
{
// Create XML writer
$objWriter = null;
@ -83,10 +83,10 @@ class StringTable extends WriterPart
// String table
$objWriter->startElement('sst');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
$objWriter->writeAttribute('uniqueCount', count($pStringTable));
$objWriter->writeAttribute('uniqueCount', count($stringTable));
// Loop through string table
foreach ($pStringTable as $textElement) {
foreach ($stringTable as $textElement) {
$objWriter->startElement('si');
if (!$textElement instanceof RichText) {
@ -113,17 +113,17 @@ class StringTable extends WriterPart
* Write Rich Text.
*
* @param XMLWriter $objWriter XML Writer
* @param RichText $pRichText Rich text
* @param RichText $richText Rich text
* @param string $prefix Optional Namespace prefix
*/
public function writeRichText(XMLWriter $objWriter, RichText $pRichText, $prefix = null): void
public function writeRichText(XMLWriter $objWriter, RichText $richText, $prefix = null): void
{
if ($prefix !== null) {
$prefix .= ':';
}
// Loop through rich text elements
$elements = $pRichText->getRichTextElements();
$elements = $richText->getRichTextElements();
foreach ($elements as $element) {
// r
$objWriter->startElement($prefix . 'r');
@ -196,15 +196,15 @@ class StringTable extends WriterPart
* Write Rich Text.
*
* @param XMLWriter $objWriter XML Writer
* @param RichText|string $pRichText text string or Rich text
* @param RichText|string $richText text string or Rich text
* @param string $prefix Optional Namespace prefix
*/
public function writeRichTextForCharts(XMLWriter $objWriter, $pRichText = null, $prefix = null): void
public function writeRichTextForCharts(XMLWriter $objWriter, $richText = null, $prefix = null): void
{
if (!$pRichText instanceof RichText) {
$textRun = $pRichText;
$pRichText = new RichText();
$pRichText->createTextRun($textRun);
if (!$richText instanceof RichText) {
$textRun = $richText;
$richText = new RichText();
$richText->createTextRun($textRun);
}
if ($prefix !== null) {
@ -212,7 +212,7 @@ class StringTable extends WriterPart
}
// Loop through rich text elements
$elements = $pRichText->getRichTextElements();
$elements = $richText->getRichTextElements();
foreach ($elements as $element) {
// r
$objWriter->startElement($prefix . 'r');

View File

@ -147,20 +147,20 @@ class Style extends WriterPart
* Write Fill.
*
* @param XMLWriter $objWriter XML Writer
* @param Fill $pFill Fill style
* @param Fill $fill Fill style
*/
private function writeFill(XMLWriter $objWriter, Fill $pFill): void
private function writeFill(XMLWriter $objWriter, Fill $fill): void
{
// Check if this is a pattern type or gradient type
if (
$pFill->getFillType() === Fill::FILL_GRADIENT_LINEAR ||
$pFill->getFillType() === Fill::FILL_GRADIENT_PATH
$fill->getFillType() === Fill::FILL_GRADIENT_LINEAR ||
$fill->getFillType() === Fill::FILL_GRADIENT_PATH
) {
// Gradient fill
$this->writeGradientFill($objWriter, $pFill);
} elseif ($pFill->getFillType() !== null) {
$this->writeGradientFill($objWriter, $fill);
} elseif ($fill->getFillType() !== null) {
// Pattern fill
$this->writePatternFill($objWriter, $pFill);
$this->writePatternFill($objWriter, $fill);
}
}
@ -168,17 +168,17 @@ class Style extends WriterPart
* Write Gradient Fill.
*
* @param XMLWriter $objWriter XML Writer
* @param Fill $pFill Fill style
* @param Fill $fill Fill style
*/
private function writeGradientFill(XMLWriter $objWriter, Fill $pFill): void
private function writeGradientFill(XMLWriter $objWriter, Fill $fill): void
{
// fill
$objWriter->startElement('fill');
// gradientFill
$objWriter->startElement('gradientFill');
$objWriter->writeAttribute('type', $pFill->getFillType());
$objWriter->writeAttribute('degree', $pFill->getRotation());
$objWriter->writeAttribute('type', $fill->getFillType());
$objWriter->writeAttribute('degree', $fill->getRotation());
// stop
$objWriter->startElement('stop');
@ -186,7 +186,7 @@ class Style extends WriterPart
// color
$objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pFill->getStartColor()->getARGB());
$objWriter->writeAttribute('rgb', $fill->getStartColor()->getARGB());
$objWriter->endElement();
$objWriter->endElement();
@ -197,7 +197,7 @@ class Style extends WriterPart
// color
$objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pFill->getEndColor()->getARGB());
$objWriter->writeAttribute('rgb', $fill->getEndColor()->getARGB());
$objWriter->endElement();
$objWriter->endElement();
@ -211,30 +211,30 @@ class Style extends WriterPart
* Write Pattern Fill.
*
* @param XMLWriter $objWriter XML Writer
* @param Fill $pFill Fill style
* @param Fill $fill Fill style
*/
private function writePatternFill(XMLWriter $objWriter, Fill $pFill): void
private function writePatternFill(XMLWriter $objWriter, Fill $fill): void
{
// fill
$objWriter->startElement('fill');
// patternFill
$objWriter->startElement('patternFill');
$objWriter->writeAttribute('patternType', $pFill->getFillType());
$objWriter->writeAttribute('patternType', $fill->getFillType());
if ($pFill->getFillType() !== Fill::FILL_NONE) {
if ($fill->getFillType() !== Fill::FILL_NONE) {
// fgColor
if ($pFill->getStartColor()->getARGB()) {
if ($fill->getStartColor()->getARGB()) {
$objWriter->startElement('fgColor');
$objWriter->writeAttribute('rgb', $pFill->getStartColor()->getARGB());
$objWriter->writeAttribute('rgb', $fill->getStartColor()->getARGB());
$objWriter->endElement();
}
}
if ($pFill->getFillType() !== Fill::FILL_NONE) {
if ($fill->getFillType() !== Fill::FILL_NONE) {
// bgColor
if ($pFill->getEndColor()->getARGB()) {
if ($fill->getEndColor()->getARGB()) {
$objWriter->startElement('bgColor');
$objWriter->writeAttribute('rgb', $pFill->getEndColor()->getARGB());
$objWriter->writeAttribute('rgb', $fill->getEndColor()->getARGB());
$objWriter->endElement();
}
}
@ -248,9 +248,9 @@ class Style extends WriterPart
* Write Font.
*
* @param XMLWriter $objWriter XML Writer
* @param Font $pFont Font style
* @param Font $font Font style
*/
private function writeFont(XMLWriter $objWriter, Font $pFont): void
private function writeFont(XMLWriter $objWriter, Font $font): void
{
// font
$objWriter->startElement('font');
@ -261,62 +261,62 @@ class Style extends WriterPart
// Bold. We explicitly write this element also when false (like MS Office Excel 2007 does
// for conditional formatting). Otherwise it will apparently not be picked up in conditional
// formatting style dialog
if ($pFont->getBold() !== null) {
if ($font->getBold() !== null) {
$objWriter->startElement('b');
$objWriter->writeAttribute('val', $pFont->getBold() ? '1' : '0');
$objWriter->writeAttribute('val', $font->getBold() ? '1' : '0');
$objWriter->endElement();
}
// Italic
if ($pFont->getItalic() !== null) {
if ($font->getItalic() !== null) {
$objWriter->startElement('i');
$objWriter->writeAttribute('val', $pFont->getItalic() ? '1' : '0');
$objWriter->writeAttribute('val', $font->getItalic() ? '1' : '0');
$objWriter->endElement();
}
// Strikethrough
if ($pFont->getStrikethrough() !== null) {
if ($font->getStrikethrough() !== null) {
$objWriter->startElement('strike');
$objWriter->writeAttribute('val', $pFont->getStrikethrough() ? '1' : '0');
$objWriter->writeAttribute('val', $font->getStrikethrough() ? '1' : '0');
$objWriter->endElement();
}
// Underline
if ($pFont->getUnderline() !== null) {
if ($font->getUnderline() !== null) {
$objWriter->startElement('u');
$objWriter->writeAttribute('val', $pFont->getUnderline());
$objWriter->writeAttribute('val', $font->getUnderline());
$objWriter->endElement();
}
// Superscript / subscript
if ($pFont->getSuperscript() === true || $pFont->getSubscript() === true) {
if ($font->getSuperscript() === true || $font->getSubscript() === true) {
$objWriter->startElement('vertAlign');
if ($pFont->getSuperscript() === true) {
if ($font->getSuperscript() === true) {
$objWriter->writeAttribute('val', 'superscript');
} elseif ($pFont->getSubscript() === true) {
} elseif ($font->getSubscript() === true) {
$objWriter->writeAttribute('val', 'subscript');
}
$objWriter->endElement();
}
// Size
if ($pFont->getSize() !== null) {
if ($font->getSize() !== null) {
$objWriter->startElement('sz');
$objWriter->writeAttribute('val', StringHelper::formatNumber($pFont->getSize()));
$objWriter->writeAttribute('val', StringHelper::formatNumber($font->getSize()));
$objWriter->endElement();
}
// Foreground color
if ($pFont->getColor()->getARGB() !== null) {
if ($font->getColor()->getARGB() !== null) {
$objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pFont->getColor()->getARGB());
$objWriter->writeAttribute('rgb', $font->getColor()->getARGB());
$objWriter->endElement();
}
// Name
if ($pFont->getName() !== null) {
if ($font->getName() !== null) {
$objWriter->startElement('name');
$objWriter->writeAttribute('val', $pFont->getName());
$objWriter->writeAttribute('val', $font->getName());
$objWriter->endElement();
}
@ -327,14 +327,14 @@ class Style extends WriterPart
* Write Border.
*
* @param XMLWriter $objWriter XML Writer
* @param Borders $pBorders Borders style
* @param Borders $borders Borders style
*/
private function writeBorder(XMLWriter $objWriter, Borders $pBorders): void
private function writeBorder(XMLWriter $objWriter, Borders $borders): void
{
// Write border
$objWriter->startElement('border');
// Diagonal?
switch ($pBorders->getDiagonalDirection()) {
switch ($borders->getDiagonalDirection()) {
case Borders::DIAGONAL_UP:
$objWriter->writeAttribute('diagonalUp', 'true');
$objWriter->writeAttribute('diagonalDown', 'false');
@ -353,11 +353,11 @@ class Style extends WriterPart
}
// BorderPr
$this->writeBorderPr($objWriter, 'left', $pBorders->getLeft());
$this->writeBorderPr($objWriter, 'right', $pBorders->getRight());
$this->writeBorderPr($objWriter, 'top', $pBorders->getTop());
$this->writeBorderPr($objWriter, 'bottom', $pBorders->getBottom());
$this->writeBorderPr($objWriter, 'diagonal', $pBorders->getDiagonal());
$this->writeBorderPr($objWriter, 'left', $borders->getLeft());
$this->writeBorderPr($objWriter, 'right', $borders->getRight());
$this->writeBorderPr($objWriter, 'top', $borders->getTop());
$this->writeBorderPr($objWriter, 'bottom', $borders->getBottom());
$this->writeBorderPr($objWriter, 'diagonal', $borders->getDiagonal());
$objWriter->endElement();
}
@ -365,70 +365,70 @@ class Style extends WriterPart
* Write Cell Style Xf.
*
* @param XMLWriter $objWriter XML Writer
* @param \PhpOffice\PhpSpreadsheet\Style\Style $pStyle Style
* @param \PhpOffice\PhpSpreadsheet\Style\Style $style Style
* @param Spreadsheet $spreadsheet Workbook
*/
private function writeCellStyleXf(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Style $pStyle, Spreadsheet $spreadsheet): void
private function writeCellStyleXf(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Style $style, Spreadsheet $spreadsheet): void
{
// xf
$objWriter->startElement('xf');
$objWriter->writeAttribute('xfId', 0);
$objWriter->writeAttribute('fontId', (int) $this->getParentWriter()->getFontHashTable()->getIndexForHashCode($pStyle->getFont()->getHashCode()));
if ($pStyle->getQuotePrefix()) {
$objWriter->writeAttribute('fontId', (int) $this->getParentWriter()->getFontHashTable()->getIndexForHashCode($style->getFont()->getHashCode()));
if ($style->getQuotePrefix()) {
$objWriter->writeAttribute('quotePrefix', 1);
}
if ($pStyle->getNumberFormat()->getBuiltInFormatCode() === false) {
$objWriter->writeAttribute('numFmtId', (int) ($this->getParentWriter()->getNumFmtHashTable()->getIndexForHashCode($pStyle->getNumberFormat()->getHashCode()) + 164));
if ($style->getNumberFormat()->getBuiltInFormatCode() === false) {
$objWriter->writeAttribute('numFmtId', (int) ($this->getParentWriter()->getNumFmtHashTable()->getIndexForHashCode($style->getNumberFormat()->getHashCode()) + 164));
} else {
$objWriter->writeAttribute('numFmtId', (int) $pStyle->getNumberFormat()->getBuiltInFormatCode());
$objWriter->writeAttribute('numFmtId', (int) $style->getNumberFormat()->getBuiltInFormatCode());
}
$objWriter->writeAttribute('fillId', (int) $this->getParentWriter()->getFillHashTable()->getIndexForHashCode($pStyle->getFill()->getHashCode()));
$objWriter->writeAttribute('borderId', (int) $this->getParentWriter()->getBordersHashTable()->getIndexForHashCode($pStyle->getBorders()->getHashCode()));
$objWriter->writeAttribute('fillId', (int) $this->getParentWriter()->getFillHashTable()->getIndexForHashCode($style->getFill()->getHashCode()));
$objWriter->writeAttribute('borderId', (int) $this->getParentWriter()->getBordersHashTable()->getIndexForHashCode($style->getBorders()->getHashCode()));
// Apply styles?
$objWriter->writeAttribute('applyFont', ($spreadsheet->getDefaultStyle()->getFont()->getHashCode() != $pStyle->getFont()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyNumberFormat', ($spreadsheet->getDefaultStyle()->getNumberFormat()->getHashCode() != $pStyle->getNumberFormat()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyFill', ($spreadsheet->getDefaultStyle()->getFill()->getHashCode() != $pStyle->getFill()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyBorder', ($spreadsheet->getDefaultStyle()->getBorders()->getHashCode() != $pStyle->getBorders()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyAlignment', ($spreadsheet->getDefaultStyle()->getAlignment()->getHashCode() != $pStyle->getAlignment()->getHashCode()) ? '1' : '0');
if ($pStyle->getProtection()->getLocked() != Protection::PROTECTION_INHERIT || $pStyle->getProtection()->getHidden() != Protection::PROTECTION_INHERIT) {
$objWriter->writeAttribute('applyFont', ($spreadsheet->getDefaultStyle()->getFont()->getHashCode() != $style->getFont()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyNumberFormat', ($spreadsheet->getDefaultStyle()->getNumberFormat()->getHashCode() != $style->getNumberFormat()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyFill', ($spreadsheet->getDefaultStyle()->getFill()->getHashCode() != $style->getFill()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyBorder', ($spreadsheet->getDefaultStyle()->getBorders()->getHashCode() != $style->getBorders()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyAlignment', ($spreadsheet->getDefaultStyle()->getAlignment()->getHashCode() != $style->getAlignment()->getHashCode()) ? '1' : '0');
if ($style->getProtection()->getLocked() != Protection::PROTECTION_INHERIT || $style->getProtection()->getHidden() != Protection::PROTECTION_INHERIT) {
$objWriter->writeAttribute('applyProtection', 'true');
}
// alignment
$objWriter->startElement('alignment');
$objWriter->writeAttribute('horizontal', $pStyle->getAlignment()->getHorizontal());
$objWriter->writeAttribute('vertical', $pStyle->getAlignment()->getVertical());
$objWriter->writeAttribute('horizontal', $style->getAlignment()->getHorizontal());
$objWriter->writeAttribute('vertical', $style->getAlignment()->getVertical());
$textRotation = 0;
if ($pStyle->getAlignment()->getTextRotation() >= 0) {
$textRotation = $pStyle->getAlignment()->getTextRotation();
} elseif ($pStyle->getAlignment()->getTextRotation() < 0) {
$textRotation = 90 - $pStyle->getAlignment()->getTextRotation();
if ($style->getAlignment()->getTextRotation() >= 0) {
$textRotation = $style->getAlignment()->getTextRotation();
} elseif ($style->getAlignment()->getTextRotation() < 0) {
$textRotation = 90 - $style->getAlignment()->getTextRotation();
}
$objWriter->writeAttribute('textRotation', $textRotation);
$objWriter->writeAttribute('wrapText', ($pStyle->getAlignment()->getWrapText() ? 'true' : 'false'));
$objWriter->writeAttribute('shrinkToFit', ($pStyle->getAlignment()->getShrinkToFit() ? 'true' : 'false'));
$objWriter->writeAttribute('wrapText', ($style->getAlignment()->getWrapText() ? 'true' : 'false'));
$objWriter->writeAttribute('shrinkToFit', ($style->getAlignment()->getShrinkToFit() ? 'true' : 'false'));
if ($pStyle->getAlignment()->getIndent() > 0) {
$objWriter->writeAttribute('indent', $pStyle->getAlignment()->getIndent());
if ($style->getAlignment()->getIndent() > 0) {
$objWriter->writeAttribute('indent', $style->getAlignment()->getIndent());
}
if ($pStyle->getAlignment()->getReadOrder() > 0) {
$objWriter->writeAttribute('readingOrder', $pStyle->getAlignment()->getReadOrder());
if ($style->getAlignment()->getReadOrder() > 0) {
$objWriter->writeAttribute('readingOrder', $style->getAlignment()->getReadOrder());
}
$objWriter->endElement();
// protection
if ($pStyle->getProtection()->getLocked() != Protection::PROTECTION_INHERIT || $pStyle->getProtection()->getHidden() != Protection::PROTECTION_INHERIT) {
if ($style->getProtection()->getLocked() != Protection::PROTECTION_INHERIT || $style->getProtection()->getHidden() != Protection::PROTECTION_INHERIT) {
$objWriter->startElement('protection');
if ($pStyle->getProtection()->getLocked() != Protection::PROTECTION_INHERIT) {
$objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
if ($style->getProtection()->getLocked() != Protection::PROTECTION_INHERIT) {
$objWriter->writeAttribute('locked', ($style->getProtection()->getLocked() == Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
}
if ($pStyle->getProtection()->getHidden() != Protection::PROTECTION_INHERIT) {
$objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
if ($style->getProtection()->getHidden() != Protection::PROTECTION_INHERIT) {
$objWriter->writeAttribute('hidden', ($style->getProtection()->getHidden() == Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
}
$objWriter->endElement();
}
@ -440,63 +440,63 @@ class Style extends WriterPart
* Write Cell Style Dxf.
*
* @param XMLWriter $objWriter XML Writer
* @param \PhpOffice\PhpSpreadsheet\Style\Style $pStyle Style
* @param \PhpOffice\PhpSpreadsheet\Style\Style $style Style
*/
private function writeCellStyleDxf(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Style $pStyle): void
private function writeCellStyleDxf(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Style $style): void
{
// dxf
$objWriter->startElement('dxf');
// font
$this->writeFont($objWriter, $pStyle->getFont());
$this->writeFont($objWriter, $style->getFont());
// numFmt
$this->writeNumFmt($objWriter, $pStyle->getNumberFormat());
$this->writeNumFmt($objWriter, $style->getNumberFormat());
// fill
$this->writeFill($objWriter, $pStyle->getFill());
$this->writeFill($objWriter, $style->getFill());
// alignment
$objWriter->startElement('alignment');
if ($pStyle->getAlignment()->getHorizontal() !== null) {
$objWriter->writeAttribute('horizontal', $pStyle->getAlignment()->getHorizontal());
if ($style->getAlignment()->getHorizontal() !== null) {
$objWriter->writeAttribute('horizontal', $style->getAlignment()->getHorizontal());
}
if ($pStyle->getAlignment()->getVertical() !== null) {
$objWriter->writeAttribute('vertical', $pStyle->getAlignment()->getVertical());
if ($style->getAlignment()->getVertical() !== null) {
$objWriter->writeAttribute('vertical', $style->getAlignment()->getVertical());
}
if ($pStyle->getAlignment()->getTextRotation() !== null) {
if ($style->getAlignment()->getTextRotation() !== null) {
$textRotation = 0;
if ($pStyle->getAlignment()->getTextRotation() >= 0) {
$textRotation = $pStyle->getAlignment()->getTextRotation();
} elseif ($pStyle->getAlignment()->getTextRotation() < 0) {
$textRotation = 90 - $pStyle->getAlignment()->getTextRotation();
if ($style->getAlignment()->getTextRotation() >= 0) {
$textRotation = $style->getAlignment()->getTextRotation();
} elseif ($style->getAlignment()->getTextRotation() < 0) {
$textRotation = 90 - $style->getAlignment()->getTextRotation();
}
$objWriter->writeAttribute('textRotation', $textRotation);
}
$objWriter->endElement();
// border
$this->writeBorder($objWriter, $pStyle->getBorders());
$this->writeBorder($objWriter, $style->getBorders());
// protection
if (($pStyle->getProtection()->getLocked() !== null) || ($pStyle->getProtection()->getHidden() !== null)) {
if (($style->getProtection()->getLocked() !== null) || ($style->getProtection()->getHidden() !== null)) {
if (
$pStyle->getProtection()->getLocked() !== Protection::PROTECTION_INHERIT ||
$pStyle->getProtection()->getHidden() !== Protection::PROTECTION_INHERIT
$style->getProtection()->getLocked() !== Protection::PROTECTION_INHERIT ||
$style->getProtection()->getHidden() !== Protection::PROTECTION_INHERIT
) {
$objWriter->startElement('protection');
if (
($pStyle->getProtection()->getLocked() !== null) &&
($pStyle->getProtection()->getLocked() !== Protection::PROTECTION_INHERIT)
($style->getProtection()->getLocked() !== null) &&
($style->getProtection()->getLocked() !== Protection::PROTECTION_INHERIT)
) {
$objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
$objWriter->writeAttribute('locked', ($style->getProtection()->getLocked() == Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
}
if (
($pStyle->getProtection()->getHidden() !== null) &&
($pStyle->getProtection()->getHidden() !== Protection::PROTECTION_INHERIT)
($style->getProtection()->getHidden() !== null) &&
($style->getProtection()->getHidden() !== Protection::PROTECTION_INHERIT)
) {
$objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
$objWriter->writeAttribute('hidden', ($style->getProtection()->getHidden() == Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
}
$objWriter->endElement();
}
@ -509,19 +509,19 @@ class Style extends WriterPart
* Write BorderPr.
*
* @param XMLWriter $objWriter XML Writer
* @param string $pName Element name
* @param Border $pBorder Border style
* @param string $name Element name
* @param Border $border Border style
*/
private function writeBorderPr(XMLWriter $objWriter, $pName, Border $pBorder): void
private function writeBorderPr(XMLWriter $objWriter, $name, Border $border): void
{
// Write BorderPr
if ($pBorder->getBorderStyle() != Border::BORDER_NONE) {
$objWriter->startElement($pName);
$objWriter->writeAttribute('style', $pBorder->getBorderStyle());
if ($border->getBorderStyle() != Border::BORDER_NONE) {
$objWriter->startElement($name);
$objWriter->writeAttribute('style', $border->getBorderStyle());
// color
$objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pBorder->getColor()->getARGB());
$objWriter->writeAttribute('rgb', $border->getColor()->getARGB());
$objWriter->endElement();
$objWriter->endElement();
@ -532,18 +532,18 @@ class Style extends WriterPart
* Write NumberFormat.
*
* @param XMLWriter $objWriter XML Writer
* @param NumberFormat $pNumberFormat Number Format
* @param int $pId Number Format identifier
* @param NumberFormat $numberFormat Number Format
* @param int $id Number Format identifier
*/
private function writeNumFmt(XMLWriter $objWriter, NumberFormat $pNumberFormat, $pId = 0): void
private function writeNumFmt(XMLWriter $objWriter, NumberFormat $numberFormat, $id = 0): void
{
// Translate formatcode
$formatCode = $pNumberFormat->getFormatCode();
$formatCode = $numberFormat->getFormatCode();
// numFmt
if ($formatCode !== null) {
$objWriter->startElement('numFmt');
$objWriter->writeAttribute('numFmtId', ($pId + 164));
$objWriter->writeAttribute('numFmtId', ($id + 164));
$objWriter->writeAttribute('formatCode', $formatCode);
$objWriter->endElement();
}

View File

@ -21,12 +21,12 @@ class Worksheet extends WriterPart
/**
* Write worksheet to XML format.
*
* @param string[] $pStringTable
* @param string[] $stringTable
* @param bool $includeCharts Flag indicating if we should write charts
*
* @return string XML Output
*/
public function writeWorksheet(PhpspreadsheetWorksheet $worksheet, $pStringTable = null, $includeCharts = false)
public function writeWorksheet(PhpspreadsheetWorksheet $worksheet, $stringTable = null, $includeCharts = false)
{
// Create XML writer
$objWriter = null;
@ -68,7 +68,7 @@ class Worksheet extends WriterPart
$this->writeCols($objWriter, $worksheet);
// sheetData
$this->writeSheetData($objWriter, $worksheet, $pStringTable);
$this->writeSheetData($objWriter, $worksheet, $stringTable);
// sheetProtection
$this->writeSheetProtection($objWriter, $worksheet);
@ -1100,12 +1100,12 @@ class Worksheet extends WriterPart
*
* @param XMLWriter $objWriter XML Writer
* @param PhpspreadsheetWorksheet $worksheet Worksheet
* @param string[] $pStringTable String table
* @param string[] $stringTable String table
*/
private function writeSheetData(XMLWriter $objWriter, PhpspreadsheetWorksheet $worksheet, array $pStringTable): void
private function writeSheetData(XMLWriter $objWriter, PhpspreadsheetWorksheet $worksheet, array $stringTable): void
{
// Flipped stringtable, for faster index searching
$aFlippedStringTable = $this->getParentWriter()->getWriterPartstringtable()->flipStringTable($pStringTable);
$aFlippedStringTable = $this->getParentWriter()->getWriterPartstringtable()->flipStringTable($stringTable);
// sheetData
$objWriter->startElement('sheetData');
@ -1200,15 +1200,15 @@ class Worksheet extends WriterPart
/**
* @param RichText|string $cellValue
* @param string[] $pFlippedStringTable
* @param string[] $flippedStringTable
*/
private function writeCellString(XMLWriter $objWriter, string $mappedType, $cellValue, array $pFlippedStringTable): void
private function writeCellString(XMLWriter $objWriter, string $mappedType, $cellValue, array $flippedStringTable): void
{
$objWriter->writeAttribute('t', $mappedType);
if (!$cellValue instanceof RichText) {
self::writeElementIf($objWriter, isset($pFlippedStringTable[$cellValue]), 'v', $pFlippedStringTable[$cellValue] ?? '');
self::writeElementIf($objWriter, isset($flippedStringTable[$cellValue]), 'v', $flippedStringTable[$cellValue] ?? '');
} else {
$objWriter->writeElement('v', $pFlippedStringTable[$cellValue->getHashCode()]);
$objWriter->writeElement('v', $flippedStringTable[$cellValue->getHashCode()]);
}
}
@ -1286,9 +1286,9 @@ class Worksheet extends WriterPart
* @param XMLWriter $objWriter XML Writer
* @param PhpspreadsheetWorksheet $worksheet Worksheet
* @param string $cellAddress Cell Address
* @param string[] $pFlippedStringTable String table (flipped), for faster index searching
* @param string[] $flippedStringTable String table (flipped), for faster index searching
*/
private function writeCell(XMLWriter $objWriter, PhpspreadsheetWorksheet $worksheet, string $cellAddress, array $pFlippedStringTable): void
private function writeCell(XMLWriter $objWriter, PhpspreadsheetWorksheet $worksheet, string $cellAddress, array $flippedStringTable): void
{
// Cell
$pCell = $worksheet->getCell($cellAddress);
@ -1312,7 +1312,7 @@ class Worksheet extends WriterPart
break;
case 's': // String
$this->writeCellString($objWriter, $mappedType, $cellValue, $pFlippedStringTable);
$this->writeCellString($objWriter, $mappedType, $cellValue, $flippedStringTable);
break;
case 'f': // Formula

View File

@ -26,8 +26,8 @@ abstract class WriterPart
/**
* Set parent Xlsx object.
*/
public function __construct(Xlsx $pWriter)
public function __construct(Xlsx $writer)
{
$this->parentWriter = $pWriter;
$this->parentWriter = $writer;
}
}