diff --git a/src/PhpSpreadsheet/Writer/Excel2007.php b/src/PhpSpreadsheet/Writer/Excel2007.php index 80b7edc2..0f91b9e0 100644 --- a/src/PhpSpreadsheet/Writer/Excel2007.php +++ b/src/PhpSpreadsheet/Writer/Excel2007.php @@ -3,7 +3,7 @@ namespace PHPExcel\Writer; /** - * PHPExcel_Writer_Excel2007 + * PHPExcel\Writer\Excel2007 * * Copyright (c) 2006 - 2015 PHPExcel * @@ -27,19 +27,8 @@ namespace PHPExcel\Writer; * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ -class Excel2007 implements IWriter +class Excel2007 extends BaseWriter implements IWriter { - /** - * Pre-calculate formulas - * Forces PHPExcel to recalculate all formulae in a workbook when saving, so that the pre-calculated values are - * immediately available to MS Excel or other office spreadsheet viewer when opening the file - * - * Overrides the default TRUE for this specific writer for performance reasons - * - * @var boolean - */ - protected $preCalculateFormulas = false; - /** * Office2003 compatibility * @@ -118,7 +107,7 @@ class Excel2007 implements IWriter private $drawingHashTable; /** - * Create a new PHPExcel_Writer_Excel2007 + * Create a new Excel2007 Writer * * @param \PHPExcel\SpreadSheet $pPHPExcel */ @@ -196,8 +185,8 @@ class Excel2007 implements IWriter } } - $saveDebugLog = PHPExcel_Calculation::getInstance($this->spreadSheet)->getDebugLog()->getWriteDebugLog(); - PHPExcel_Calculation::getInstance($this->spreadSheet)->getDebugLog()->setWriteDebugLog(false); + $saveDebugLog = \PHPExcel\Calculation::getInstance($this->spreadSheet)->getDebugLog()->getWriteDebugLog(); + \PHPExcel\Calculation::getInstance($this->spreadSheet)->getDebugLog()->setWriteDebugLog(false); $saveDateReturnType = \PHPExcel\Calculation\Functions::getReturnDateType(); \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_EXCEL); @@ -386,7 +375,7 @@ class Excel2007 implements IWriter } \PHPExcel\Calculation\Functions::setReturnDateType($saveDateReturnType); - PHPExcel_Calculation::getInstance($this->spreadSheet)->getDebugLog()->setWriteDebugLog($saveDebugLog); + \PHPExcel\Calculation::getInstance($this->spreadSheet)->getDebugLog()->setWriteDebugLog($saveDebugLog); // Close file if ($objZip->close() === false) { diff --git a/src/PhpSpreadsheet/Writer/Excel5.php b/src/PhpSpreadsheet/Writer/Excel5.php index d204ae72..9042d4d0 100644 --- a/src/PhpSpreadsheet/Writer/Excel5.php +++ b/src/PhpSpreadsheet/Writer/Excel5.php @@ -1,7 +1,9 @@ phpExcel = $phpExcel; + $this->phpExcel = $phpExcel; - $this->parser = new PHPExcel_Writer_Excel5_Parser(); + $this->parser = new Excel5\Parser(); } /** - * Save PHPExcel to file + * Save Spreadsheet to file * * @param string $pFilename * @throws \PHPExcel\Writer\Exception @@ -114,8 +116,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce // garbage collect $this->phpExcel->garbageCollect(); - $saveDebugLog = PHPExcel_Calculation::getInstance($this->phpExcel)->getDebugLog()->getWriteDebugLog(); - PHPExcel_Calculation::getInstance($this->phpExcel)->getDebugLog()->setWriteDebugLog(false); + $saveDebugLog = \PHPExcel\Calculation::getInstance($this->phpExcel)->getDebugLog()->getWriteDebugLog(); + \PHPExcel\Calculation::getInstance($this->phpExcel)->getDebugLog()->setWriteDebugLog(false); $saveDateReturnType = \PHPExcel\Calculation\Functions::getReturnDateType(); \PHPExcel\Calculation\Functions::setReturnDateType(\PHPExcel\Calculation\Functions::RETURNDATE_EXCEL); @@ -123,12 +125,12 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $this->colors = array(); // Initialise workbook writer - $this->writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->phpExcel, $this->strTotal, $this->strUnique, $this->strTable, $this->colors, $this->parser); + $this->writerWorkbook = new Excel5\Workbook($this->phpExcel, $this->strTotal, $this->strUnique, $this->strTable, $this->colors, $this->parser); // Initialise worksheet writers $countSheets = $this->phpExcel->getSheetCount(); for ($i = 0; $i < $countSheets; ++$i) { - $this->writerWorksheets[$i] = new PHPExcel_Writer_Excel5_Worksheet($this->strTotal, $this->strUnique, $this->strTable, $this->colors, $this->parser, $this->preCalculateFormulas, $this->phpExcel->getSheet($i)); + $this->writerWorksheets[$i] = new Excel5\Worksheet($this->strTotal, $this->strUnique, $this->strTable, $this->colors, $this->parser, $this->preCalculateFormulas, $this->phpExcel->getSheet($i)); } // build Escher objects. Escher objects for workbooks needs to be build before Escher object for workbook. @@ -166,7 +168,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce // initialize OLE file $workbookStreamName = 'Workbook'; - $OLE = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs($workbookStreamName)); + $OLE = new \PHPExcel\Shared\OLE\PPS\File(\PHPExcel\Shared\OLE::Asc2Ucs($workbookStreamName)); // Write the worksheet streams before the global workbook stream, // because the byte sizes of these are needed in the global workbook stream @@ -187,14 +189,14 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $this->documentSummaryInformation = $this->writeDocumentSummaryInformation(); // initialize OLE Document Summary Information if (isset($this->documentSummaryInformation) && !empty($this->documentSummaryInformation)) { - $OLE_DocumentSummaryInformation = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs(chr(5) . 'DocumentSummaryInformation')); + $OLE_DocumentSummaryInformation = new \PHPExcel\Shared\OLE\PPS\File(\PHPExcel\Shared\OLE::Asc2Ucs(chr(5) . 'DocumentSummaryInformation')); $OLE_DocumentSummaryInformation->append($this->documentSummaryInformation); } $this->summaryInformation = $this->writeSummaryInformation(); // initialize OLE Summary Information if (isset($this->summaryInformation) && !empty($this->summaryInformation)) { - $OLE_SummaryInformation = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs(chr(5) . 'SummaryInformation')); + $OLE_SummaryInformation = new \PHPExcel\Shared\OLE\PPS\File(\PHPExcel\Shared\OLE::Asc2Ucs(chr(5) . 'SummaryInformation')); $OLE_SummaryInformation->append($this->summaryInformation); } @@ -209,12 +211,12 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $arrRootData[] = $OLE_DocumentSummaryInformation; } - $root = new PHPExcel_Shared_OLE_PPS_Root(time(), time(), $arrRootData); + $root = new \PHPExcel\Shared\OLE\PPS\Root(time(), time(), $arrRootData); // save the OLE file $res = $root->save($pFilename); \PHPExcel\Calculation\Functions::setReturnDateType($saveDateReturnType); - PHPExcel_Calculation::getInstance($this->phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog); + \PHPExcel\Calculation::getInstance($this->phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog); } /** @@ -223,7 +225,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce * @deprecated * @param string $pValue Temporary storage directory * @throws \PHPExcel\Writer\Exception when directory does not exist - * @return PHPExcel_Writer_Excel5 + * @return \PHPExcel\Writer\Excel5 */ public function setTempDir($pValue = '') { @@ -254,10 +256,10 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce } // create intermediate Escher object - $escher = new PHPExcel_Shared_Escher(); + $escher = new \PHPExcel\Shared\Escher(); // dgContainer - $dgContainer = new PHPExcel_Shared_Escher_DgContainer(); + $dgContainer = new \PHPExcel\Shared\Escher\DgContainer(); // set the drawing index (we use sheet index + 1) $dgId = $sheet->getParent()->getIndex($sheet) + 1; @@ -265,11 +267,11 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $escher->setDgContainer($dgContainer); // spgrContainer - $spgrContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer(); + $spgrContainer = new \PHPExcel\Shared\Escher\DgContainer\SpgrContainer(); $dgContainer->setSpgrContainer($spgrContainer); // add one shape which is the group shape - $spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer(); + $spContainer = new \PHPExcel\Shared\Escher\DgContainer\SpgrContainer\SpContainer(); $spContainer->setSpgr(true); $spContainer->setSpType(0); $spContainer->setSpId(($sheet->getParent()->getIndex($sheet) + 1) << 10); @@ -285,7 +287,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce ++$countShapes[$sheetIndex]; // add the shape - $spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer(); + $spContainer = new \PHPExcel\Shared\Escher\DgContainer\SpgrContainer\SpContainer(); // set the shape type $spContainer->setSpType(0x004B); @@ -314,7 +316,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $width = $drawing->getWidth(); $height = $drawing->getHeight(); - $twoAnchor = PHPExcel_Shared_Excel5::oneAnchor2twoAnchor($sheet, $coordinates, $offsetX, $offsetY, $width, $height); + $twoAnchor = \PHPExcel\Shared\Excel5::oneAnchor2twoAnchor($sheet, $coordinates, $offsetX, $offsetY, $width, $height); $spContainer->setStartCoordinates($twoAnchor['startCoordinates']); $spContainer->setStartOffsetX($twoAnchor['startOffsetX']); @@ -328,7 +330,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce // AutoFilters if (!empty($filterRange)) { - $rangeBounds = PHPExcel_Cell::rangeBoundaries($filterRange); + $rangeBounds = \PHPExcel\Cell::rangeBoundaries($filterRange); $iNumColStart = $rangeBounds[0][0]; $iNumColEnd = $rangeBounds[1][0]; @@ -339,12 +341,12 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce // create an Drawing Object for the dropdown $oDrawing = new \PHPExcel\Worksheet\BaseDrawing(); // get the coordinates of drawing - $cDrawing = PHPExcel_Cell::stringFromColumnIndex($iInc - 1) . $rangeBounds[0][1]; + $cDrawing = \PHPExcel\Cell::stringFromColumnIndex($iInc - 1) . $rangeBounds[0][1]; $oDrawing->setCoordinates($cDrawing); $oDrawing->setWorksheet($sheet); // add the shape - $spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer(); + $spContainer = new \PHPExcel\Shared\Escher\DgContainer\SpgrContainer\SpContainer(); // set the shape type $spContainer->setSpType(0x00C9); // set the shape flag @@ -369,7 +371,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $spContainer->setOPT(0x03BF, 0x000A0000); // Group Shape -> fPrint // set coordinates and offsets, client anchor - $endCoordinates = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::stringFromColumnIndex($iInc - 1)); + $endCoordinates = \PHPExcel\Cell::stringFromColumnIndex(\PHPExcel\Cell::stringFromColumnIndex($iInc - 1)); $endCoordinates .= $rangeBounds[0][1] + 1; $spContainer->setStartCoordinates($cDrawing); @@ -417,10 +419,10 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce } // if we reach here, then there are drawings in the workbook - $escher = new PHPExcel_Shared_Escher(); + $escher = new \PHPExcel\Shared\Escher(); // dggContainer - $dggContainer = new PHPExcel_Shared_Escher_DggContainer(); + $dggContainer = new \PHPExcel\Shared\Escher\DggContainer(); $escher->setDggContainer($dggContainer); // set IDCLs (identifier clusters) @@ -452,7 +454,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $dggContainer->setCSpSaved($totalCountShapes + $countDrawings); // total number of shapes incl. one group shapes per drawing // bstoreContainer - $bstoreContainer = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer(); + $bstoreContainer = new \PHPExcel\Shared\Escher\DggContainer\BstoreContainer(); $dggContainer->setBstoreContainer($bstoreContainer); // the BSE's (all the images) @@ -465,22 +467,22 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce switch ($imageFormat) { case 1: // GIF, not supported by BIFF8, we convert to PNG - $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG; + $blipType = \PHPExcel\Shared\Escher\DggContainer\BstoreContainer\BSE::BLIPTYPE_PNG; ob_start(); imagepng(imagecreatefromgif($filename)); $blipData = ob_get_contents(); ob_end_clean(); break; case 2: // JPEG - $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG; + $blipType = \PHPExcel\Shared\Escher\DggContainer\BstoreContainer\BSE::BLIPTYPE_JPEG; $blipData = file_get_contents($filename); break; case 3: // PNG - $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG; + $blipType = \PHPExcel\Shared\Escher\DggContainer\BstoreContainer\BSE::BLIPTYPE_PNG; $blipData = file_get_contents($filename); break; case 6: // Windows DIB (BMP), we convert to PNG - $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG; + $blipType = \PHPExcel\Shared\Escher\DggContainer\BstoreContainer\BSE::BLIPTYPE_PNG; ob_start(); imagepng(\PHPExcel\Shared\Drawing::imagecreatefrombmp($filename)); $blipData = ob_get_contents(); @@ -490,10 +492,10 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce continue 2; } - $blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip(); + $blip = new \PHPExcel\Shared\Escher\DggContainer\BstoreContainer\BSE\Blip(); $blip->setData($blipData); - $BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE(); + $BSE = new \PHPExcel\Shared\Escher\DggContainer\BstoreContainer\BSE(); $BSE->setBlipType($blipType); $BSE->setBlip($blip); @@ -501,13 +503,13 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce } elseif ($drawing instanceof \PHPExcel\Worksheet\MemoryDrawing) { switch ($drawing->getRenderingFunction()) { case \PHPExcel\Worksheet\MemoryDrawing::RENDERING_JPEG: - $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG; + $blipType = \PHPExcel\Shared\Escher\DggContainer\BstoreContainer\BSE::BLIPTYPE_JPEG; $renderingFunction = 'imagejpeg'; break; case \PHPExcel\Worksheet\MemoryDrawing::RENDERING_GIF: case \PHPExcel\Worksheet\MemoryDrawing::RENDERING_PNG: case \PHPExcel\Worksheet\MemoryDrawing::RENDERING_DEFAULT: - $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG; + $blipType = \PHPExcel\Shared\Escher\DggContainer\BstoreContainer\BSE::BLIPTYPE_PNG; $renderingFunction = 'imagepng'; break; } @@ -517,10 +519,10 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $blipData = ob_get_contents(); ob_end_clean(); - $blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip(); + $blip = new \PHPExcel\Shared\Escher\DggContainer\BstoreContainer\BSE\Blip(); $blip->setData($blipData); - $BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE(); + $BSE = new \PHPExcel\Shared\Escher\DggContainer\BstoreContainer\BSE(); $BSE->setBlipType($blipType); $BSE->setBlip($blip); @@ -826,7 +828,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x0C), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x40), // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) - 'data' => array('data' => PHPExcel_Shared_OLE::LocalDate2OLE($dataProp))); + 'data' => array('data' => \PHPExcel\Shared\OLE::LocalDate2OLE($dataProp))); $dataSection_NumProps++; } // Modified Date/Time @@ -835,7 +837,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce $dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x0D), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x40), // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) - 'data' => array('data' => PHPExcel_Shared_OLE::LocalDate2OLE($dataProp))); + 'data' => array('data' => \PHPExcel\Shared\OLE::LocalDate2OLE($dataProp))); $dataSection_NumProps++; } // Security diff --git a/src/PhpSpreadsheet/Writer/Excel5/BIFFwriter.php b/src/PhpSpreadsheet/Writer/Excel5/BIFFwriter.php index 2549ef52..3d6f2ebf 100644 --- a/src/PhpSpreadsheet/Writer/Excel5/BIFFwriter.php +++ b/src/PhpSpreadsheet/Writer/Excel5/BIFFwriter.php @@ -1,7 +1,9 @@ little endian, 1 => big endian diff --git a/src/PhpSpreadsheet/Writer/Excel5/Escher.php b/src/PhpSpreadsheet/Writer/Excel5/Escher.php index c37fda9b..5b96cc17 100644 --- a/src/PhpSpreadsheet/Writer/Excel5/Escher.php +++ b/src/PhpSpreadsheet/Writer/Excel5/Escher.php @@ -1,6 +1,9 @@ data = ''; switch (get_class($this->object)) { - case 'PHPExcel_Shared_Escher': + case '\\PHPExcel\\Shared\\Escher': if ($dggContainer = $this->object->getDggContainer()) { - $writer = new PHPExcel_Writer_Excel5_Escher($dggContainer); + $writer = new Escher($dggContainer); $this->data = $writer->close(); } elseif ($dgContainer = $this->object->getDgContainer()) { - $writer = new PHPExcel_Writer_Excel5_Escher($dgContainer); + $writer = new Escher($dgContainer); $this->data = $writer->close(); $this->spOffsets = $writer->getSpOffsets(); $this->spTypes = $writer->getSpTypes(); } break; - case 'PHPExcel_Shared_Escher_DggContainer': + case '\\PHPExcel\\Shared\\Escher\\DggContainer': // this is a container record // initialize @@ -125,7 +121,7 @@ class PHPExcel_Writer_Excel5_Escher // write the bstoreContainer if ($bstoreContainer = $this->object->getBstoreContainer()) { - $writer = new PHPExcel_Writer_Excel5_Escher($bstoreContainer); + $writer = new Escher($bstoreContainer); $innerData .= $writer->close(); } @@ -142,7 +138,7 @@ class PHPExcel_Writer_Excel5_Escher $this->data = $header . $innerData; break; - case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer': + case '\\PHPExcel\\Shared\\Escher\\DggContainer\\BstoreContainer': // this is a container record // initialize @@ -151,7 +147,7 @@ class PHPExcel_Writer_Excel5_Escher // treat the inner data if ($BSECollection = $this->object->getBSECollection()) { foreach ($BSECollection as $BSE) { - $writer = new PHPExcel_Writer_Excel5_Escher($BSE); + $writer = new Escher($BSE); $innerData .= $writer->close(); } } @@ -169,7 +165,7 @@ class PHPExcel_Writer_Excel5_Escher $this->data = $header . $innerData; break; - case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE': + case '\\PHPExcel\\Shared\\Escher\\DggContainer\\BstoreContainer\\BSE': // this is a semi-container record // initialize @@ -177,7 +173,7 @@ class PHPExcel_Writer_Excel5_Escher // here we treat the inner data if ($blip = $this->object->getBlip()) { - $writer = new PHPExcel_Writer_Excel5_Escher($blip); + $writer = new Escher($blip); $innerData .= $writer->close(); } @@ -218,12 +214,12 @@ class PHPExcel_Writer_Excel5_Escher $this->data .= $data; break; - case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip': + case '\\PHPExcel\\Shared\\Escher\\DggContainer\\BstoreContainer\\BSE\\Blip': // this is an atom record // write the record switch ($this->object->getParent()->getBlipType()) { - case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG: + case \PHPExcel\Shared\Escher\DggContainer\BstoreContainer\BSE::BLIPTYPE_JPEG: // initialize $innerData = ''; @@ -250,7 +246,7 @@ class PHPExcel_Writer_Excel5_Escher $this->data .= $innerData; break; - case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG: + case \PHPExcel\Shared\Escher\DggContainer\BstoreContainer\BSE::BLIPTYPE_PNG: // initialize $innerData = ''; @@ -278,7 +274,7 @@ class PHPExcel_Writer_Excel5_Escher break; } break; - case 'PHPExcel_Shared_Escher_DgContainer': + case '\\PHPExcel\\Shared\\Escher\\DgContainer': // this is a container record // initialize @@ -302,7 +298,7 @@ class PHPExcel_Writer_Excel5_Escher // write the spgrContainer if ($spgrContainer = $this->object->getSpgrContainer()) { - $writer = new PHPExcel_Writer_Excel5_Escher($spgrContainer); + $writer = new Escher($spgrContainer); $innerData .= $writer->close(); // get the shape offsets relative to the spgrContainer record @@ -331,7 +327,7 @@ class PHPExcel_Writer_Excel5_Escher $this->data = $header . $innerData; break; - case 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer': + case '\\PHPExcel\\Shared\\Escher\\DgContainer\\SpgrContainer': // this is a container record // initialize @@ -344,7 +340,7 @@ class PHPExcel_Writer_Excel5_Escher // treat the inner data foreach ($this->object->getChildren() as $spContainer) { - $writer = new PHPExcel_Writer_Excel5_Escher($spContainer); + $writer = new Escher($spContainer); $spData = $writer->close(); $innerData .= $spData; @@ -370,7 +366,7 @@ class PHPExcel_Writer_Excel5_Escher $this->spOffsets = $spOffsets; $this->spTypes = $spTypes; break; - case 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer': + case '\\PHPExcel\\Shared\\Escher\\DgContainer\\SpgrContainer\\SpContainer': // initialize $data = ''; @@ -434,8 +430,8 @@ class PHPExcel_Writer_Excel5_Escher $recType = 0xF010; // start coordinates - list($column, $row) = PHPExcel_Cell::coordinateFromString($this->object->getStartCoordinates()); - $c1 = PHPExcel_Cell::columnIndexFromString($column) - 1; + list($column, $row) = \PHPExcel\Cell::coordinateFromString($this->object->getStartCoordinates()); + $c1 = \PHPExcel\Cell::columnIndexFromString($column) - 1; $r1 = $row - 1; // start offsetX @@ -445,8 +441,8 @@ class PHPExcel_Writer_Excel5_Escher $startOffsetY = $this->object->getStartOffsetY(); // end coordinates - list($column, $row) = PHPExcel_Cell::coordinateFromString($this->object->getEndCoordinates()); - $c2 = PHPExcel_Cell::columnIndexFromString($column) - 1; + list($column, $row) = \PHPExcel\Cell::coordinateFromString($this->object->getEndCoordinates()); + $c2 = \PHPExcel\Cell::columnIndexFromString($column) - 1; $r2 = $row - 1; // end offsetX diff --git a/src/PhpSpreadsheet/Writer/Excel5/Font.php b/src/PhpSpreadsheet/Writer/Excel5/Font.php index dc3c6d71..aad7d211 100644 --- a/src/PhpSpreadsheet/Writer/Excel5/Font.php +++ b/src/PhpSpreadsheet/Writer/Excel5/Font.php @@ -1,7 +1,9 @@ font->getName()); // Character set + $bCharSet = \PHPExcel\Shared\Font::getCharsetFromFontName($this->font->getName()); // Character set $record = 0x31; // Record identifier $reserved = 0x00; // Reserved @@ -115,7 +117,7 @@ class PHPExcel_Writer_Excel5_Font $bCharSet, $reserved ); - $data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($this->font->getName()); + $data .= \PHPExcel\Shared\String::UTF8toBIFF8UnicodeShort($this->font->getName()); $length = strlen($data); $header = pack("vv", $record, $length); diff --git a/src/PhpSpreadsheet/Writer/Excel5/Parser.php b/src/PhpSpreadsheet/Writer/Excel5/Parser.php index 3129fc60..a41ab735 100644 --- a/src/PhpSpreadsheet/Writer/Excel5/Parser.php +++ b/src/PhpSpreadsheet/Writer/Excel5/Parser.php @@ -1,7 +1,9 @@ ptg['ptgInt'], $num); } else { // A float - if (PHPExcel_Writer_Excel5_BIFFwriter::getByteOrder()) { // if it's Big Endian + if (BIFFwriter::getByteOrder()) { // if it's Big Endian $num = strrev($num); } return pack("Cd", $this->ptg['ptgNum'], $num); @@ -593,7 +595,7 @@ class PHPExcel_Writer_Excel5_Parser throw new \PHPExcel\Writer\Exception("String is too long"); } - return pack('C', $this->ptg['ptgStr']) . PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($string); + return pack('C', $this->ptg['ptgStr']) . \PHPExcel\Shared\String::UTF8toBIFF8UnicodeShort($string); } /** @@ -899,7 +901,7 @@ class PHPExcel_Writer_Excel5_Parser /** * Look up the index that corresponds to an external sheet name. The hash of * sheet names is updated by the addworksheet() method of the - * PHPExcel_Writer_Excel5_Workbook class. + * \PHPExcel\Writer\Excel5\Workbook class. * * @access private * @param string $sheet_name Sheet name @@ -917,10 +919,10 @@ class PHPExcel_Writer_Excel5_Parser /** * This method is used to update the array of sheet names. It is * called by the addWorksheet() method of the - * PHPExcel_Writer_Excel5_Workbook class. + * \PHPExcel\Writer\Excel5\Workbook class. * * @access public - * @see PHPExcel_Writer_Excel5_Workbook::addWorksheet() + * @see \PHPExcel\Writer\Excel5\Workbook::addWorksheet() * @param string $name The name of the worksheet being added * @param integer $index The index of the worksheet being added */ diff --git a/src/PhpSpreadsheet/Writer/Excel5/Workbook.php b/src/PhpSpreadsheet/Writer/Excel5/Workbook.php index 660b5661..1adddfe0 100644 --- a/src/PhpSpreadsheet/Writer/Excel5/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Excel5/Workbook.php @@ -1,7 +1,9 @@ setIsStyleXf($isStyleXf); // Add the font if not already added @@ -299,7 +301,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter $countFonts = count($this->fontWriters); $fontIndex = ($countFonts < 4) ? $countFonts : $countFonts + 1; - $fontWriter = new PHPExcel_Writer_Excel5_Font($font); + $fontWriter = new \PHPExcel\Writer\Excel5\Font($font); $fontWriter->setColorIndex($this->addColor($font->getColor()->getRGB())); $this->fontWriters[] = $fontWriter; @@ -478,7 +480,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter // add size of Workbook globals part 2, the length of the SHEET records $total_worksheets = count($this->phpExcel->getAllSheets()); foreach ($this->phpExcel->getWorksheetIterator() as $sheet) { - $offset += $boundsheet_length + strlen(PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($sheet->getTitle())); + $offset += $boundsheet_length + strlen(\PHPExcel\Shared\String::UTF8toBIFF8UnicodeShort($sheet->getTitle())); } // add the sizes of each of the Sheet substreams, respectively @@ -557,15 +559,15 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter // Write a Name record if the print area has been defined if ($sheetSetup->isPrintAreaSet()) { // Print area - $printArea = PHPExcel_Cell::splitRange($sheetSetup->getPrintArea()); + $printArea = \PHPExcel\Cell::splitRange($sheetSetup->getPrintArea()); $printArea = $printArea[0]; - $printArea[0] = PHPExcel_Cell::coordinateFromString($printArea[0]); - $printArea[1] = PHPExcel_Cell::coordinateFromString($printArea[1]); + $printArea[0] = \PHPExcel\Cell::coordinateFromString($printArea[0]); + $printArea[1] = \PHPExcel\Cell::coordinateFromString($printArea[1]); $print_rowmin = $printArea[0][1] - 1; $print_rowmax = $printArea[1][1] - 1; - $print_colmin = PHPExcel_Cell::columnIndexFromString($printArea[0][0]) - 1; - $print_colmax = PHPExcel_Cell::columnIndexFromString($printArea[1][0]) - 1; + $print_colmin = \PHPExcel\Cell::columnIndexFromString($printArea[0][0]) - 1; + $print_colmax = \PHPExcel\Cell::columnIndexFromString($printArea[1][0]) - 1; $this->writeNameShort( $i, // sheet index @@ -585,8 +587,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter // simultaneous repeatColumns repeatRows if ($sheetSetup->isColumnsToRepeatAtLeftSet() && $sheetSetup->isRowsToRepeatAtTopSet()) { $repeat = $sheetSetup->getColumnsToRepeatAtLeft(); - $colmin = PHPExcel_Cell::columnIndexFromString($repeat[0]) - 1; - $colmax = PHPExcel_Cell::columnIndexFromString($repeat[1]) - 1; + $colmin = \PHPExcel\Cell::columnIndexFromString($repeat[0]) - 1; + $colmax = \PHPExcel\Cell::columnIndexFromString($repeat[1]) - 1; $repeat = $sheetSetup->getRowsToRepeatAtTop(); $rowmin = $repeat[0] - 1; @@ -606,8 +608,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter // Columns to repeat if ($sheetSetup->isColumnsToRepeatAtLeftSet()) { $repeat = $sheetSetup->getColumnsToRepeatAtLeft(); - $colmin = PHPExcel_Cell::columnIndexFromString($repeat[0]) - 1; - $colmax = PHPExcel_Cell::columnIndexFromString($repeat[1]) - 1; + $colmin = \PHPExcel\Cell::columnIndexFromString($repeat[0]) - 1; + $colmax = \PHPExcel\Cell::columnIndexFromString($repeat[1]) - 1; } else { $colmin = 0; $colmax = 255; @@ -649,14 +651,14 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter $namedRanges = $this->phpExcel->getNamedRanges(); foreach ($namedRanges as $namedRange) { // Create absolute coordinate - $range = PHPExcel_Cell::splitRange($namedRange->getRange()); + $range = \PHPExcel\Cell::splitRange($namedRange->getRange()); for ($i = 0; $i < count($range); $i++) { - $range[$i][0] = '\'' . str_replace("'", "''", $namedRange->getWorksheet()->getTitle()) . '\'!' . PHPExcel_Cell::absoluteCoordinate($range[$i][0]); + $range[$i][0] = '\'' . str_replace("'", "''", $namedRange->getWorksheet()->getTitle()) . '\'!' . \PHPExcel\Cell::absoluteCoordinate($range[$i][0]); if (isset($range[$i][1])) { - $range[$i][1] = PHPExcel_Cell::absoluteCoordinate($range[$i][1]); + $range[$i][1] = \PHPExcel\Cell::absoluteCoordinate($range[$i][1]); } } - $range = PHPExcel_Cell::buildRange($range); // e.g. Sheet1!$A$1:$B$2 + $range = \PHPExcel\Cell::buildRange($range); // e.g. Sheet1!$A$1:$B$2 // parse formula try { @@ -677,7 +679,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter } $chunk .= $this->writeData($this->writeDefinedNameBiff8($namedRange->getName(), $formulaData, $scope, false)); - } catch (PHPExcel_Exception $e) { + } catch (\PHPExcel\Exception $e) { // do nothing } } @@ -692,8 +694,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter // simultaneous repeatColumns repeatRows if ($sheetSetup->isColumnsToRepeatAtLeftSet() && $sheetSetup->isRowsToRepeatAtTopSet()) { $repeat = $sheetSetup->getColumnsToRepeatAtLeft(); - $colmin = PHPExcel_Cell::columnIndexFromString($repeat[0]) - 1; - $colmax = PHPExcel_Cell::columnIndexFromString($repeat[1]) - 1; + $colmin = \PHPExcel\Cell::columnIndexFromString($repeat[0]) - 1; + $colmax = \PHPExcel\Cell::columnIndexFromString($repeat[1]) - 1; $repeat = $sheetSetup->getRowsToRepeatAtTop(); $rowmin = $repeat[0] - 1; @@ -713,8 +715,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter // Columns to repeat if ($sheetSetup->isColumnsToRepeatAtLeftSet()) { $repeat = $sheetSetup->getColumnsToRepeatAtLeft(); - $colmin = PHPExcel_Cell::columnIndexFromString($repeat[0]) - 1; - $colmax = PHPExcel_Cell::columnIndexFromString($repeat[1]) - 1; + $colmin = \PHPExcel\Cell::columnIndexFromString($repeat[0]) - 1; + $colmax = \PHPExcel\Cell::columnIndexFromString($repeat[1]) - 1; } else { $colmin = 0; $colmax = 255; @@ -742,19 +744,19 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter $sheetSetup = $this->phpExcel->getSheet($i)->getPageSetup(); if ($sheetSetup->isPrintAreaSet()) { // Print area, e.g. A3:J6,H1:X20 - $printArea = PHPExcel_Cell::splitRange($sheetSetup->getPrintArea()); + $printArea = \PHPExcel\Cell::splitRange($sheetSetup->getPrintArea()); $countPrintArea = count($printArea); $formulaData = ''; for ($j = 0; $j < $countPrintArea; ++$j) { $printAreaRect = $printArea[$j]; // e.g. A3:J6 - $printAreaRect[0] = PHPExcel_Cell::coordinateFromString($printAreaRect[0]); - $printAreaRect[1] = PHPExcel_Cell::coordinateFromString($printAreaRect[1]); + $printAreaRect[0] = \PHPExcel\Cell::coordinateFromString($printAreaRect[0]); + $printAreaRect[1] = \PHPExcel\Cell::coordinateFromString($printAreaRect[1]); $print_rowmin = $printAreaRect[0][1] - 1; $print_rowmax = $printAreaRect[1][1] - 1; - $print_colmin = PHPExcel_Cell::columnIndexFromString($printAreaRect[0][0]) - 1; - $print_colmax = PHPExcel_Cell::columnIndexFromString($printAreaRect[1][0]) - 1; + $print_colmin = \PHPExcel\Cell::columnIndexFromString($printAreaRect[0][0]) - 1; + $print_colmax = \PHPExcel\Cell::columnIndexFromString($printAreaRect[1][0]) - 1; // construct formula data manually because parser does not recognize absolute 3d cell references $formulaData .= pack('Cvvvvv', 0x3B, $i, $print_rowmin, $print_rowmax, $print_colmin, $print_colmax); @@ -774,7 +776,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter $sheetAutoFilter = $this->phpExcel->getSheet($i)->getAutoFilter(); $autoFilterRange = $sheetAutoFilter->getRange(); if (!empty($autoFilterRange)) { - $rangeBounds = PHPExcel_Cell::rangeBoundaries($autoFilterRange); + $rangeBounds = \PHPExcel\Cell::rangeBoundaries($autoFilterRange); //Autofilter built in name $name = pack('C', 0x0D); @@ -803,10 +805,10 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter $options = $isBuiltIn ? 0x20 : 0x00; // length of the name, character count - $nlen = PHPExcel_Shared_String::CountCharacters($name); + $nlen = \PHPExcel\Shared\String::CountCharacters($name); // name with stripped length field - $name = substr(PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($name), 2); + $name = substr(\PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($name), 2); // size of the formula (in bytes) $sz = strlen($formulaData); @@ -937,7 +939,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter $grbit = 0x0000; // Visibility and sheet type $data = pack("VCC", $offset, $ss, $st); - $data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($sheetname); + $data .= \PHPExcel\Shared\String::UTF8toBIFF8UnicodeShort($sheetname); $length = strlen($data); $header = pack("vv", $record, $length); @@ -1004,7 +1006,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter { $record = 0x041E; // Record identifier - $numberFormatString = PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($format); + $numberFormatString = \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($format); $length = 2 + strlen($numberFormatString); // Number of bytes to follow @@ -1021,7 +1023,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter $record = 0x0022; // Record identifier $length = 0x0002; // Bytes to follow - $f1904 = (PHPExcel_Shared_Date::getExcelCalendar() == PHPExcel_Shared_Date::CALENDAR_MAC_1904) + $f1904 = (\PHPExcel\Shared\Date::getExcelCalendar() == \PHPExcel\Shared\Date::CALENDAR_MAC_1904) ? 1 : 0; // Flag for 1904 date system @@ -1409,7 +1411,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter { // write the Escher stream if necessary if (isset($this->escher)) { - $writer = new PHPExcel_Writer_Excel5_Escher($this->escher); + $writer = new \PHPExcel\Writer\Excel5\Escher($this->escher); $data = $writer->close(); $record = 0x00EB; @@ -1425,7 +1427,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter /** * Get Escher object * - * @return PHPExcel_Shared_Escher + * @return \PHPExcel\Shared\Escher */ public function getEscher() { @@ -1435,9 +1437,9 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter /** * Set Escher object * - * @param PHPExcel_Shared_Escher $pValue + * @param \PHPExcel\Shared\Escher $pValue */ - public function setEscher(PHPExcel_Shared_Escher $pValue = null) + public function setEscher(\PHPExcel\Shared\Escher $pValue = null) { $this->escher = $pValue; } diff --git a/src/PhpSpreadsheet/Writer/Excel5/Worksheet.php b/src/PhpSpreadsheet/Writer/Excel5/Worksheet.php index de3b29ab..81d9555a 100644 --- a/src/PhpSpreadsheet/Writer/Excel5/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Excel5/Worksheet.php @@ -1,7 +1,9 @@ firstRowIndex = ($minR > 65535) ? 65535 : $minR; $this->lastRowIndex = ($maxR > 65535) ? 65535 : $maxR ; - $this->firstColumnIndex = PHPExcel_Cell::columnIndexFromString($minC); - $this->lastColumnIndex = PHPExcel_Cell::columnIndexFromString($maxC); + $this->firstColumnIndex = \PHPExcel\Cell::columnIndexFromString($minC); + $this->lastColumnIndex = \PHPExcel\Cell::columnIndexFromString($maxC); // if ($this->firstColumnIndex > 255) $this->firstColumnIndex = 255; if ($this->lastColumnIndex > 255) { @@ -264,7 +266,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter * and to the end of the workbook. * * @access public - * @see PHPExcel_Writer_Excel5_Workbook::storeWorkbook() + * @see \PHPExcel\Writer\Excel5\Workbook::storeWorkbook() */ public function close() { @@ -289,7 +291,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter // Column dimensions if (($defaultWidth = $phpSheet->getDefaultColumnDimension()->getWidth()) < 0) { - $defaultWidth = PHPExcel_Shared_Font::getDefaultColumnWidthByFont($phpSheet->getParent()->getDefaultStyle()->getFont()); + $defaultWidth = \PHPExcel\Shared\Font::getDefaultColumnWidthByFont($phpSheet->getParent()->getDefaultStyle()->getFont()); } $columnDimensions = $phpSheet->getColumnDimensions(); @@ -301,7 +303,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $width = $defaultWidth; - $columnLetter = PHPExcel_Cell::stringFromColumnIndex($i); + $columnLetter = \PHPExcel\Cell::stringFromColumnIndex($i); if (isset($columnDimensions[$columnLetter])) { $columnDimension = $columnDimensions[$columnLetter]; if ($columnDimension->getWidth() >= 0) { @@ -386,7 +388,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter foreach ($phpSheet->getCellCollection() as $cellID) { $cell = $phpSheet->getCell($cellID); $row = $cell->getRow() - 1; - $column = PHPExcel_Cell::columnIndexFromString($cell->getColumn()) - 1; + $column = \PHPExcel\Cell::columnIndexFromString($cell->getColumn()) - 1; // Don't break Excel! // if ($row + 1 > 65536 or $column + 1 > 256) { @@ -401,7 +403,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter if ($cVal instanceof \PHPExcel\RichText) { // $this->writeString($row, $column, $cVal->getPlainText(), $xfIndex); $arrcRun = array(); - $str_len = PHPExcel_Shared_String::CountCharacters($cVal->getPlainText(), 'UTF-8'); + $str_len = \PHPExcel\Shared\String::CountCharacters($cVal->getPlainText(), 'UTF-8'); $str_pos = 0; $elements = $cVal->getRichTextElements(); foreach ($elements as $element) { @@ -413,7 +415,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter } $arrcRun[] = array('strlen' => $str_pos, 'fontidx' => $str_fontidx); // Position FROM - $str_pos += PHPExcel_Shared_String::CountCharacters($element->getText(), 'UTF-8'); + $str_pos += \PHPExcel\Shared\String::CountCharacters($element->getText(), 'UTF-8'); } $this->writeRichTextString($row, $column, $cVal->getPlainText(), $xfIndex, $arrcRun); } else { @@ -472,7 +474,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter // Hyperlinks foreach ($phpSheet->getHyperLinkCollection() as $coordinate => $hyperlink) { - list($column, $row) = PHPExcel_Cell::coordinateFromString($coordinate); + list($column, $row) = \PHPExcel\Cell::coordinateFromString($coordinate); $url = $hyperlink->getUrl(); @@ -489,7 +491,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $url = 'external:' . $url; } - $this->writeUrl($row - 1, PHPExcel_Cell::columnIndexFromString($column) - 1, $url); + $this->writeUrl($row - 1, \PHPExcel\Cell::columnIndexFromString($column) - 1, $url); } $this->writeDataValidity(); @@ -545,10 +547,10 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $lastCell = $explodes[1]; } - $firstCellCoordinates = PHPExcel_Cell::coordinateFromString($firstCell); // e.g. array(0, 1) - $lastCellCoordinates = PHPExcel_Cell::coordinateFromString($lastCell); // e.g. array(1, 6) + $firstCellCoordinates = \PHPExcel\Cell::coordinateFromString($firstCell); // e.g. array(0, 1) + $lastCellCoordinates = \PHPExcel\Cell::coordinateFromString($lastCell); // e.g. array(1, 6) - return pack('vvvv', $firstCellCoordinates[1] - 1, $lastCellCoordinates[1] - 1, PHPExcel_Cell::columnIndexFromString($firstCellCoordinates[0]) - 1, PHPExcel_Cell::columnIndexFromString($lastCellCoordinates[0]) - 1); + return pack('vvvv', $firstCellCoordinates[1] - 1, $lastCellCoordinates[1] - 1, \PHPExcel\Cell::columnIndexFromString($firstCellCoordinates[0]) - 1, \PHPExcel\Cell::columnIndexFromString($lastCellCoordinates[0]) - 1); } /** @@ -660,7 +662,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter { $record = 0x00FD; // Record identifier $length = 0x000A; // Bytes to follow - $str = PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($str, $arrcRun); + $str = \PHPExcel\Shared\String::UTF8toBIFF8UnicodeShort($str, $arrcRun); /* check if string is already present */ if (!isset($this->stringTable[$str])) { @@ -729,7 +731,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $record = 0x00FD; // Record identifier $length = 0x000A; // Bytes to follow - $str = PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($str); + $str = \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($str); /* check if string is already present */ if (!isset($this->stringTable[$str])) { @@ -906,7 +908,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter return 0; - } catch (PHPExcel_Exception $e) { + } catch (\PHPExcel\Exception $e) { // do nothing } @@ -920,7 +922,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter private function writeStringRecord($stringValue) { $record = 0x0207; // Record identifier - $data = PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($stringValue); + $data = \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($stringValue); $length = strlen($data); $header = pack('vv', $record, $length); @@ -1058,10 +1060,10 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $url .= "\0"; // character count - $url_len = PHPExcel_Shared_String::CountCharacters($url); + $url_len = \PHPExcel\Shared\String::CountCharacters($url); $url_len = pack('V', $url_len); - $url = PHPExcel_Shared_String::ConvertEncoding($url, 'UTF-16LE', 'UTF-8'); + $url = \PHPExcel\Shared\String::ConvertEncoding($url, 'UTF-16LE', 'UTF-8'); // Calculate the data length $length = 0x24 + strlen($url); @@ -1404,7 +1406,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter { // look up the selected cell range $selectedCells = $this->phpSheet->getSelectedCells(); - $selectedCells = PHPExcel_Cell::splitRange($this->phpSheet->getSelectedCells()); + $selectedCells = \PHPExcel\Cell::splitRange($this->phpSheet->getSelectedCells()); $selectedCells = $selectedCells[0]; if (count($selectedCells) == 2) { list($first, $last) = $selectedCells; @@ -1413,12 +1415,12 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $last = $selectedCells[0]; } - list($colFirst, $rwFirst) = PHPExcel_Cell::coordinateFromString($first); - $colFirst = PHPExcel_Cell::columnIndexFromString($colFirst) - 1; // base 0 column index + list($colFirst, $rwFirst) = \PHPExcel\Cell::coordinateFromString($first); + $colFirst = \PHPExcel\Cell::columnIndexFromString($colFirst) - 1; // base 0 column index --$rwFirst; // base 0 row index - list($colLast, $rwLast) = PHPExcel_Cell::coordinateFromString($last); - $colLast = PHPExcel_Cell::columnIndexFromString($colLast) - 1; // base 0 column index + list($colLast, $rwLast) = \PHPExcel\Cell::coordinateFromString($last); + $colLast = \PHPExcel\Cell::columnIndexFromString($colLast) - 1; // base 0 column index --$rwLast; // base 0 row index // make sure we are not out of bounds @@ -1491,12 +1493,12 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter ++$j; // extract the row and column indexes - $range = PHPExcel_Cell::splitRange($mergeCell); + $range = \PHPExcel\Cell::splitRange($mergeCell); list($first, $last) = $range[0]; - list($firstColumn, $firstRow) = PHPExcel_Cell::coordinateFromString($first); - list($lastColumn, $lastRow) = PHPExcel_Cell::coordinateFromString($last); + list($firstColumn, $firstRow) = \PHPExcel\Cell::coordinateFromString($first); + list($lastColumn, $lastRow) = \PHPExcel\Cell::coordinateFromString($last); - $recordData .= pack('vvvv', $firstRow - 1, $lastRow - 1, PHPExcel_Cell::columnIndexFromString($firstColumn) - 1, PHPExcel_Cell::columnIndexFromString($lastColumn) - 1); + $recordData .= pack('vvvv', $firstRow - 1, $lastRow - 1, \PHPExcel\Cell::columnIndexFromString($firstColumn) - 1, \PHPExcel\Cell::columnIndexFromString($lastColumn) - 1); // flush record if we have reached limit for number of merged cells, or reached final merged cell if ($j == $maxCountMergeCellsPerRecord or $i == $countMergeCells) { @@ -1621,7 +1623,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter hexdec($password) ); - $recordData .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong('p' . md5($recordData)); + $recordData .= \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong('p' . md5($recordData)); $length = strlen($recordData); @@ -1694,9 +1696,9 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter { $panes = array(); if ($freezePane = $this->phpSheet->getFreezePane()) { - list($column, $row) = PHPExcel_Cell::coordinateFromString($freezePane); + list($column, $row) = \PHPExcel\Cell::coordinateFromString($freezePane); $panes[0] = $row - 1; - $panes[1] = PHPExcel_Cell::columnIndexFromString($column) - 1; + $panes[1] = \PHPExcel\Cell::columnIndexFromString($column) - 1; } else { // thaw panes return; @@ -1844,7 +1846,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter } */ - $recordData = PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($this->phpSheet->getHeaderFooter()->getOddHeader()); + $recordData = \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($this->phpSheet->getHeaderFooter()->getOddHeader()); $length = strlen($recordData); $header = pack("vv", $record, $length); @@ -1868,7 +1870,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter } */ - $recordData = PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($this->phpSheet->getHeaderFooter()->getOddFooter()); + $recordData = \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($this->phpSheet->getHeaderFooter()->getOddFooter()); $length = strlen($recordData); $header = pack("vv", $record, $length); @@ -2040,7 +2042,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $record = 0x009D; // Record identifier $length = 0x0002; // Bytes to follow - $rangeBounds = PHPExcel_Cell::rangeBoundaries($this->phpSheet->getAutoFilter()->getRange()); + $rangeBounds = \PHPExcel\Cell::rangeBoundaries($this->phpSheet->getAutoFilter()->getRange()); $iNumFilters = 1 + $rangeBounds[1][0] - $rangeBounds[0][0]; $header = pack("vv", $record, $length); @@ -2142,13 +2144,13 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter foreach ($this->phpSheet->getBreaks() as $cell => $breakType) { // Fetch coordinates - $coordinates = PHPExcel_Cell::coordinateFromString($cell); + $coordinates = \PHPExcel\Cell::coordinateFromString($cell); // Decide what to do by the type of break switch ($breakType) { case \PHPExcel\Worksheet::BREAK_COLUMN: // Add to list of vertical breaks - $vbreaks[] = PHPExcel_Cell::columnIndexFromString($coordinates[0]) - 1; + $vbreaks[] = \PHPExcel\Cell::columnIndexFromString($coordinates[0]) - 1; break; case \PHPExcel\Worksheet::BREAK_ROW: // Add to list of horizontal breaks @@ -2395,10 +2397,10 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $row_end = $row_start; // Row containing bottom right corner of object // Zero the specified offset if greater than the cell dimensions - if ($x1 >= PHPExcel_Shared_Excel5::sizeCol($this->phpSheet, PHPExcel_Cell::stringFromColumnIndex($col_start))) { + if ($x1 >= \PHPExcel\Shared\Excel5::sizeCol($this->phpSheet, \PHPExcel\Cell::stringFromColumnIndex($col_start))) { $x1 = 0; } - if ($y1 >= PHPExcel_Shared_Excel5::sizeRow($this->phpSheet, $row_start + 1)) { + if ($y1 >= \PHPExcel\Shared\Excel5::sizeRow($this->phpSheet, $row_start + 1)) { $y1 = 0; } @@ -2406,38 +2408,38 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $height = $height + $y1 -1; // Subtract the underlying cell widths to find the end cell of the image - while ($width >= PHPExcel_Shared_Excel5::sizeCol($this->phpSheet, PHPExcel_Cell::stringFromColumnIndex($col_end))) { - $width -= PHPExcel_Shared_Excel5::sizeCol($this->phpSheet, PHPExcel_Cell::stringFromColumnIndex($col_end)); + while ($width >= \PHPExcel\Shared\Excel5::sizeCol($this->phpSheet, \PHPExcel\Cell::stringFromColumnIndex($col_end))) { + $width -= \PHPExcel\Shared\Excel5::sizeCol($this->phpSheet, \PHPExcel\Cell::stringFromColumnIndex($col_end)); ++$col_end; } // Subtract the underlying cell heights to find the end cell of the image - while ($height >= PHPExcel_Shared_Excel5::sizeRow($this->phpSheet, $row_end + 1)) { - $height -= PHPExcel_Shared_Excel5::sizeRow($this->phpSheet, $row_end + 1); + while ($height >= \PHPExcel\Shared\Excel5::sizeRow($this->phpSheet, $row_end + 1)) { + $height -= \PHPExcel\Shared\Excel5::sizeRow($this->phpSheet, $row_end + 1); ++$row_end; } // Bitmap isn't allowed to start or finish in a hidden cell, i.e. a cell // with zero eight or width. // - if (PHPExcel_Shared_Excel5::sizeCol($this->phpSheet, PHPExcel_Cell::stringFromColumnIndex($col_start)) == 0) { + if (\PHPExcel\Shared\Excel5::sizeCol($this->phpSheet, \PHPExcel\Cell::stringFromColumnIndex($col_start)) == 0) { return; } - if (PHPExcel_Shared_Excel5::sizeCol($this->phpSheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) == 0) { + if (\PHPExcel\Shared\Excel5::sizeCol($this->phpSheet, \PHPExcel\Cell::stringFromColumnIndex($col_end)) == 0) { return; } - if (PHPExcel_Shared_Excel5::sizeRow($this->phpSheet, $row_start + 1) == 0) { + if (\PHPExcel\Shared\Excel5::sizeRow($this->phpSheet, $row_start + 1) == 0) { return; } - if (PHPExcel_Shared_Excel5::sizeRow($this->phpSheet, $row_end + 1) == 0) { + if (\PHPExcel\Shared\Excel5::sizeRow($this->phpSheet, $row_end + 1) == 0) { return; } // Convert the pixel values to the percentage value expected by Excel - $x1 = $x1 / PHPExcel_Shared_Excel5::sizeCol($this->phpSheet, PHPExcel_Cell::stringFromColumnIndex($col_start)) * 1024; - $y1 = $y1 / PHPExcel_Shared_Excel5::sizeRow($this->phpSheet, $row_start + 1) * 256; - $x2 = $width / PHPExcel_Shared_Excel5::sizeCol($this->phpSheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object - $y2 = $height / PHPExcel_Shared_Excel5::sizeRow($this->phpSheet, $row_end + 1) * 256; // Distance to bottom of object + $x1 = $x1 / \PHPExcel\Shared\Excel5::sizeCol($this->phpSheet, \PHPExcel\Cell::stringFromColumnIndex($col_start)) * 1024; + $y1 = $y1 / \PHPExcel\Shared\Excel5::sizeRow($this->phpSheet, $row_start + 1) * 256; + $x2 = $width / \PHPExcel\Shared\Excel5::sizeCol($this->phpSheet, \PHPExcel\Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object + $y2 = $height / \PHPExcel\Shared\Excel5::sizeRow($this->phpSheet, $row_end + 1) * 256; // Distance to bottom of object $this->writeObjPicture($col_start, $x1, $row_start, $y1, $col_end, $x2, $row_end, $y2); } @@ -2659,7 +2661,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter /** * Get Escher object * - * @return PHPExcel_Shared_Escher + * @return \PHPExcel\Shared\Escher */ public function getEscher() { @@ -2669,9 +2671,9 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter /** * Set Escher object * - * @param PHPExcel_Shared_Escher $pValue + * @param \PHPExcel\Shared\Escher $pValue */ - public function setEscher(PHPExcel_Shared_Escher $pValue = null) + public function setEscher(\PHPExcel\Shared\Escher $pValue = null) { $this->escher = $pValue; } @@ -2683,7 +2685,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter { // write the Escher stream if necessary if (isset($this->escher)) { - $writer = new PHPExcel_Writer_Excel5_Escher($this->escher); + $writer = new \PHPExcel\Writer\Excel5\Escher($this->escher); $data = $writer->close(); $spOffsets = $writer->getSpOffsets(); $spTypes = $writer->getSpTypes(); @@ -2797,28 +2799,28 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter // data type $type = $dataValidation->getType(); switch ($type) { - case PHPExcel_Cell_DataValidation::TYPE_NONE: + case \PHPExcel\Cell\DataValidation::TYPE_NONE: $type = 0x00; break; - case PHPExcel_Cell_DataValidation::TYPE_WHOLE: + case \PHPExcel\Cell\DataValidation::TYPE_WHOLE: $type = 0x01; break; - case PHPExcel_Cell_DataValidation::TYPE_DECIMAL: + case \PHPExcel\Cell\DataValidation::TYPE_DECIMAL: $type = 0x02; break; - case PHPExcel_Cell_DataValidation::TYPE_LIST: + case \PHPExcel\Cell\DataValidation::TYPE_LIST: $type = 0x03; break; - case PHPExcel_Cell_DataValidation::TYPE_DATE: + case \PHPExcel\Cell\DataValidation::TYPE_DATE: $type = 0x04; break; - case PHPExcel_Cell_DataValidation::TYPE_TIME: + case \PHPExcel\Cell\DataValidation::TYPE_TIME: $type = 0x05; break; - case PHPExcel_Cell_DataValidation::TYPE_TEXTLENGTH: + case \PHPExcel\Cell\DataValidation::TYPE_TEXTLENGTH: $type = 0x06; break; - case PHPExcel_Cell_DataValidation::TYPE_CUSTOM: + case \PHPExcel\Cell\DataValidation::TYPE_CUSTOM: $type = 0x07; break; } @@ -2827,13 +2829,13 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter // error style $errorStyle = $dataValidation->getType(); switch ($errorStyle) { - case PHPExcel_Cell_DataValidation::STYLE_STOP: + case \PHPExcel\Cell\DataValidation::STYLE_STOP: $errorStyle = 0x00; break; - case PHPExcel_Cell_DataValidation::STYLE_WARNING: + case \PHPExcel\Cell\DataValidation::STYLE_WARNING: $errorStyle = 0x01; break; - case PHPExcel_Cell_DataValidation::STYLE_INFORMATION: + case \PHPExcel\Cell\DataValidation::STYLE_INFORMATION: $errorStyle = 0x02; break; } @@ -2859,28 +2861,28 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter // condition operator $operator = $dataValidation->getOperator(); switch ($operator) { - case PHPExcel_Cell_DataValidation::OPERATOR_BETWEEN: + case \PHPExcel\Cell\DataValidation::OPERATOR_BETWEEN: $operator = 0x00; break; - case PHPExcel_Cell_DataValidation::OPERATOR_NOTBETWEEN: + case \PHPExcel\Cell\DataValidation::OPERATOR_NOTBETWEEN: $operator = 0x01; break; - case PHPExcel_Cell_DataValidation::OPERATOR_EQUAL: + case \PHPExcel\Cell\DataValidation::OPERATOR_EQUAL: $operator = 0x02; break; - case PHPExcel_Cell_DataValidation::OPERATOR_NOTEQUAL: + case \PHPExcel\Cell\DataValidation::OPERATOR_NOTEQUAL: $operator = 0x03; break; - case PHPExcel_Cell_DataValidation::OPERATOR_GREATERTHAN: + case \PHPExcel\Cell\DataValidation::OPERATOR_GREATERTHAN: $operator = 0x04; break; - case PHPExcel_Cell_DataValidation::OPERATOR_LESSTHAN: + case \PHPExcel\Cell\DataValidation::OPERATOR_LESSTHAN: $operator = 0x05; break; - case PHPExcel_Cell_DataValidation::OPERATOR_GREATERTHANOREQUAL: + case \PHPExcel\Cell\DataValidation::OPERATOR_GREATERTHANOREQUAL: $operator = 0x06; break; - case PHPExcel_Cell_DataValidation::OPERATOR_LESSTHANOREQUAL: + case \PHPExcel\Cell\DataValidation::OPERATOR_LESSTHANOREQUAL: $operator = 0x07; break; } @@ -2891,22 +2893,22 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter // prompt title $promptTitle = $dataValidation->getPromptTitle() !== '' ? $dataValidation->getPromptTitle() : chr(0); - $data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($promptTitle); + $data .= \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($promptTitle); // error title $errorTitle = $dataValidation->getErrorTitle() !== '' ? $dataValidation->getErrorTitle() : chr(0); - $data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($errorTitle); + $data .= \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($errorTitle); // prompt text $prompt = $dataValidation->getPrompt() !== '' ? $dataValidation->getPrompt() : chr(0); - $data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($prompt); + $data .= \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($prompt); // error text $error = $dataValidation->getError() !== '' ? $dataValidation->getError() : chr(0); - $data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($error); + $data .= \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($error); // formula 1 try { @@ -2917,7 +2919,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $this->parser->parse($formula1); $formula1 = $this->parser->toReversePolish(); $sz1 = strlen($formula1); - } catch (PHPExcel_Exception $e) { + } catch (\PHPExcel\Exception $e) { $sz1 = 0; $formula1 = ''; } @@ -2933,7 +2935,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $this->parser->parse($formula2); $formula2 = $this->parser->toReversePolish(); $sz2 = strlen($formula2); - } catch (PHPExcel_Exception $e) { + } catch (\PHPExcel\Exception $e) { $sz2 = 0; $formula2 = ''; } @@ -3182,7 +3184,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $dataBlockFont = pack('VVVVVVVV', 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000); $dataBlockFont .= pack('VVVVVVVV', 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000); } else { - $dataBlockFont = PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($conditional->getStyle()->getFont()->getName()); + $dataBlockFont = \PHPExcel\Shared\String::UTF8toBIFF8UnicodeLong($conditional->getStyle()->getFont()->getName()); } // Font Size if ($conditional->getStyle()->getFont()->getSize() == null) { @@ -4208,9 +4210,9 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $arrConditional[] = $conditional->getHashCode(); } // Cells - $arrCoord = PHPExcel_Cell::coordinateFromString($cellCoordinate); + $arrCoord = \PHPExcel\Cell::coordinateFromString($cellCoordinate); if (!is_numeric($arrCoord[0])) { - $arrCoord[0] = PHPExcel_Cell::columnIndexFromString($arrCoord[0]); + $arrCoord[0] = \PHPExcel\Cell::columnIndexFromString($arrCoord[0]); } if (is_null($numColumnMin) || ($numColumnMin > $arrCoord[0])) { $numColumnMin = $arrCoord[0]; diff --git a/src/PhpSpreadsheet/Writer/Excel5/Xf.php b/src/PhpSpreadsheet/Writer/Excel5/Xf.php index 9c14b0d0..5987ecee 100644 --- a/src/PhpSpreadsheet/Writer/Excel5/Xf.php +++ b/src/PhpSpreadsheet/Writer/Excel5/Xf.php @@ -1,7 +1,9 @@