diff --git a/src/PhpSpreadsheet/Cell/Cell.php b/src/PhpSpreadsheet/Cell/Cell.php index ae075003..ac14573f 100644 --- a/src/PhpSpreadsheet/Cell/Cell.php +++ b/src/PhpSpreadsheet/Cell/Cell.php @@ -6,7 +6,8 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Collection\Cells; use PhpOffice\PhpSpreadsheet\Exception; use PhpOffice\PhpSpreadsheet\RichText\RichText; -use PhpOffice\PhpSpreadsheet\Style; +use PhpOffice\PhpSpreadsheet\Style\NumberFormat; +use PhpOffice\PhpSpreadsheet\Style\Style; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; class Cell @@ -167,7 +168,7 @@ class Cell */ public function getFormattedValue() { - return (string) Style\NumberFormat::toFormattedString( + return (string) NumberFormat::toFormattedString( $this->getCalculatedValue(), $this->getStyle() ->getNumberFormat()->getFormatCode() diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index d74de3e1..10a49c30 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -1343,7 +1343,7 @@ class Worksheet implements IComparable * Get row dimension at a specific row. * * @param int $pRow Numeric index of the row - * @param mixed $create + * @param bool $create * * @return RowDimension */ @@ -1369,7 +1369,7 @@ class Worksheet implements IComparable * Get column dimension at a specific column. * * @param string $pColumn String index of the column eg: 'A' - * @param mixed $create + * @param bool $create * * @return ColumnDimension */ @@ -1910,7 +1910,7 @@ class Worksheet implements IComparable /** * Set AutoFilter. * - * @param string|Worksheet\AutoFilter $pValue + * @param AutoFilter|string $pValue * A simple string containing a Cell range like 'A1:E10' is permitted for backward compatibility * * @throws Exception @@ -1919,7 +1919,6 @@ class Worksheet implements IComparable */ public function setAutoFilter($pValue) { - $pValue = strtoupper($pValue); if (is_string($pValue)) { $this->autoFilter->setRange($pValue); } elseif (is_object($pValue) && ($pValue instanceof AutoFilter)) { diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 44527bd1..33533f2c 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -1164,7 +1164,7 @@ class Html extends BaseWriter implements IWriter * @param Worksheet $pSheet \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet * @param array $pValues Array containing cells in a row * @param int $pRow Row number (0-based) - * @param mixed $cellType eg: 'td' + * @param string $cellType eg: 'td' * * @throws WriterException * diff --git a/src/PhpSpreadsheet/Writer/Ods/MetaInf.php b/src/PhpSpreadsheet/Writer/Ods/MetaInf.php index 7336b4ea..1ec9d1eb 100644 --- a/src/PhpSpreadsheet/Writer/Ods/MetaInf.php +++ b/src/PhpSpreadsheet/Writer/Ods/MetaInf.php @@ -3,7 +3,6 @@ namespace PhpOffice\PhpSpreadsheet\Writer\Ods; use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; -use PhpOffice\PhpSpreadsheet\Spreadsheet; class MetaInf extends WriterPart { diff --git a/src/PhpSpreadsheet/Writer/Xls/Workbook.php b/src/PhpSpreadsheet/Writer/Xls/Workbook.php index fa901981..d8cc0464 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xls/Workbook.php @@ -224,8 +224,8 @@ class Workbook extends BIFFwriter * * @param Style * @param bool Is it a style XF? - * @param mixed $style - * @param mixed $isStyleXf + * @param Style $style + * @param bool $isStyleXf * * @return int Index to XF record */ @@ -683,7 +683,7 @@ class Workbook extends BIFFwriter * * @param string $name The name in UTF-8 * @param string $formulaData The binary formula data - * @param string $sheetIndex 1-based sheet index the defined name applies to. 0 = global + * @param int $sheetIndex 1-based sheet index the defined name applies to. 0 = global * @param bool $isBuiltIn Built-in name? * * @return string Complete binary record data diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index 6e9d8fdf..47b0ff93 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -176,7 +176,7 @@ class Worksheet extends BIFFwriter /** * Sheet object. * - * @var Worksheet + * @var \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet */ public $phpSheet; @@ -214,16 +214,15 @@ class Worksheet extends BIFFwriter /** * Constructor. * - * @param int &$str_total Total number of strings - * @param int &$str_unique Total number of unique strings + * @param int $str_total Total number of strings + * @param int $str_unique Total number of unique strings * @param array &$str_table String Table * @param array &$colors Colour Table - * @param mixed $parser The formula parser created for the Workbook + * @param Parser $parser The formula parser created for the Workbook * @param bool $preCalculateFormulas Flag indicating whether formulas should be calculated or just written - * @param string $phpSheet The worksheet to write - * @param Worksheet $phpSheet + * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $phpSheet The worksheet to write */ - public function __construct(&$str_total, &$str_unique, &$str_table, &$colors, $parser, $preCalculateFormulas, $phpSheet) + public function __construct(&$str_total, &$str_unique, &$str_table, &$colors, Parser $parser, $preCalculateFormulas, \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $phpSheet) { // It needs to call its parent's constructor explicitly parent::__construct(); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php index 1d8e0bd8..f250cdda 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php @@ -204,7 +204,7 @@ class Chart extends WriterPart * Write Chart Plot Area. * * @param XMLWriter $objWriter XML Writer - * @param Worksheet $pSheet + * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet * @param PlotArea $plotArea * @param Title $xAxisLabel * @param Title $yAxisLabel @@ -394,11 +394,11 @@ class Chart extends WriterPart * @param string $id1 * @param string $id2 * @param bool $isMultiLevelSeries - * @param mixed $yAxis + * @param Axis $yAxis * * @throws WriterException */ - private function writeCategoryAxis($objWriter, $xAxisLabel, $id1, $id2, $isMultiLevelSeries, $yAxis) + private function writeCategoryAxis($objWriter, $xAxisLabel, $id1, $id2, $isMultiLevelSeries, Axis $yAxis) { $objWriter->startElement('c:catAx'); @@ -515,13 +515,13 @@ class Chart extends WriterPart * @param string $id1 * @param string $id2 * @param bool $isMultiLevelSeries - * @param mixed $xAxis - * @param mixed $majorGridlines - * @param mixed $minorGridlines + * @param Axis $xAxis + * @param GridLines $majorGridlines + * @param GridLines $minorGridlines * * @throws WriterException */ - private function writeValueAxis($objWriter, $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, $xAxis, $majorGridlines, $minorGridlines) + private function writeValueAxis($objWriter, $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, Axis $xAxis, GridLines $majorGridlines, GridLines $minorGridlines) { $objWriter->startElement('c:valAx'); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php index bb24c884..f1f0400f 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php @@ -11,7 +11,7 @@ class Comments extends WriterPart /** * Write comments to XML format. * - * @param Worksheet $pWorksheet + * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * @@ -94,7 +94,7 @@ class Comments extends WriterPart /** * Write VML comments to XML format. * - * @param Worksheet $pWorksheet + * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php b/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php index 3bf30588..b710e132 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php @@ -14,7 +14,7 @@ class Drawing extends WriterPart /** * Write drawings to XML format. * - * @param Worksheet $pWorksheet + * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet * @param bool $includeCharts Flag indicating if we should include drawing details for charts * * @throws WriterException @@ -271,7 +271,7 @@ class Drawing extends WriterPart /** * Write VML header/footer images to XML format. * - * @param Worksheet $pWorksheet + * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet * * @throws WriterException * diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php index 0d1610a1..e5d2aa53 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php @@ -168,7 +168,7 @@ class Rels extends WriterPart * rId1 - Drawings * rId_hyperlink_x - Hyperlinks * - * @param Worksheet $pWorksheet + * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet * @param int $pWorksheetId * @param bool $includeCharts Flag indicating if we should write charts * @@ -263,7 +263,7 @@ class Rels extends WriterPart /** * Write drawing relationships to XML format. * - * @param Worksheet $pWorksheet + * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet * @param int &$chartRef Chart ID * @param bool $includeCharts Flag indicating if we should write charts * @@ -330,7 +330,7 @@ class Rels extends WriterPart /** * Write header/footer drawing relationships to XML format. * - * @param Worksheet $pWorksheet + * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet * * @throws WriterException * diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index 12668079..3a2ceabe 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -31,96 +31,92 @@ class Worksheet extends WriterPart * * @return string XML Output */ - public function writeWorksheet($pSheet = null, $pStringTable = null, $includeCharts = false) + public function writeWorksheet(PhpspreadsheetWorksheet $pSheet, $pStringTable = null, $includeCharts = false) { - if ($pSheet !== null) { - // Create XML writer - $objWriter = null; - if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $objWriter->startDocument('1.0', 'UTF-8', 'yes'); - - // Worksheet - $objWriter->startElement('worksheet'); - $objWriter->writeAttribute('xml:space', 'preserve'); - $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); - $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - - // sheetPr - $this->writeSheetPr($objWriter, $pSheet); - - // Dimension - $this->writeDimension($objWriter, $pSheet); - - // sheetViews - $this->writeSheetViews($objWriter, $pSheet); - - // sheetFormatPr - $this->writeSheetFormatPr($objWriter, $pSheet); - - // cols - $this->writeCols($objWriter, $pSheet); - - // sheetData - $this->writeSheetData($objWriter, $pSheet, $pStringTable); - - // sheetProtection - $this->writeSheetProtection($objWriter, $pSheet); - - // protectedRanges - $this->writeProtectedRanges($objWriter, $pSheet); - - // autoFilter - $this->writeAutoFilter($objWriter, $pSheet); - - // mergeCells - $this->writeMergeCells($objWriter, $pSheet); - - // conditionalFormatting - $this->writeConditionalFormatting($objWriter, $pSheet); - - // dataValidations - $this->writeDataValidations($objWriter, $pSheet); - - // hyperlinks - $this->writeHyperlinks($objWriter, $pSheet); - - // Print options - $this->writePrintOptions($objWriter, $pSheet); - - // Page margins - $this->writePageMargins($objWriter, $pSheet); - - // Page setup - $this->writePageSetup($objWriter, $pSheet); - - // Header / footer - $this->writeHeaderFooter($objWriter, $pSheet); - - // Breaks - $this->writeBreaks($objWriter, $pSheet); - - // Drawings and/or Charts - $this->writeDrawings($objWriter, $pSheet, $includeCharts); - - // LegacyDrawing - $this->writeLegacyDrawing($objWriter, $pSheet); - - // LegacyDrawingHF - $this->writeLegacyDrawingHF($objWriter, $pSheet); - - $objWriter->endElement(); - - // Return - return $objWriter->getData(); + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } - throw new WriterException('Invalid \\PhpOffice\\PhpSpreadsheet\\Worksheet\\Worksheet object passed.'); + // XML header + $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + + // Worksheet + $objWriter->startElement('worksheet'); + $objWriter->writeAttribute('xml:space', 'preserve'); + $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); + $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + + // sheetPr + $this->writeSheetPr($objWriter, $pSheet); + + // Dimension + $this->writeDimension($objWriter, $pSheet); + + // sheetViews + $this->writeSheetViews($objWriter, $pSheet); + + // sheetFormatPr + $this->writeSheetFormatPr($objWriter, $pSheet); + + // cols + $this->writeCols($objWriter, $pSheet); + + // sheetData + $this->writeSheetData($objWriter, $pSheet, $pStringTable); + + // sheetProtection + $this->writeSheetProtection($objWriter, $pSheet); + + // protectedRanges + $this->writeProtectedRanges($objWriter, $pSheet); + + // autoFilter + $this->writeAutoFilter($objWriter, $pSheet); + + // mergeCells + $this->writeMergeCells($objWriter, $pSheet); + + // conditionalFormatting + $this->writeConditionalFormatting($objWriter, $pSheet); + + // dataValidations + $this->writeDataValidations($objWriter, $pSheet); + + // hyperlinks + $this->writeHyperlinks($objWriter, $pSheet); + + // Print options + $this->writePrintOptions($objWriter, $pSheet); + + // Page margins + $this->writePageMargins($objWriter, $pSheet); + + // Page setup + $this->writePageSetup($objWriter, $pSheet); + + // Header / footer + $this->writeHeaderFooter($objWriter, $pSheet); + + // Breaks + $this->writeBreaks($objWriter, $pSheet); + + // Drawings and/or Charts + $this->writeDrawings($objWriter, $pSheet, $includeCharts); + + // LegacyDrawing + $this->writeLegacyDrawing($objWriter, $pSheet); + + // LegacyDrawingHF + $this->writeLegacyDrawingHF($objWriter, $pSheet); + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); } /** @@ -531,7 +527,7 @@ class Worksheet extends WriterPart * Write DataValidations. * * @param XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet\PhpspreadsheetWorksheet $pSheet Worksheet + * @param PhpspreadsheetWorksheet $pSheet Worksheet * * @throws WriterException */ @@ -697,7 +693,7 @@ class Worksheet extends WriterPart * Write PrintOptions. * * @param XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet\PhpspreadsheetWorksheet $pSheet Worksheet + * @param PhpspreadsheetWorksheet $pSheet Worksheet * * @throws WriterException */ @@ -724,7 +720,7 @@ class Worksheet extends WriterPart * Write PageMargins. * * @param XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet\PhpspreadsheetWorksheet $pSheet Worksheet + * @param PhpspreadsheetWorksheet $pSheet Worksheet * * @throws WriterException */ @@ -901,7 +897,7 @@ class Worksheet extends WriterPart * Write Breaks. * * @param XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet\PhpspreadsheetWorksheet $pSheet Worksheet + * @param PhpspreadsheetWorksheet $pSheet Worksheet * * @throws WriterException */ @@ -1048,7 +1044,6 @@ class Worksheet extends WriterPart * @param XMLWriter $objWriter XML Writer * @param PhpspreadsheetWorksheet $pSheet Worksheet * @param Cell $pCellAddress Cell Address - * @param string[] $pStringTable String table * @param string[] $pFlippedStringTable String table (flipped), for faster index searching * * @throws WriterException @@ -1167,7 +1162,7 @@ class Worksheet extends WriterPart * Write Drawings. * * @param XMLWriter $objWriter XML Writer - * @param \PhpOffice\PhpSpreadsheet\Worksheet\PhpspreadsheetWorksheet $pSheet Worksheet + * @param PhpspreadsheetWorksheet $pSheet Worksheet * @param bool $includeCharts Flag indicating if we should include drawing details for charts * * @throws WriterException