From e5915ce8d9bdbcd9d7236d23d130b0c10779a6ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Tue, 3 Nov 2015 10:48:57 +0100 Subject: [PATCH] Upgraded PHPExcel to v1.8.1 Fixes issues with PHP 7 --- COPYRIGHT | 2 +- composer.json | 2 +- composer.lock | 12 +- .../includes/phpoffice/phpexcel/.travis.yml | 6 + .../phpoffice/phpexcel/Classes/PHPExcel.php | 22 +- .../phpexcel/Classes/PHPExcel/Autoloader.php | 6 +- .../PHPExcel/CachedObjectStorage/APC.php | 6 +- .../CachedObjectStorage/CacheBase.php | 43 +- .../PHPExcel/CachedObjectStorage/DiscISAM.php | 18 +- .../PHPExcel/CachedObjectStorage/ICache.php | 8 +- .../PHPExcel/CachedObjectStorage/Igbinary.php | 4 +- .../PHPExcel/CachedObjectStorage/Memcache.php | 6 +- .../CachedObjectStorage/MemoryGZip.php | 4 +- .../CachedObjectStorage/MemorySerialized.php | 4 +- .../PHPExcel/CachedObjectStorage/PHPTemp.php | 14 +- .../PHPExcel/CachedObjectStorage/SQLite.php | 4 +- .../PHPExcel/CachedObjectStorage/SQLite3.php | 4 +- .../PHPExcel/CachedObjectStorage/Wincache.php | 4 +- .../CalcEngine/CyclicReferenceStack.php | 12 +- .../phpexcel/Classes/PHPExcel/Calculation.php | 105 +- .../Classes/PHPExcel/Calculation/DateTime.php | 20 +- .../PHPExcel/Calculation/Functions.php | 5 +- .../PHPExcel/Calculation/LookupRef.php | 9 +- .../Classes/PHPExcel/Calculation/MathTrig.php | 51 +- .../PHPExcel/Calculation/Statistical.php | 2 +- .../Classes/PHPExcel/Calculation/TextData.php | 48 +- .../phpexcel/Classes/PHPExcel/Cell.php | 56 +- .../PHPExcel/Cell/DefaultValueBinder.php | 32 +- .../phpexcel/Classes/PHPExcel/Chart.php | 86 +- .../phpexcel/Classes/PHPExcel/Chart/Axis.php | 584 ++++ .../Classes/PHPExcel/Chart/DataSeries.php | 7 +- .../Classes/PHPExcel/Chart/GridLines.php | 458 +++ .../Classes/PHPExcel/Chart/Properties.php | 359 +++ .../PHPExcel/Chart/Renderer/jpgraph.php | 34 +- .../phpexcel/Classes/PHPExcel/Helper/HTML.php | 762 +++++ .../Classes/PHPExcel/Reader/Abstract.php | 30 +- .../phpexcel/Classes/PHPExcel/Reader/CSV.php | 28 - .../Classes/PHPExcel/Reader/Excel2003XML.php | 29 +- .../Classes/PHPExcel/Reader/Excel2007.php | 284 +- .../Classes/PHPExcel/Reader/Excel5.php | 4 + .../Classes/PHPExcel/Reader/Gnumeric.php | 10 +- .../phpexcel/Classes/PHPExcel/Reader/HTML.php | 804 ++--- .../Classes/PHPExcel/Reader/IReader.php | 1 + .../Classes/PHPExcel/Reader/OOCalc.php | 20 +- .../phpexcel/Classes/PHPExcel/Settings.php | 12 +- .../Classes/PHPExcel/Shared/CodePage.php | 14 +- .../phpexcel/Classes/PHPExcel/Shared/Date.php | 2 +- .../phpexcel/Classes/PHPExcel/Shared/Font.php | 56 +- .../Classes/PHPExcel/Shared/JAMA/Matrix.php | 4 +- .../Shared/OLE/ChainedBlockStream.php | 8 - .../PHPExcel/Shared/PCLZip/pclzip.lib.php | 3 - .../Classes/PHPExcel/Shared/String.php | 39 +- .../Classes/PHPExcel/Shared/ZipArchive.php | 2 +- .../Classes/PHPExcel/Style/Alignment.php | 91 +- .../Classes/PHPExcel/Style/NumberFormat.php | 20 +- .../phpexcel/Classes/PHPExcel/Worksheet.php | 66 +- .../Classes/PHPExcel/Worksheet/AutoFilter.php | 6 +- .../Worksheet/AutoFilter/Column/Rule.php | 2 +- .../PHPExcel/Worksheet/BaseDrawing.php | 14 +- .../PHPExcel/Worksheet/CellIterator.php | 102 +- .../Classes/PHPExcel/Worksheet/Column.php | 92 + .../PHPExcel/Worksheet/ColumnCellIterator.php | 215 ++ .../PHPExcel/Worksheet/ColumnIterator.php | 192 ++ .../Classes/PHPExcel/Worksheet/Row.php | 6 +- .../PHPExcel/Worksheet/RowCellIterator.php | 224 ++ .../PHPExcel/Worksheet/RowDimension.php | 4 +- .../PHPExcel/Worksheet/RowIterator.php | 45 +- .../PHPExcel/Writer/Excel2007/Chart.php | 2737 ++++++++++------- .../PHPExcel/Writer/Excel2007/Style.php | 3 + .../PHPExcel/Writer/Excel2007/Worksheet.php | 4 +- .../Classes/PHPExcel/Writer/Excel5/Parser.php | 1 + .../PHPExcel/Writer/Excel5/Worksheet.php | 2 +- .../phpexcel/Classes/PHPExcel/Writer/HTML.php | 40 +- .../Classes/PHPExcel/Writer/OpenDocument.php | 200 ++ .../Writer/OpenDocument/Cell/Comment.php | 63 + .../PHPExcel/Writer/OpenDocument/Content.php | 272 ++ .../PHPExcel/Writer/OpenDocument/Meta.php | 98 + .../PHPExcel/Writer/OpenDocument/MetaInf.php | 96 + .../PHPExcel/Writer/OpenDocument/Mimetype.php | 50 + .../PHPExcel/Writer/OpenDocument/Settings.php | 85 + .../PHPExcel/Writer/OpenDocument/Styles.php | 101 + .../Writer/OpenDocument/Thumbnails.php | 50 + .../Writer/OpenDocument/WriterPart.php | 38 + .../phpexcel/Classes/PHPExcel/Writer/PDF.php | 9 +- .../Classes/PHPExcel/Writer/PDF/DomPDF.php | 4 +- .../Examples/01simple-download-ods.php | 89 + .../phpexcel/Examples/05featuredemo.inc.php | 3 +- .../phpexcel/Examples/13calculation.php | 1 + .../phpexcel/Examples/33chartcreate-area.php | 8 +- .../Examples/33chartcreate-bar-stacked.php | 8 +- .../phpexcel/Examples/33chartcreate-bar.php | 8 +- .../Examples/33chartcreate-column-2.php | 8 +- .../Examples/33chartcreate-column.php | 8 +- .../Examples/33chartcreate-composite.php | 16 +- .../phpexcel/Examples/33chartcreate-line.php | 8 +- .../33chartcreate-multiple-charts.php | 16 +- .../phpexcel/Examples/33chartcreate-pie.php | 20 +- .../phpexcel/Examples/33chartcreate-radar.php | 10 +- .../Examples/33chartcreate-scatter.php | 8 +- .../phpexcel/Examples/33chartcreate-stock.php | 8 +- .../phpexcel/Examples/34chartupdate.php | 2 +- .../phpexcel/Examples/35chartrender.php | 2 +- .../phpexcel/Examples/39dropdown.php | 175 ++ .../phpexcel/Examples/41password.php | 84 + .../phpexcel/Examples/42richText.php | 159 + .../Examples/data/continents/Africa.txt | 54 + .../Examples/data/continents/Asia.txt | 44 + .../Examples/data/continents/Europe.txt | 47 + .../data/continents/North America.txt | 23 + .../Examples/data/continents/Oceania.txt | 14 + .../data/continents/South America.txt | 12 + .../phpoffice/phpexcel/Examples/runall.php | 6 +- .../includes/phpoffice/phpexcel/changelog.txt | 42 +- .../PHPExcel/Calculation/DateTimeTest.php | 2 + .../PHPExcel/Calculation/EngineeringTest.php | 2 + .../PHPExcel/Calculation/FinancialTest.php | 2 + .../PHPExcel/Calculation/FunctionsTest.php | 2 + .../PHPExcel/Calculation/LogicalTest.php | 2 + .../PHPExcel/Calculation/LookupRefTest.php | 2 + .../PHPExcel/Calculation/MathTrigTest.php | 2 + .../PHPExcel/Calculation/TextDataTest.php | 22 + .../Classes/PHPExcel/CalculationTest.php | 2 + .../PHPExcel/Cell/DefaultValueBinderTest.php | 85 + .../PHPExcel/Reader/XEEValidatorTest.php | 55 + .../Worksheet/AutoFilter/ColumnTest.php | 2 +- .../Worksheet/ColumnCellIteratorTest.php | 87 + .../PHPExcel/Worksheet/ColumnIteratorTest.php | 89 + .../Worksheet/RowCellIteratorTest.php | 89 + .../PHPExcel/Worksheet/RowIteratorTest.php | 87 + .../Worksheet/WorksheetColumnTest.php | 46 + .../PHPExcel/Worksheet/WorksheetRowTest.php | 46 + .../phpoffice/phpexcel/unitTests/phpunit.xml | 3 + .../Calculation/MathTrig/MINVERSE.data | 7 +- .../Calculation/MathTrig/MMULT.data | 19 +- .../Calculation/TextData/TRIM.data | 2 +- .../Calculation/TextData/VALUE.data | 10 + .../rawTestData/Cell/DefaultValueBinder.data | 19 + .../Reader/XEETestInvalidUTF-16.xml | Bin 0 -> 276 bytes .../Reader/XEETestInvalidUTF-16BE.xml | Bin 0 -> 278 bytes .../Reader/XEETestInvalidUTF-16LE.xml | Bin 0 -> 278 bytes .../Reader/XEETestInvalidUTF-8.xml | 8 + .../rawTestData/Reader/XEETestValidUTF-16.xml | Bin 0 -> 176 bytes .../Reader/XEETestValidUTF-16BE.xml | Bin 0 -> 178 bytes .../Reader/XEETestValidUTF-16LE.xml | Bin 0 -> 178 bytes .../rawTestData/Reader/XEETestValidUTF-8.xml | 4 + .../rawTestData/Style/NumberFormat.data | 3 + 146 files changed, 8438 insertions(+), 2225 deletions(-) create mode 100644 htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/Axis.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/GridLines.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/Properties.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Helper/HTML.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/Column.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/ColumnCellIterator.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/ColumnIterator.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/RowCellIterator.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Cell/Comment.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Content.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Meta.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/MetaInf.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Mimetype.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Settings.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Styles.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Thumbnails.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/WriterPart.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Examples/01simple-download-ods.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Examples/39dropdown.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Examples/41password.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Examples/42richText.php create mode 100644 htdocs/includes/phpoffice/phpexcel/Examples/data/continents/Africa.txt create mode 100644 htdocs/includes/phpoffice/phpexcel/Examples/data/continents/Asia.txt create mode 100644 htdocs/includes/phpoffice/phpexcel/Examples/data/continents/Europe.txt create mode 100644 htdocs/includes/phpoffice/phpexcel/Examples/data/continents/North America.txt create mode 100644 htdocs/includes/phpoffice/phpexcel/Examples/data/continents/Oceania.txt create mode 100644 htdocs/includes/phpoffice/phpexcel/Examples/data/continents/South America.txt create mode 100644 htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Cell/DefaultValueBinderTest.php create mode 100644 htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Reader/XEEValidatorTest.php create mode 100644 htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/ColumnCellIteratorTest.php create mode 100644 htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/ColumnIteratorTest.php create mode 100644 htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/RowCellIteratorTest.php create mode 100644 htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/RowIteratorTest.php create mode 100644 htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/WorksheetColumnTest.php create mode 100644 htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/WorksheetRowTest.php create mode 100644 htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Calculation/TextData/VALUE.data create mode 100644 htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Cell/DefaultValueBinder.data create mode 100644 htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Reader/XEETestInvalidUTF-16.xml create mode 100644 htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Reader/XEETestInvalidUTF-16BE.xml create mode 100644 htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Reader/XEETestInvalidUTF-16LE.xml create mode 100644 htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Reader/XEETestInvalidUTF-8.xml create mode 100644 htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Reader/XEETestValidUTF-16.xml create mode 100644 htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Reader/XEETestValidUTF-16BE.xml create mode 100644 htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Reader/XEETestValidUTF-16LE.xml create mode 100644 htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Reader/XEETestValidUTF-8.xml diff --git a/COPYRIGHT b/COPYRIGHT index a6cde40b504..621be689df6 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -24,7 +24,7 @@ Mobiledetect 2.8.3 MIT License Yes NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package) PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency odtPHP 1.0.1 GPL-2+ b Yes Library to build/edit ODT files -PHPExcel 1.8.0 LGPL-2.1+ Yes Read/Write XLS files, read ODS files +PHPExcel 1.8.1 LGPL-2.1+ Yes Read/Write XLS files, read ODS files php-iban 1.4.7 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP PHPoAuthLib 0.8.2 MIT License Yes Library to provide oauth1 and oauth2 to different service PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests diff --git a/composer.json b/composer.json index ed02c885318..3cce643b66d 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "ckeditor/ckeditor": "dev-full/4.3.x#0b7c3f1", "mike42/escpos-php": "dev-master", "mobiledetect/mobiledetectlib": "2.8.3", - "phpoffice/phpexcel": "1.8.0", + "phpoffice/phpexcel": "1.8.1", "restler/framework": "^3.0", "tecnick.com/tcpdf": "6.2.6", "raven/raven": "^0.12.0", diff --git a/composer.lock b/composer.lock index 6acfca565c3..9b2eb93c792 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "4dfedf298cf48a9a69726e02121890aa", + "hash": "1c6ca041da94484642adcbde492ad50b", "packages": [ { "name": "ccampbell/chromephp", @@ -238,16 +238,16 @@ }, { "name": "phpoffice/phpexcel", - "version": "1.8.0", + "version": "1.8.1", "source": { "type": "git", "url": "https://github.com/PHPOffice/PHPExcel.git", - "reference": "e69a5e4d0ffa7fb6f171859e0a04346e580df30b" + "reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/e69a5e4d0ffa7fb6f171859e0a04346e580df30b", - "reference": "e69a5e4d0ffa7fb6f171859e0a04346e580df30b", + "url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/372c7cbb695a6f6f1e62649381aeaa37e7e70b32", + "reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32", "shasum": "" }, "require": { @@ -291,7 +291,7 @@ "xls", "xlsx" ], - "time": "2014-03-02 15:22:49" + "time": "2015-05-01 07:00:55" }, { "name": "raven/raven", diff --git a/htdocs/includes/phpoffice/phpexcel/.travis.yml b/htdocs/includes/phpoffice/phpexcel/.travis.yml index 8b53bf22ea2..c35625b132f 100644 --- a/htdocs/includes/phpoffice/phpexcel/.travis.yml +++ b/htdocs/includes/phpoffice/phpexcel/.travis.yml @@ -6,6 +6,12 @@ php: - 5.3 - 5.4 - 5.5 + - 5.6 + - hhvm + +matrix: + allow_failures: + - php: hhvm script: - phpunit -c ./unitTests/ diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel.php index e01581a243d..d27de51a2b3 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel.php @@ -461,10 +461,12 @@ class PHPExcel * Get active sheet * * @return PHPExcel_Worksheet + * + * @throws PHPExcel_Exception */ public function getActiveSheet() { - return $this->_workSheetCollection[$this->_activeSheetIndex]; + return $this->getSheet($this->_activeSheetIndex); } /** @@ -570,16 +572,14 @@ class PHPExcel */ public function getSheet($pIndex = 0) { - - $numSheets = count($this->_workSheetCollection); - - if ($pIndex > $numSheets - 1) { + if (!isset($this->_workSheetCollection[$pIndex])) { + $numSheets = $this->getSheetCount(); throw new PHPExcel_Exception( - "Your requested sheet index: {$pIndex} is out of bounds. The actual number of sheets is {$numSheets}." - ); - } else { - return $this->_workSheetCollection[$pIndex]; + "Your requested sheet index: {$pIndex} is out of bounds. The actual number of sheets is {$numSheets}." + ); } + + return $this->_workSheetCollection[$pIndex]; } /** @@ -682,7 +682,7 @@ class PHPExcel */ public function setActiveSheetIndex($pIndex = 0) { - $numSheets = count($this->_workSheetCollection); + $numSheets = count($this->_workSheetCollection); if ($pIndex > $numSheets - 1) { throw new PHPExcel_Exception( @@ -1011,7 +1011,7 @@ class PHPExcel */ public function getCellStyleXfByHashCode($pValue = '') { - foreach ($this->_cellXfStyleCollection as $cellStyleXf) { + foreach ($this->_cellStyleXfCollection as $cellStyleXf) { if ($cellStyleXf->getHashCode() == $pValue) { return $cellStyleXf; } diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Autoloader.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Autoloader.php index 221666f99bc..f0b2251636f 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Autoloader.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Autoloader.php @@ -55,7 +55,11 @@ class PHPExcel_Autoloader spl_autoload_register('__autoload'); } // Register ourselves with SPL - return spl_autoload_register(array('PHPExcel_Autoloader', 'Load')); + if (version_compare(PHP_VERSION, '5.3.0') >= 0) { + return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'), true, true); + } else { + return spl_autoload_register(array('PHPExcel_Autoloader', 'Load')); + } } // function Register() diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/APC.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/APC.php index c256919da5a..8bde7fe3e57 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/APC.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/APC.php @@ -80,7 +80,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach * @access public * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update - * @return void + * @return PHPExcel_Cell * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { @@ -102,7 +102,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach * * @access public * @param string $pCoord Coordinate address of the cell to check - * @return void + * @throws PHPExcel_Exception * @return boolean */ public function isDataSet($pCoord) { @@ -165,7 +165,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach /** * Get a list of all cell addresses currently held in cache * - * @return array of string + * @return string[] */ public function getCellList() { if ($this->_currentObjectID !== null) { diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/CacheBase.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/CacheBase.php index cc7ffd0cc44..ab2bf4ea718 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/CacheBase.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/CacheBase.php @@ -136,7 +136,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase { * Add or Update a cell in cache * * @param PHPExcel_Cell $cell Cell to update - * @return void + * @return PHPExcel_Cell * @throws PHPExcel_Exception */ public function updateCacheData(PHPExcel_Cell $cell) { @@ -151,7 +151,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase { * @throws PHPExcel_Exception */ public function deleteCacheData($pCoord) { - if ($pCoord === $this->_currentObjectID) { + if ($pCoord === $this->_currentObjectID && !is_null($this->_currentObject)) { $this->_currentObject->detach(); $this->_currentObjectID = $this->_currentObject = null; } @@ -167,7 +167,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase { /** * Get a list of all cell addresses currently held in cache * - * @return array of string + * @return string[] */ public function getCellList() { return array_keys($this->_cellCache); @@ -177,7 +177,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase { /** * Sort the list of all cell addresses currently held in cache by row and column * - * @return void + * @return string[] */ public function getSortedCellList() { $sortKeys = array(); @@ -206,7 +206,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase { sscanf($coord,'%[A-Z]%d', $c, $r); $row[$r] = $r; $col[$c] = strlen($c).$c; - } + } if (!empty($row)) { // Determine highest column and row $highestRow = max($row); @@ -243,12 +243,12 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase { /** * Return the row address of the currently active cell object * - * @return string + * @return integer */ public function getCurrentRow() { sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row); - return $row; + return (integer) $row; } /** @@ -333,6 +333,35 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase { } } // function copyCellCollection() + /** + * Remove a row, deleting all cells in that row + * + * @param string $row Row number to remove + * @return void + */ + public function removeRow($row) { + foreach ($this->getCellList() as $coord) { + sscanf($coord,'%[A-Z]%d', $c, $r); + if ($r == $row) { + $this->deleteCacheData($coord); + } + } + } + + /** + * Remove a column, deleting all cells in that column + * + * @param string $column Column ID to remove + * @return void + */ + public function removeColumn($column) { + foreach ($this->getCellList() as $coord) { + sscanf($coord,'%[A-Z]%d', $c, $r); + if ($c == $column) { + $this->deleteCacheData($coord); + } + } + } /** * Identify whether the caching method is currently available diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php index abea93f8a5a..c0e2ebcbdc8 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php @@ -69,11 +69,11 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage $this->_currentObject->detach(); fseek($this->_fileHandle,0,SEEK_END); - $offset = ftell($this->_fileHandle); - fwrite($this->_fileHandle, serialize($this->_currentObject)); - $this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset, - 'sz' => ftell($this->_fileHandle) - $offset - ); + + $this->_cellCache[$this->_currentObjectID] = array( + 'ptr' => ftell($this->_fileHandle), + 'sz' => fwrite($this->_fileHandle, serialize($this->_currentObject)) + ); $this->_currentCellIsDirty = false; } $this->_currentObjectID = $this->_currentObject = null; @@ -85,7 +85,7 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage * * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update - * @return void + * @return PHPExcel_Cell * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { @@ -122,8 +122,8 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage // Set current entry to the requested entry $this->_currentObjectID = $pCoord; - fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']); - $this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz'])); + fseek($this->_fileHandle, $this->_cellCache[$pCoord]['ptr']); + $this->_currentObject = unserialize(fread($this->_fileHandle, $this->_cellCache[$pCoord]['sz'])); // Re-attach this as the cell's parent $this->_currentObject->attach($this); @@ -135,7 +135,7 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage /** * Get a list of all cell addresses currently held in cache * - * @return array of string + * @return string[] */ public function getCellList() { if ($this->_currentObjectID !== null) { diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/ICache.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/ICache.php index 7686f3c4b09..220905cd46a 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/ICache.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/ICache.php @@ -40,7 +40,7 @@ interface PHPExcel_CachedObjectStorage_ICache * * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update - * @return void + * @return PHPExcel_Cell * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell); @@ -49,7 +49,7 @@ interface PHPExcel_CachedObjectStorage_ICache * Add or Update a cell in cache * * @param PHPExcel_Cell $cell Cell to update - * @return void + * @return PHPExcel_Cell * @throws PHPExcel_Exception */ public function updateCacheData(PHPExcel_Cell $cell); @@ -82,14 +82,14 @@ interface PHPExcel_CachedObjectStorage_ICache /** * Get a list of all cell addresses currently held in cache * - * @return array of string + * @return string[] */ public function getCellList(); /** * Get the list of all cell addresses currently held in cache sorted by column and row * - * @return void + * @return string[] */ public function getSortedCellList(); diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/Igbinary.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/Igbinary.php index 5cc7220c848..0258511f92e 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/Igbinary.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/Igbinary.php @@ -58,7 +58,7 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage * * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update - * @return void + * @return PHPExcel_Cell * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { @@ -107,7 +107,7 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage /** * Get a list of all cell addresses currently held in cache * - * @return array of string + * @return string[] */ public function getCellList() { if ($this->_currentObjectID !== null) { diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/Memcache.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/Memcache.php index 2896c752159..4b959dbde1f 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/Memcache.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/Memcache.php @@ -86,7 +86,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage * * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update - * @return void + * @return PHPExcel_Cell * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { @@ -107,7 +107,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? * * @param string $pCoord Coordinate address of the cell to check - * @return void + * @return boolean * @return boolean */ public function isDataSet($pCoord) { @@ -169,7 +169,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage /** * Get a list of all cell addresses currently held in cache * - * @return array of string + * @return string[] */ public function getCellList() { if ($this->_currentObjectID !== null) { diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/MemoryGZip.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/MemoryGZip.php index 9c866ca3ddf..5a0227f7184 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/MemoryGZip.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/MemoryGZip.php @@ -58,7 +58,7 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora * * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update - * @return void + * @return PHPExcel_Cell * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { @@ -107,7 +107,7 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora /** * Get a list of all cell addresses currently held in cache * - * @return array of string + * @return string[] */ public function getCellList() { if ($this->_currentObjectID !== null) { diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/MemorySerialized.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/MemorySerialized.php index cdded69698f..a922b19a17c 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/MemorySerialized.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/MemorySerialized.php @@ -58,7 +58,7 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec * * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update - * @return void + * @return PHPExcel_Cell * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { @@ -107,7 +107,7 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec /** * Get a list of all cell addresses currently held in cache * - * @return array of string + * @return string[] */ public function getCellList() { if ($this->_currentObjectID !== null) { diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/PHPTemp.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/PHPTemp.php index 17a1c4b0eb8..8a6364aed3e 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/PHPTemp.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/PHPTemp.php @@ -61,11 +61,11 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_ $this->_currentObject->detach(); fseek($this->_fileHandle,0,SEEK_END); - $offset = ftell($this->_fileHandle); - fwrite($this->_fileHandle, serialize($this->_currentObject)); - $this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset, - 'sz' => ftell($this->_fileHandle) - $offset - ); + + $this->_cellCache[$this->_currentObjectID] = array( + 'ptr' => ftell($this->_fileHandle), + 'sz' => fwrite($this->_fileHandle, serialize($this->_currentObject)) + ); $this->_currentCellIsDirty = false; } $this->_currentObjectID = $this->_currentObject = null; @@ -77,7 +77,7 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_ * * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update - * @return void + * @return PHPExcel_Cell * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { @@ -127,7 +127,7 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_ /** * Get a list of all cell addresses currently held in cache * - * @return array of string + * @return string[] */ public function getCellList() { if ($this->_currentObjectID !== null) { diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/SQLite.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/SQLite.php index 6c8e65cb3a3..e752e853e5c 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/SQLite.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/SQLite.php @@ -73,7 +73,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C * * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update - * @return void + * @return PHPExcel_Cell * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { @@ -198,7 +198,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C /** * Get a list of all cell addresses currently held in cache * - * @return array of string + * @return string[] */ public function getCellList() { if ($this->_currentObjectID !== null) { diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/SQLite3.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/SQLite3.php index da27ad1a840..4f38c0319b1 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/SQLite3.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/SQLite3.php @@ -104,7 +104,7 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ * * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update - * @return void + * @return PHPExcel_Cell * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { @@ -231,7 +231,7 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ /** * Get a list of all cell addresses currently held in cache * - * @return array of string + * @return string[] */ public function getCellList() { if ($this->_currentObjectID !== null) { diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/Wincache.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/Wincache.php index 7ff27893034..ed475dfba7e 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/Wincache.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/Wincache.php @@ -85,7 +85,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage * * @param string $pCoord Coordinate address of the cell to update * @param PHPExcel_Cell $cell Cell to update - * @return void + * @return PHPExcel_Cell * @throws PHPExcel_Exception */ public function addCacheData($pCoord, PHPExcel_Cell $cell) { @@ -169,7 +169,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage /** * Get a list of all cell addresses currently held in cache * - * @return array of string + * @return string[] */ public function getCellList() { if ($this->_currentObjectID !== null) { diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CalcEngine/CyclicReferenceStack.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CalcEngine/CyclicReferenceStack.php index a633c2c3ab7..5cd0b909e47 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CalcEngine/CyclicReferenceStack.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/CalcEngine/CyclicReferenceStack.php @@ -58,8 +58,8 @@ class PHPExcel_CalcEngine_CyclicReferenceStack { * @param mixed $value */ public function push($value) { - $this->_stack[] = $value; - } // function push() + $this->_stack[$value] = $value; + } /** * Pop the last entry from the stack @@ -68,7 +68,7 @@ class PHPExcel_CalcEngine_CyclicReferenceStack { */ public function pop() { return array_pop($this->_stack); - } // function pop() + } /** * Test to see if a specified entry exists on the stack @@ -76,7 +76,7 @@ class PHPExcel_CalcEngine_CyclicReferenceStack { * @param mixed $value The value to test */ public function onStack($value) { - return in_array($value, $this->_stack); + return isset($this->_stack[$value]); } /** @@ -84,7 +84,7 @@ class PHPExcel_CalcEngine_CyclicReferenceStack { */ public function clear() { $this->_stack = array(); - } // function push() + } /** * Return an array of all entries on the stack @@ -95,4 +95,4 @@ class PHPExcel_CalcEngine_CyclicReferenceStack { return $this->_stack; } -} // class PHPExcel_CalcEngine_CyclicReferenceStack +} diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation.php index 6159be9ba90..48fb4a422f2 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation.php @@ -194,6 +194,8 @@ class PHPExcel_Calculation { */ private $_cyclicReferenceStack; + private $_cellStack = array(); + /** * Current iteration counter for cyclic formulae * If the value is 0 (or less) then cyclic formulae will throw an exception, @@ -202,7 +204,7 @@ class PHPExcel_Calculation { * @var integer * */ - private $_cyclicFormulaCount = 0; + private $_cyclicFormulaCount = 1; private $_cyclicFormulaCell = ''; @@ -212,7 +214,7 @@ class PHPExcel_Calculation { * @var integer * */ - public $cyclicFormulaCount = 0; + public $cyclicFormulaCount = 1; /** * Precision used for calculations @@ -1626,7 +1628,7 @@ class PHPExcel_Calculation { 'argumentCount' => '2' ), 'VALUE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA, - 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', + 'functionCall' => 'PHPExcel_Calculation_TextData::VALUE', 'argumentCount' => '1' ), 'VAR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL, @@ -1724,6 +1726,7 @@ class PHPExcel_Calculation { if ($this->_savedPrecision < $setPrecision) { ini_set('precision',$setPrecision); } + $this->delta = 1 * pow(10, -$setPrecision); if ($workbook !== NULL) { self::$_workbookSets[$workbook->getID()] = $this; @@ -2240,9 +2243,17 @@ class PHPExcel_Calculation { } // Execute the calculation for the cell formula + $this->_cellStack[] = array( + 'sheet' => $pCell->getWorksheet()->getTitle(), + 'cell' => $pCell->getCoordinate(), + ); try { $result = self::_unwrapResult($this->_calculateFormulaValue($pCell->getValue(), $pCell->getCoordinate(), $pCell)); + $cellAddress = array_pop($this->_cellStack); + $this->_workbook->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']); } catch (PHPExcel_Exception $e) { + $cellAddress = array_pop($this->_cellStack); + $this->_workbook->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']); throw new PHPExcel_Calculation_Exception($e->getMessage()); } @@ -2333,24 +2344,22 @@ class PHPExcel_Calculation { } // function calculateFormula() - public function getValueFromCache($worksheetName, $cellID, &$cellValue) { + public function getValueFromCache($cellReference, &$cellValue) { // Is calculation cacheing enabled? // Is the value present in calculation cache? -//echo 'Test cache for ',$worksheetName,'!',$cellID,PHP_EOL; - $this->_debugLog->writeDebugLog('Testing cache value for cell ', $worksheetName, '!', $cellID); - if (($this->_calculationCacheEnabled) && (isset($this->_calculationCache[$worksheetName][$cellID]))) { -//echo 'Retrieve from cache',PHP_EOL; - $this->_debugLog->writeDebugLog('Retrieving value for cell ', $worksheetName, '!', $cellID, ' from cache'); + $this->_debugLog->writeDebugLog('Testing cache value for cell ', $cellReference); + if (($this->_calculationCacheEnabled) && (isset($this->_calculationCache[$cellReference]))) { + $this->_debugLog->writeDebugLog('Retrieving value for cell ', $cellReference, ' from cache'); // Return the cached result - $cellValue = $this->_calculationCache[$worksheetName][$cellID]; + $cellValue = $this->_calculationCache[$cellReference]; return TRUE; } return FALSE; } - public function saveValueToCache($worksheetName, $cellID, $cellValue) { + public function saveValueToCache($cellReference, $cellValue) { if ($this->_calculationCacheEnabled) { - $this->_calculationCache[$worksheetName][$cellID] = $cellValue; + $this->_calculationCache[$cellReference] = $cellValue; } } @@ -2364,49 +2373,49 @@ class PHPExcel_Calculation { * @throws PHPExcel_Calculation_Exception */ public function _calculateFormulaValue($formula, $cellID=null, PHPExcel_Cell $pCell = null) { - $cellValue = ''; + $cellValue = null; // Basic validation that this is indeed a formula // We simply return the cell value if not $formula = trim($formula); if ($formula{0} != '=') return self::_wrapResult($formula); - $formula = ltrim(substr($formula,1)); + $formula = ltrim(substr($formula, 1)); if (!isset($formula{0})) return self::_wrapResult($formula); $pCellParent = ($pCell !== NULL) ? $pCell->getWorksheet() : NULL; $wsTitle = ($pCellParent !== NULL) ? $pCellParent->getTitle() : "\x00Wrk"; + $wsCellReference = $wsTitle . '!' . $cellID; - if (($cellID !== NULL) && ($this->getValueFromCache($wsTitle, $cellID, $cellValue))) { + if (($cellID !== NULL) && ($this->getValueFromCache($wsCellReference, $cellValue))) { return $cellValue; } - if (($wsTitle{0} !== "\x00") && ($this->_cyclicReferenceStack->onStack($wsTitle.'!'.$cellID))) { - if ($this->cyclicFormulaCount <= 0) { + if (($wsTitle{0} !== "\x00") && ($this->_cyclicReferenceStack->onStack($wsCellReference))) { + if ($this->cyclicFormulaCount <= 0) { + $this->_cyclicFormulaCell = ''; return $this->_raiseFormulaError('Cyclic Reference in Formula'); - } elseif (($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) && - ($this->_cyclicFormulaCell == $wsTitle.'!'.$cellID)) { - return $cellValue; - } elseif ($this->_cyclicFormulaCell == $wsTitle.'!'.$cellID) { + } elseif ($this->_cyclicFormulaCell === $wsCellReference) { ++$this->_cyclicFormulaCount; if ($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) { + $this->_cyclicFormulaCell = ''; return $cellValue; } } elseif ($this->_cyclicFormulaCell == '') { - $this->_cyclicFormulaCell = $wsTitle.'!'.$cellID; if ($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) { return $cellValue; } + $this->_cyclicFormulaCell = $wsCellReference; } } // Parse the formula onto the token stack and calculate the value - $this->_cyclicReferenceStack->push($wsTitle.'!'.$cellID); + $this->_cyclicReferenceStack->push($wsCellReference); $cellValue = $this->_processTokenStack($this->_parseFormula($formula, $pCell), $cellID, $pCell); $this->_cyclicReferenceStack->pop(); // Save to calculation cache if ($cellID !== NULL) { - $this->saveValueToCache($wsTitle, $cellID, $cellValue); + $this->saveValueToCache($wsCellReference, $cellValue); } // Return the calculated value @@ -2640,7 +2649,7 @@ class PHPExcel_Calculation { } // function _showTypeDetails() - private static function _convertMatrixReferences($formula) { + private function _convertMatrixReferences($formula) { static $matrixReplaceFrom = array('{',';','}'); static $matrixReplaceTo = array('MKMATRIX(MKMATRIX(','),MKMATRIX(','))'); @@ -2729,7 +2738,7 @@ class PHPExcel_Calculation { // Convert infix to postfix notation private function _parseFormula($formula, PHPExcel_Cell $pCell = NULL) { - if (($formula = self::_convertMatrixReferences(trim($formula))) === FALSE) { + if (($formula = $this->_convertMatrixReferences(trim($formula))) === FALSE) { return FALSE; } @@ -2911,11 +2920,11 @@ class PHPExcel_Calculation { // echo 'Element with value '.$val.' is an Operand, Variable, Constant, String, Number, Cell Reference or Function
'; if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $val, $matches)) { - $val = preg_replace('/\s/','',$val); + $val = preg_replace('/\s/u','',$val); // echo 'Element '.$val.' is a Function
'; if (isset(self::$_PHPExcelFunctions[strtoupper($matches[1])]) || isset(self::$_controlFunctions[strtoupper($matches[1])])) { // it's a function $stack->push('Function', strtoupper($val)); - $ax = preg_match('/^\s*(\s*\))/i', substr($formula, $index+$length), $amatch); + $ax = preg_match('/^\s*(\s*\))/ui', substr($formula, $index+$length), $amatch); if ($ax) { $stack->push('Operand Count for Function '.strtoupper($val).')', 0); $expectingOperator = TRUE; @@ -3592,27 +3601,39 @@ class PHPExcel_Calculation { break; // Equality case '=': - $result = ($operand1 == $operand2); + if (is_numeric($operand1) && is_numeric($operand2)) { + $result = (abs($operand1 - $operand2) < $this->delta); + } else { + $result = strcmp($operand1, $operand2) == 0; + } break; // Greater than or equal case '>=': - if ($useLowercaseFirstComparison) { + if (is_numeric($operand1) && is_numeric($operand2)) { + $result = ((abs($operand1 - $operand2) < $this->delta) || ($operand1 > $operand2)); + } elseif ($useLowercaseFirstComparison) { $result = $this->strcmpLowercaseFirst($operand1, $operand2) >= 0; } else { - $result = ($operand1 >= $operand2); + $result = strcmp($operand1, $operand2) >= 0; } break; // Less than or equal case '<=': - if ($useLowercaseFirstComparison) { + if (is_numeric($operand1) && is_numeric($operand2)) { + $result = ((abs($operand1 - $operand2) < $this->delta) || ($operand1 < $operand2)); + } elseif ($useLowercaseFirstComparison) { $result = $this->strcmpLowercaseFirst($operand1, $operand2) <= 0; } else { - $result = ($operand1 <= $operand2); + $result = strcmp($operand1, $operand2) <= 0; } break; // Inequality case '<>': - $result = ($operand1 != $operand2); + if (is_numeric($operand1) && is_numeric($operand2)) { + $result = (abs($operand1 - $operand2) > 1E-14); + } else { + $result = strcmp($operand1, $operand2) != 0; + } break; } @@ -3620,21 +3641,19 @@ class PHPExcel_Calculation { $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result)); // And push the result onto the stack $stack->push('Value',$result); - return TRUE; - } // function _executeBinaryComparisonOperation() + return true; + } /** * Compare two strings in the same way as strcmp() except that lowercase come before uppercase letters - * @param string $str1 - * @param string $str2 - * @return integer + * @param string $str1 First string value for the comparison + * @param string $str2 Second string value for the comparison + * @return integer */ private function strcmpLowercaseFirst($str1, $str2) { - $from = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; - $to = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - $inversedStr1 = strtr($str1, $from, $to); - $inversedStr2 = strtr($str2, $from, $to); + $inversedStr1 = PHPExcel_Shared_String::StrCaseReverse($str1); + $inversedStr2 = PHPExcel_Shared_String::StrCaseReverse($str2); return strcmp($inversedStr1, $inversedStr2); } diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/DateTime.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/DateTime.php index 6eb96fd2ccd..56c14079ae4 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/DateTime.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/DateTime.php @@ -1071,7 +1071,9 @@ class PHPExcel_Calculation_DateTime { public static function DAYOFMONTH($dateValue = 1) { $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); - if (is_string($dateValue = self::_getDateValue($dateValue))) { + if ($dateValue === null) { + $dateValue = 1; + } elseif (is_string($dateValue = self::_getDateValue($dateValue))) { return PHPExcel_Calculation_Functions::VALUE(); } elseif ($dateValue == 0.0) { return 0; @@ -1114,7 +1116,9 @@ class PHPExcel_Calculation_DateTime { } $style = floor($style); - if (is_string($dateValue = self::_getDateValue($dateValue))) { + if ($dateValue === null) { + $dateValue = 1; + } elseif (is_string($dateValue = self::_getDateValue($dateValue))) { return PHPExcel_Calculation_Functions::VALUE(); } elseif ($dateValue < 0.0) { return PHPExcel_Calculation_Functions::NaN(); @@ -1180,7 +1184,9 @@ class PHPExcel_Calculation_DateTime { } $method = floor($method); - if (is_string($dateValue = self::_getDateValue($dateValue))) { + if ($dateValue === null) { + $dateValue = 1; + } elseif (is_string($dateValue = self::_getDateValue($dateValue))) { return PHPExcel_Calculation_Functions::VALUE(); } elseif ($dateValue < 0.0) { return PHPExcel_Calculation_Functions::NaN(); @@ -1216,7 +1222,9 @@ class PHPExcel_Calculation_DateTime { public static function MONTHOFYEAR($dateValue = 1) { $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); - if (is_string($dateValue = self::_getDateValue($dateValue))) { + if ($dateValue === null) { + $dateValue = 1; + } elseif (is_string($dateValue = self::_getDateValue($dateValue))) { return PHPExcel_Calculation_Functions::VALUE(); } elseif ($dateValue < 0.0) { return PHPExcel_Calculation_Functions::NaN(); @@ -1245,7 +1253,9 @@ class PHPExcel_Calculation_DateTime { public static function YEAR($dateValue = 1) { $dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue); - if (is_string($dateValue = self::_getDateValue($dateValue))) { + if ($dateValue === null) { + $dateValue = 1; + } elseif (is_string($dateValue = self::_getDateValue($dateValue))) { return PHPExcel_Calculation_Functions::VALUE(); } elseif ($dateValue < 0.0) { return PHPExcel_Calculation_Functions::NaN(); diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Functions.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Functions.php index df21ac4f454..dea1503b8ec 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Functions.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Functions.php @@ -496,7 +496,7 @@ class PHPExcel_Calculation_Functions { * @return string Version information */ public static function VERSION() { - return 'PHPExcel ##VERSION##, ##DATE##'; + return 'PHPExcel 1.8.1, 2015-04-30'; } // function VERSION() @@ -578,7 +578,6 @@ class PHPExcel_Calculation_Functions { return 4; } elseif(is_array($value)) { return 64; - break; } elseif(is_string($value)) { // Errors if ((strlen($value) > 0) && ($value{0} == '#')) { @@ -711,7 +710,7 @@ if ((!function_exists('mb_str_replace')) && } foreach((array) $search as $key => $s) { - if($s == '') { + if($s == '' && $s !== 0) { continue; } $r = !is_array($replace) ? $replace : (array_key_exists($key, $replace) ? $replace[$key] : ''); diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/LookupRef.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/LookupRef.php index 94f42e5f292..75e7f69cee5 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/LookupRef.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/LookupRef.php @@ -735,11 +735,7 @@ class PHPExcel_Calculation_LookupRef { return PHPExcel_Calculation_Functions::NA(); } else { // otherwise return the appropriate value - $result = $lookup_array[$rowNumber][$returnColumn]; - if ((is_numeric($lookup_value) && is_numeric($result)) || - (!is_numeric($lookup_value) && !is_numeric($result))) { - return $result; - } + return $lookup_array[$rowNumber][$returnColumn]; } } @@ -802,8 +798,7 @@ class PHPExcel_Calculation_LookupRef { return PHPExcel_Calculation_Functions::NA(); } else { // otherwise return the appropriate value - $result = $lookup_array[$returnColumn][$rowNumber]; - return $result; + return $lookup_array[$returnColumn][$rowNumber]; } } diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/MathTrig.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/MathTrig.php index b2bb19d4840..689d59ffce9 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/MathTrig.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/MathTrig.php @@ -145,8 +145,8 @@ class PHPExcel_Calculation_MathTrig { $significance = $number/abs($number); } - if ((is_numeric($number)) && (is_numeric($significance))) { - if ($significance == 0.0) { + if ((is_numeric($number)) && (is_numeric($significance))) { + if (($number == 0.0 ) || ($significance == 0.0)) { return 0.0; } elseif (self::SIGN($number) == self::SIGN($significance)) { return ceil($number / $significance) * $significance; @@ -316,15 +316,17 @@ class PHPExcel_Calculation_MathTrig { } if ((is_numeric($number)) && (is_numeric($significance))) { - if ((float) $significance == 0.0) { - return PHPExcel_Calculation_Functions::DIV0(); - } - if (self::SIGN($number) == self::SIGN($significance)) { + if ($significance == 0.0) { + return PHPExcel_Calculation_Functions::DIV0(); + } elseif ($number == 0.0) { + return 0.0; + } elseif (self::SIGN($number) == self::SIGN($significance)) { return floor($number / $significance) * $significance; } else { return PHPExcel_Calculation_Functions::NaN(); } - } + } else + return PHPExcel_Calculation_Functions::VALUE(); } // function FLOOR() @@ -607,27 +609,27 @@ class PHPExcel_Calculation_MathTrig { if (!is_array($matrixData1)) { $matrixData1 = array(array($matrixData1)); } if (!is_array($matrixData2)) { $matrixData2 = array(array($matrixData2)); } - $rowA = 0; - foreach($matrixData1 as $matrixRow) { - if (!is_array($matrixRow)) { $matrixRow = array($matrixRow); } - $columnA = 0; - foreach($matrixRow as $matrixCell) { - if ((is_string($matrixCell)) || ($matrixCell === null)) { - return PHPExcel_Calculation_Functions::VALUE(); - } - $matrixAData[$rowA][$columnA] = $matrixCell; - ++$columnA; - } - ++$rowA; - } try { + $rowA = 0; + foreach($matrixData1 as $matrixRow) { + if (!is_array($matrixRow)) { $matrixRow = array($matrixRow); } + $columnA = 0; + foreach($matrixRow as $matrixCell) { + if ((!is_numeric($matrixCell)) || ($matrixCell === null)) { + return PHPExcel_Calculation_Functions::VALUE(); + } + $matrixAData[$rowA][$columnA] = $matrixCell; + ++$columnA; + } + ++$rowA; + } $matrixA = new PHPExcel_Shared_JAMA_Matrix($matrixAData); $rowB = 0; foreach($matrixData2 as $matrixRow) { if (!is_array($matrixRow)) { $matrixRow = array($matrixRow); } $columnB = 0; foreach($matrixRow as $matrixCell) { - if ((is_string($matrixCell)) || ($matrixCell === null)) { + if ((!is_numeric($matrixCell)) || ($matrixCell === null)) { return PHPExcel_Calculation_Functions::VALUE(); } $matrixBData[$rowB][$columnB] = $matrixCell; @@ -637,12 +639,13 @@ class PHPExcel_Calculation_MathTrig { } $matrixB = new PHPExcel_Shared_JAMA_Matrix($matrixBData); - if (($rowA != $columnB) || ($rowB != $columnA)) { + if ($columnA != $rowB) { return PHPExcel_Calculation_Functions::VALUE(); } return $matrixA->times($matrixB)->getArray(); } catch (PHPExcel_Exception $ex) { + var_dump($ex->getMessage()); return PHPExcel_Calculation_Functions::VALUE(); } } // function MMULT() @@ -880,9 +883,9 @@ class PHPExcel_Calculation_MathTrig { $max = PHPExcel_Calculation_Functions::flattenSingleValue($max); if ($min == 0 && $max == 0) { - return (rand(0,10000000)) / 10000000; + return (mt_rand(0,10000000)) / 10000000; } else { - return rand($min, $max); + return mt_rand($min, $max); } } // function RAND() diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php index 2037f334994..67e1951c254 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php @@ -2737,7 +2737,7 @@ class PHPExcel_Calculation_Statistical { $mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean); if ((is_numeric($value)) && (is_numeric($mean))) { - if (($value <= 0) || ($mean <= 0)) { + if (($value < 0) || ($mean <= 0)) { return PHPExcel_Calculation_Functions::NaN(); } if ((is_numeric($cumulative)) || (is_bool($cumulative))) { diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/TextData.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/TextData.php index 73a0d0cd7be..148a5b756dd 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/TextData.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Calculation/TextData.php @@ -104,7 +104,7 @@ class PHPExcel_Calculation_TextData { } if (is_string($stringValue) || is_numeric($stringValue)) { - return str_replace(self::$_invalidChars,'',trim($stringValue,"\x00..\x1F")); + return str_replace(self::$_invalidChars, '', trim($stringValue, "\x00..\x1F")); } return NULL; } // function TRIMNONPRINTABLE() @@ -118,13 +118,12 @@ class PHPExcel_Calculation_TextData { */ public static function TRIMSPACES($stringValue = '') { $stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue); - if (is_bool($stringValue)) { return ($stringValue) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); } if (is_string($stringValue) || is_numeric($stringValue)) { - return trim(preg_replace('/ +/',' ',trim($stringValue,' '))); + return trim(preg_replace('/ +/',' ',trim($stringValue, ' ')), ' '); } return NULL; } // function TRIMSPACES() @@ -587,4 +586,45 @@ class PHPExcel_Calculation_TextData { return (string) PHPExcel_Style_NumberFormat::toFormattedString($value,$format); } // function TEXTFORMAT() -} // class PHPExcel_Calculation_TextData + /** + * VALUE + * + * @param mixed $value Value to check + * @return boolean + */ + public static function VALUE($value = '') { + $value = PHPExcel_Calculation_Functions::flattenSingleValue($value); + + if (!is_numeric($value)) { + $numberValue = str_replace( + PHPExcel_Shared_String::getThousandsSeparator(), + '', + trim($value, " \t\n\r\0\x0B" . PHPExcel_Shared_String::getCurrencyCode()) + ); + if (is_numeric($numberValue)) { + return (float) $numberValue; + } + + $dateSetting = PHPExcel_Calculation_Functions::getReturnDateType(); + PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); + + if (strpos($value, ':') !== false) { + $timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($value); + if ($timeValue !== PHPExcel_Calculation_Functions::VALUE()) { + PHPExcel_Calculation_Functions::setReturnDateType($dateSetting); + return $timeValue; + } + } + $dateValue = PHPExcel_Calculation_DateTime::DATEVALUE($value); + if ($dateValue !== PHPExcel_Calculation_Functions::VALUE()) { + PHPExcel_Calculation_Functions::setReturnDateType($dateSetting); + return $dateValue; + } + PHPExcel_Calculation_Functions::setReturnDateType($dateSetting); + + return PHPExcel_Calculation_Functions::VALUE(); + } + return (float) $value; + } + +} diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Cell.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Cell.php index 0462686d178..2d5f9102d8f 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Cell.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Cell.php @@ -88,7 +88,7 @@ class PHPExcel_Cell * * @var int */ - private $_xfIndex; + private $_xfIndex = 0; /** * Attributes of the formula @@ -113,8 +113,6 @@ class PHPExcel_Cell } public function attach(PHPExcel_CachedObjectStorage_CacheBase $parent) { - - $this->_parent = $parent; } @@ -140,14 +138,9 @@ class PHPExcel_Cell if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) $pDataType = PHPExcel_Cell_DataType::TYPE_STRING; $this->_dataType = $pDataType; - } else { - if (!self::getValueBinder()->bindValue($this, $pValue)) { - throw new PHPExcel_Exception("Value could not be bound to cell."); - } + } elseif (!self::getValueBinder()->bindValue($this, $pValue)) { + throw new PHPExcel_Exception("Value could not be bound to cell."); } - - // set default index to cellXf - $this->_xfIndex = 0; } /** @@ -199,7 +192,7 @@ class PHPExcel_Cell { return (string) PHPExcel_Style_NumberFormat::toFormattedString( $this->getCalculatedValue(), - $this->getWorksheet()->getParent()->getCellXfByIndex($this->getXfIndex()) + $this->getStyle() ->getNumberFormat()->getFormatCode() ); } @@ -496,6 +489,45 @@ class PHPExcel_Cell return $this->_parent->getParent(); } + /** + * Is this cell in a merge range + * + * @return boolean + */ + public function isInMergeRange() { + return (boolean) $this->getMergeRange(); + } + + /** + * Is this cell the master (top left cell) in a merge range (that holds the actual data value) + * + * @return boolean + */ + public function isMergeRangeValueCell() { + if ($mergeRange = $this->getMergeRange()) { + $mergeRange = PHPExcel_Cell::splitRange($mergeRange); + list($startCell) = $mergeRange[0]; + if ($this->getCoordinate() === $startCell) { + return true; + } + } + return false; + } + + /** + * If this cell is in a merge range, then return the range + * + * @return string + */ + public function getMergeRange() { + foreach($this->getWorksheet()->getMergeCells() as $mergeRange) { + if ($this->isInRange($mergeRange)) { + return $mergeRange; + } + } + return false; + } + /** * Get cell style * @@ -503,7 +535,7 @@ class PHPExcel_Cell */ public function getStyle() { - return $this->getWorksheet()->getParent()->getCellXfByIndex($this->getXfIndex()); + return $this->getWorksheet()->getStyle($this->getCoordinate()); } /** diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Cell/DefaultValueBinder.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Cell/DefaultValueBinder.php index 67a4b5f6835..252048f7d8e 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Cell/DefaultValueBinder.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Cell/DefaultValueBinder.php @@ -57,13 +57,20 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder // sanitize UTF-8 strings if (is_string($value)) { $value = PHPExcel_Shared_String::SanitizeUTF8($value); + } elseif (is_object($value)) { + // Handle any objects that might be injected + if ($value instanceof DateTime) { + $value = $value->format('Y-m-d H:i:s'); + } elseif (!($value instanceof PHPExcel_RichText)) { + $value = (string) $value; + } } // Set value explicit $cell->setValueExplicit( $value, self::dataTypeForValue($value) ); // Done! - return TRUE; + return true; } /** @@ -74,33 +81,30 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder */ public static function dataTypeForValue($pValue = null) { // Match the value against a few data types - if (is_null($pValue)) { + if ($pValue === null) { return PHPExcel_Cell_DataType::TYPE_NULL; - } elseif ($pValue === '') { return PHPExcel_Cell_DataType::TYPE_STRING; - } elseif ($pValue instanceof PHPExcel_RichText) { return PHPExcel_Cell_DataType::TYPE_INLINE; - } elseif ($pValue{0} === '=' && strlen($pValue) > 1) { return PHPExcel_Cell_DataType::TYPE_FORMULA; - } elseif (is_bool($pValue)) { return PHPExcel_Cell_DataType::TYPE_BOOL; - } elseif (is_float($pValue) || is_int($pValue)) { return PHPExcel_Cell_DataType::TYPE_NUMERIC; - - } elseif (preg_match('/^\-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)$/', $pValue)) { + } elseif (preg_match('/^[\+\-]?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $pValue)) { + $tValue = ltrim($pValue, '+-'); + if (is_string($pValue) && $tValue{0} === '0' && strlen($tValue) > 1 && $tValue{1} !== '.' ) { + return PHPExcel_Cell_DataType::TYPE_STRING; + } elseif((strpos($pValue, '.') === false) && ($pValue > PHP_INT_MAX)) { + return PHPExcel_Cell_DataType::TYPE_STRING; + } return PHPExcel_Cell_DataType::TYPE_NUMERIC; - } elseif (is_string($pValue) && array_key_exists($pValue, PHPExcel_Cell_DataType::getErrorCodes())) { return PHPExcel_Cell_DataType::TYPE_ERROR; - - } else { - return PHPExcel_Cell_DataType::TYPE_STRING; - } + + return PHPExcel_Cell_DataType::TYPE_STRING; } } diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart.php index 2f3f19d22a0..9bf72dbbd4f 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart.php @@ -98,6 +98,33 @@ class PHPExcel_Chart */ private $_displayBlanksAs = '0'; + /** + * Chart Asix Y as + * + * @var PHPExcel_Chart_Axis + */ + private $_yAxis = null; + + /** + * Chart Asix X as + * + * @var PHPExcel_Chart_Axis + */ + private $_xAxis = null; + + /** + * Chart Major Gridlines as + * + * @var PHPExcel_Chart_GridLines + */ + private $_majorGridlines = null; + + /** + * Chart Minor Gridlines as + * + * @var PHPExcel_Chart_GridLines + */ + private $_minorGridlines = null; /** * Top-Left Cell Position @@ -150,7 +177,7 @@ class PHPExcel_Chart /** * Create a new PHPExcel_Chart */ - public function __construct($name, PHPExcel_Chart_Title $title = null, PHPExcel_Chart_Legend $legend = null, PHPExcel_Chart_PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = '0', PHPExcel_Chart_Title $xAxisLabel = null, PHPExcel_Chart_Title $yAxisLabel = null) + public function __construct($name, PHPExcel_Chart_Title $title = null, PHPExcel_Chart_Legend $legend = null, PHPExcel_Chart_PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = '0', PHPExcel_Chart_Title $xAxisLabel = null, PHPExcel_Chart_Title $yAxisLabel = null, PHPExcel_Chart_Axis $xAxis = null, PHPExcel_Chart_Axis $yAxis = null, PHPExcel_Chart_GridLines $majorGridlines = null, PHPExcel_Chart_GridLines $minorGridlines = null) { $this->_name = $name; $this->_title = $title; @@ -160,6 +187,10 @@ class PHPExcel_Chart $this->_plotArea = $plotArea; $this->_plotVisibleOnly = $plotVisibleOnly; $this->_displayBlanksAs = $displayBlanksAs; + $this->_xAxis = $xAxis; + $this->_yAxis = $yAxis; + $this->_majorGridlines = $majorGridlines; + $this->_minorGridlines = $minorGridlines; } /** @@ -327,6 +358,59 @@ class PHPExcel_Chart } + /** + * Get yAxis + * + * @return PHPExcel_Chart_Axis + */ + public function getChartAxisY() { + if($this->_yAxis !== NULL){ + return $this->_yAxis; + } + + return new PHPExcel_Chart_Axis(); + } + + /** + * Get xAxis + * + * @return PHPExcel_Chart_Axis + */ + public function getChartAxisX() { + if($this->_xAxis !== NULL){ + return $this->_xAxis; + } + + return new PHPExcel_Chart_Axis(); + } + + /** + * Get Major Gridlines + * + * @return PHPExcel_Chart_GridLines + */ + public function getMajorGridlines() { + if($this->_majorGridlines !== NULL){ + return $this->_majorGridlines; + } + + return new PHPExcel_Chart_GridLines(); + } + + /** + * Get Minor Gridlines + * + * @return PHPExcel_Chart_GridLines + */ + public function getMinorGridlines() { + if($this->_minorGridlines !== NULL){ + return $this->_minorGridlines; + } + + return new PHPExcel_Chart_GridLines(); + } + + /** * Set the Top Left position for the chart * diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/Axis.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/Axis.php new file mode 100644 index 00000000000..efb39e9f410 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/Axis.php @@ -0,0 +1,584 @@ + self::FORMAT_CODE_GENERAL, + 'source_linked' => 1 + ); + + /** + * Axis Options + * + * @var array of mixed + */ + + private $_axis_options = array( + 'minimum' => NULL, + 'maximum' => NULL, + 'major_unit' => NULL, + 'minor_unit' => NULL, + 'orientation' => self::ORIENTATION_NORMAL, + 'minor_tick_mark' => self::TICK_MARK_NONE, + 'major_tick_mark' => self::TICK_MARK_NONE, + 'axis_labels' => self::AXIS_LABELS_NEXT_TO, + 'horizontal_crosses' => self::HORIZONTAL_CROSSES_AUTOZERO, + 'horizontal_crosses_value' => NULL + ); + + /** + * Fill Properties + * + * @var array of mixed + */ + + private $_fill_properties = array( + 'type' => self::EXCEL_COLOR_TYPE_ARGB, + 'value' => NULL, + 'alpha' => 0 + ); + + /** + * Line Properties + * + * @var array of mixed + */ + + private $_line_properties = array( + 'type' => self::EXCEL_COLOR_TYPE_ARGB, + 'value' => NULL, + 'alpha' => 0 + ); + + /** + * Line Style Properties + * + * @var array of mixed + */ + + private $_line_style_properties = array( + 'width' => '9525', + 'compound' => self::LINE_STYLE_COMPOUND_SIMPLE, + 'dash' => self::LINE_STYLE_DASH_SOLID, + 'cap' => self::LINE_STYLE_CAP_FLAT, + 'join' => self::LINE_STYLE_JOIN_BEVEL, + 'arrow' => array( + 'head' => array( + 'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW, + 'size' => self::LINE_STYLE_ARROW_SIZE_5 + ), + 'end' => array( + 'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW, + 'size' => self::LINE_STYLE_ARROW_SIZE_8 + ), + ) + ); + + /** + * Shadow Properties + * + * @var array of mixed + */ + + private $_shadow_properties = array( + 'presets' => self::SHADOW_PRESETS_NOSHADOW, + 'effect' => NULL, + 'color' => array( + 'type' => self::EXCEL_COLOR_TYPE_STANDARD, + 'value' => 'black', + 'alpha' => 40, + ), + 'size' => array( + 'sx' => NULL, + 'sy' => NULL, + 'kx' => NULL + ), + 'blur' => NULL, + 'direction' => NULL, + 'distance' => NULL, + 'algn' => NULL, + 'rotWithShape' => NULL + ); + + /** + * Glow Properties + * + * @var array of mixed + */ + + private $_glow_properties = array( + 'size' => NULL, + 'color' => array( + 'type' => self::EXCEL_COLOR_TYPE_STANDARD, + 'value' => 'black', + 'alpha' => 40 + ) + ); + + /** + * Soft Edge Properties + * + * @var array of mixed + */ + + private $_soft_edges = array( + 'size' => NULL + ); + + /** + * Get Series Data Type + * + * @return string + */ + + public function setAxisNumberProperties($format_code) { + $this->_axis_number['format'] = (string) $format_code; + $this->_axis_number['source_linked'] = 0; + } + + /** + * Get Axis Number Format Data Type + * + * @return string + */ + + public function getAxisNumberFormat() { + return $this->_axis_number['format']; + } + + /** + * Get Axis Number Source Linked + * + * @return string + */ + + public function getAxisNumberSourceLinked() { + return (string) $this->_axis_number['source_linked']; + } + + /** + * Set Axis Options Properties + * + * @param string $axis_labels + * @param string $horizontal_crosses_value + * @param string $horizontal_crosses + * @param string $axis_orientation + * @param string $major_tmt + * @param string $minor_tmt + * @param string $minimum + * @param string $maximum + * @param string $major_unit + * @param string $minor_unit + * + */ + + public function setAxisOptionsProperties($axis_labels, $horizontal_crosses_value = NULL, $horizontal_crosses = NULL, + $axis_orientation = NULL, $major_tmt = NULL, $minor_tmt = NULL, $minimum = NULL, $maximum = NULL, $major_unit = NULL, + $minor_unit = NULL) { + + $this->_axis_options['axis_labels'] = (string) $axis_labels; + ($horizontal_crosses_value !== NULL) + ? $this->_axis_options['horizontal_crosses_value'] = (string) $horizontal_crosses_value : NULL; + ($horizontal_crosses !== NULL) ? $this->_axis_options['horizontal_crosses'] = (string) $horizontal_crosses : NULL; + ($axis_orientation !== NULL) ? $this->_axis_options['orientation'] = (string) $axis_orientation : NULL; + ($major_tmt !== NULL) ? $this->_axis_options['major_tick_mark'] = (string) $major_tmt : NULL; + ($minor_tmt !== NULL) ? $this->_axis_options['minor_tick_mark'] = (string) $minor_tmt : NULL; + ($minor_tmt !== NULL) ? $this->_axis_options['minor_tick_mark'] = (string) $minor_tmt : NULL; + ($minimum !== NULL) ? $this->_axis_options['minimum'] = (string) $minimum : NULL; + ($maximum !== NULL) ? $this->_axis_options['maximum'] = (string) $maximum : NULL; + ($major_unit !== NULL) ? $this->_axis_options['major_unit'] = (string) $major_unit : NULL; + ($minor_unit !== NULL) ? $this->_axis_options['minor_unit'] = (string) $minor_unit : NULL; + } + + /** + * Get Axis Options Property + * + * @param string $property + * + * @return string + */ + + public function getAxisOptionsProperty($property) { + return $this->_axis_options[$property]; + } + + /** + * Set Axis Orientation Property + * + * @param string $orientation + * + */ + + public function setAxisOrientation($orientation) { + $this->orientation = (string) $orientation; + } + + /** + * Set Fill Property + * + * @param string $color + * @param int $alpha + * @param string $type + * + */ + + public function setFillParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB) { + $this->_fill_properties = $this->setColorProperties($color, $alpha, $type); + } + + /** + * Set Line Property + * + * @param string $color + * @param int $alpha + * @param string $type + * + */ + + public function setLineParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB) { + $this->_line_properties = $this->setColorProperties($color, $alpha, $type); + } + + /** + * Get Fill Property + * + * @param string $property + * + * @return string + */ + + public function getFillProperty($property) { + return $this->_fill_properties[$property]; + } + + /** + * Get Line Property + * + * @param string $property + * + * @return string + */ + + public function getLineProperty($property) { + return $this->_line_properties[$property]; + } + + /** + * Set Line Style Properties + * + * @param float $line_width + * @param string $compound_type + * @param string $dash_type + * @param string $cap_type + * @param string $join_type + * @param string $head_arrow_type + * @param string $head_arrow_size + * @param string $end_arrow_type + * @param string $end_arrow_size + * + */ + + public function setLineStyleProperties($line_width = NULL, $compound_type = NULL, + $dash_type = NULL, $cap_type = NULL, $join_type = NULL, $head_arrow_type = NULL, + $head_arrow_size = NULL, $end_arrow_type = NULL, $end_arrow_size = NULL) { + + (!is_null($line_width)) ? $this->_line_style_properties['width'] = $this->getExcelPointsWidth((float) $line_width) + : NULL; + (!is_null($compound_type)) ? $this->_line_style_properties['compound'] = (string) $compound_type : NULL; + (!is_null($dash_type)) ? $this->_line_style_properties['dash'] = (string) $dash_type : NULL; + (!is_null($cap_type)) ? $this->_line_style_properties['cap'] = (string) $cap_type : NULL; + (!is_null($join_type)) ? $this->_line_style_properties['join'] = (string) $join_type : NULL; + (!is_null($head_arrow_type)) ? $this->_line_style_properties['arrow']['head']['type'] = (string) $head_arrow_type + : NULL; + (!is_null($head_arrow_size)) ? $this->_line_style_properties['arrow']['head']['size'] = (string) $head_arrow_size + : NULL; + (!is_null($end_arrow_type)) ? $this->_line_style_properties['arrow']['end']['type'] = (string) $end_arrow_type + : NULL; + (!is_null($end_arrow_size)) ? $this->_line_style_properties['arrow']['end']['size'] = (string) $end_arrow_size + : NULL; + } + + /** + * Get Line Style Property + * + * @param array|string $elements + * + * @return string + */ + + public function getLineStyleProperty($elements) { + return $this->getArrayElementsValue($this->_line_style_properties, $elements); + } + + /** + * Get Line Style Arrow Excel Width + * + * @param string $arrow + * + * @return string + */ + + public function getLineStyleArrowWidth($arrow) { + return $this->getLineStyleArrowSize($this->_line_style_properties['arrow'][$arrow]['size'], 'w'); + } + + /** + * Get Line Style Arrow Excel Length + * + * @param string $arrow + * + * @return string + */ + + public function getLineStyleArrowLength($arrow) { + return $this->getLineStyleArrowSize($this->_line_style_properties['arrow'][$arrow]['size'], 'len'); + } + + /** + * Set Shadow Properties + * + * @param int $shadow_presets + * @param string $sh_color_value + * @param string $sh_color_type + * @param string $sh_color_alpha + * @param float $sh_blur + * @param int $sh_angle + * @param float $sh_distance + * + */ + + public function setShadowProperties($sh_presets, $sh_color_value = NULL, $sh_color_type = NULL, $sh_color_alpha = NULL, $sh_blur = NULL, $sh_angle = NULL, $sh_distance = NULL) { + $this + ->_setShadowPresetsProperties((int) $sh_presets) + ->_setShadowColor( + is_null($sh_color_value) ? $this->_shadow_properties['color']['value'] : $sh_color_value + , is_null($sh_color_alpha) ? (int) $this->_shadow_properties['color']['alpha'] : $sh_color_alpha + , is_null($sh_color_type) ? $this->_shadow_properties['color']['type'] : $sh_color_type) + ->_setShadowBlur($sh_blur) + ->_setShadowAngle($sh_angle) + ->_setShadowDistance($sh_distance); + } + + /** + * Set Shadow Color + * + * @param int $shadow_presets + * + * @return PHPExcel_Chart_Axis + */ + + private function _setShadowPresetsProperties($shadow_presets) { + $this->_shadow_properties['presets'] = $shadow_presets; + $this->_setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets)); + + return $this; + } + + /** + * Set Shadow Properties from Maped Values + * + * @param array $properties_map + * @param * $reference + * + * @return PHPExcel_Chart_Axis + */ + + private function _setShadowProperiesMapValues(array $properties_map, &$reference = NULL) { + $base_reference = $reference; + foreach ($properties_map as $property_key => $property_val) { + if (is_array($property_val)) { + if ($reference === NULL) { + $reference = & $this->_shadow_properties[$property_key]; + } else { + $reference = & $reference[$property_key]; + } + $this->_setShadowProperiesMapValues($property_val, $reference); + } else { + if ($base_reference === NULL) { + $this->_shadow_properties[$property_key] = $property_val; + } else { + $reference[$property_key] = $property_val; + } + } + } + + return $this; + } + + /** + * Set Shadow Color + * + * @param string $color + * @param int $alpha + * @param string $type + * + * @return PHPExcel_Chart_Axis + */ + + private function _setShadowColor($color, $alpha, $type) { + $this->_shadow_properties['color'] = $this->setColorProperties($color, $alpha, $type); + + return $this; + } + + /** + * Set Shadow Blur + * + * @param float $blur + * + * @return PHPExcel_Chart_Axis + */ + + private function _setShadowBlur($blur) { + if ($blur !== NULL) { + $this->_shadow_properties['blur'] = (string) $this->getExcelPointsWidth($blur); + } + + return $this; + } + + /** + * Set Shadow Angle + * + * @param int $angle + * + * @return PHPExcel_Chart_Axis + */ + + private function _setShadowAngle($angle) { + if ($angle !== NULL) { + $this->_shadow_properties['direction'] = (string) $this->getExcelPointsAngle($angle); + } + + return $this; + } + + /** + * Set Shadow Distance + * + * @param float $distance + * + * @return PHPExcel_Chart_Axis + */ + + private function _setShadowDistance($distance) { + if ($distance !== NULL) { + $this->_shadow_properties['distance'] = (string) $this->getExcelPointsWidth($distance); + } + + return $this; + } + + /** + * Get Glow Property + * + * @param float $size + * @param string $color_value + * @param int $color_alpha + * @param string $color_type + */ + + public function getShadowProperty($elements) { + return $this->getArrayElementsValue($this->_shadow_properties, $elements); + } + + /** + * Set Glow Properties + * + * @param float $size + * @param string $color_value + * @param int $color_alpha + * @param string $color_type + */ + + public function setGlowProperties($size, $color_value = NULL, $color_alpha = NULL, $color_type = NULL) { + $this + ->_setGlowSize($size) + ->_setGlowColor( + is_null($color_value) ? $this->_glow_properties['color']['value'] : $color_value + , is_null($color_alpha) ? (int) $this->_glow_properties['color']['alpha'] : $color_alpha + , is_null($color_type) ? $this->_glow_properties['color']['type'] : $color_type); + } + + /** + * Get Glow Property + * + * @param array|string $property + * + * @return string + */ + + public function getGlowProperty($property) { + return $this->getArrayElementsValue($this->_glow_properties, $property); + } + + /** + * Set Glow Color + * + * @param float $size + * + * @return PHPExcel_Chart_Axis + */ + + private function _setGlowSize($size) { + if (!is_null($size)) { + $this->_glow_properties['size'] = $this->getExcelPointsWidth($size); + } + + return $this; + } + + /** + * Set Glow Color + * + * @param string $color + * @param int $alpha + * @param string $type + * + * @return PHPExcel_Chart_Axis + */ + + private function _setGlowColor($color, $alpha, $type) { + $this->_glow_properties['color'] = $this->setColorProperties($color, $alpha, $type); + + return $this; + } + + /** + * Set Soft Edges Size + * + * @param float $size + */ + + public function setSoftEdges($size) { + if (!is_null($size)) { + $_soft_edges['size'] = (string) $this->getExcelPointsWidth($size); + } + } + + /** + * Get Soft Edges Size + * + * @return string + */ + + public function getSoftEdgesSize() { + return $this->_soft_edges['size']; + } +} \ No newline at end of file diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/DataSeries.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/DataSeries.php index 86e61eb17ee..56faf6ee00e 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/DataSeries.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/DataSeries.php @@ -137,7 +137,7 @@ class PHPExcel_Chart_DataSeries /** * Create a new PHPExcel_Chart_DataSeries */ - public function __construct($plotType = null, $plotGrouping = null, $plotOrder = array(), $plotLabel = array(), $plotCategory = array(), $plotValues = array(), $smoothLine = null, $plotStyle = null) + public function __construct($plotType = null, $plotGrouping = null, $plotOrder = array(), $plotLabel = array(), $plotCategory = array(), $plotValues = array(), $plotDirection = null, $smoothLine = null, $plotStyle = null) { $this->_plotType = $plotType; $this->_plotGrouping = $plotGrouping; @@ -155,6 +155,11 @@ class PHPExcel_Chart_DataSeries $this->_plotCategory = $plotCategory; $this->_smoothLine = $smoothLine; $this->_plotStyle = $plotStyle; + + if (is_null($plotDirection)) { + $plotDirection = self::DIRECTION_COL; + } + $this->_plotDirection = $plotDirection; } /** diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/GridLines.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/GridLines.php new file mode 100644 index 00000000000..269860ca1f8 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/GridLines.php @@ -0,0 +1,458 @@ + array( + 'type' => self::EXCEL_COLOR_TYPE_STANDARD, + 'value' => NULL, + 'alpha' => 0 + ), + 'style' => array( + 'width' => '9525', + 'compound' => self::LINE_STYLE_COMPOUND_SIMPLE, + 'dash' => self::LINE_STYLE_DASH_SOLID, + 'cap' => self::LINE_STYLE_CAP_FLAT, + 'join' => self::LINE_STYLE_JOIN_BEVEL, + 'arrow' => array( + 'head' => array( + 'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW, + 'size' => self::LINE_STYLE_ARROW_SIZE_5 + ), + 'end' => array( + 'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW, + 'size' => self::LINE_STYLE_ARROW_SIZE_8 + ), + ) + ) + ), + $_shadow_properties = array( + 'presets' => self::SHADOW_PRESETS_NOSHADOW, + 'effect' => NULL, + 'color' => array( + 'type' => self::EXCEL_COLOR_TYPE_STANDARD, + 'value' => 'black', + 'alpha' => 85, + ), + 'size' => array( + 'sx' => NULL, + 'sy' => NULL, + 'kx' => NULL + ), + 'blur' => NULL, + 'direction' => NULL, + 'distance' => NULL, + 'algn' => NULL, + 'rotWithShape' => NULL + ), + $_glow_properties = array( + 'size' => NULL, + 'color' => array( + 'type' => self::EXCEL_COLOR_TYPE_STANDARD, + 'value' => 'black', + 'alpha' => 40 + ) + ), + $_soft_edges = array( + 'size' => NULL + ); + + /** + * Get Object State + * + * @return bool + */ + + public function getObjectState() { + return $this->_object_state; + } + + /** + * Change Object State to True + * + * @return PHPExcel_Chart_GridLines + */ + + private function _activateObject() { + $this->_object_state = TRUE; + + return $this; + } + + /** + * Set Line Color Properties + * + * @param string $value + * @param int $alpha + * @param string $type + */ + + public function setLineColorProperties($value, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_STANDARD) { + $this + ->_activateObject() + ->_line_properties['color'] = $this->setColorProperties( + $value, + $alpha, + $type); + } + + /** + * Set Line Color Properties + * + * @param float $line_width + * @param string $compound_type + * @param string $dash_type + * @param string $cap_type + * @param string $join_type + * @param string $head_arrow_type + * @param string $head_arrow_size + * @param string $end_arrow_type + * @param string $end_arrow_size + */ + + public function setLineStyleProperties($line_width = NULL, $compound_type = NULL, $dash_type = NULL, $cap_type = NULL, $join_type = NULL, $head_arrow_type = NULL, $head_arrow_size = NULL, $end_arrow_type = NULL, $end_arrow_size = NULL) { + $this->_activateObject(); + (!is_null($line_width)) + ? $this->_line_properties['style']['width'] = $this->getExcelPointsWidth((float) $line_width) + : NULL; + (!is_null($compound_type)) + ? $this->_line_properties['style']['compound'] = (string) $compound_type + : NULL; + (!is_null($dash_type)) + ? $this->_line_properties['style']['dash'] = (string) $dash_type + : NULL; + (!is_null($cap_type)) + ? $this->_line_properties['style']['cap'] = (string) $cap_type + : NULL; + (!is_null($join_type)) + ? $this->_line_properties['style']['join'] = (string) $join_type + : NULL; + (!is_null($head_arrow_type)) + ? $this->_line_properties['style']['arrow']['head']['type'] = (string) $head_arrow_type + : NULL; + (!is_null($head_arrow_size)) + ? $this->_line_properties['style']['arrow']['head']['size'] = (string) $head_arrow_size + : NULL; + (!is_null($end_arrow_type)) + ? $this->_line_properties['style']['arrow']['end']['type'] = (string) $end_arrow_type + : NULL; + (!is_null($end_arrow_size)) + ? $this->_line_properties['style']['arrow']['end']['size'] = (string) $end_arrow_size + : NULL; + } + + /** + * Get Line Color Property + * + * @param string $parameter + * + * @return string + */ + + public function getLineColorProperty($parameter) { + return $this->_line_properties['color'][$parameter]; + } + + /** + * Get Line Style Property + * + * @param array|string $elements + * + * @return string + */ + + public function getLineStyleProperty($elements) { + return $this->getArrayElementsValue($this->_line_properties['style'], $elements); + } + + /** + * Set Glow Properties + * + * @param float $size + * @param string $color_value + * @param int $color_alpha + * @param string $color_type + * + */ + + public function setGlowProperties($size, $color_value = NULL, $color_alpha = NULL, $color_type = NULL) { + $this + ->_activateObject() + ->_setGlowSize($size) + ->_setGlowColor($color_value, $color_alpha, $color_type); + } + + /** + * Get Glow Color Property + * + * @param string $property + * + * @return string + */ + + public function getGlowColor($property) { + return $this->_glow_properties['color'][$property]; + } + + /** + * Get Glow Size + * + * @return string + */ + + public function getGlowSize() { + return $this->_glow_properties['size']; + } + + /** + * Set Glow Size + * + * @param float $size + * + * @return PHPExcel_Chart_GridLines + */ + + private function _setGlowSize($size) { + $this->_glow_properties['size'] = $this->getExcelPointsWidth((float) $size); + + return $this; + } + + /** + * Set Glow Color + * + * @param string $color + * @param int $alpha + * @param string $type + * + * @return PHPExcel_Chart_GridLines + */ + + private function _setGlowColor($color, $alpha, $type) { + if (!is_null($color)) { + $this->_glow_properties['color']['value'] = (string) $color; + } + if (!is_null($alpha)) { + $this->_glow_properties['color']['alpha'] = $this->getTrueAlpha((int) $alpha); + } + if (!is_null($type)) { + $this->_glow_properties['color']['type'] = (string) $type; + } + + return $this; + } + + /** + * Get Line Style Arrow Parameters + * + * @param string $arrow_selector + * @param string $property_selector + * + * @return string + */ + + public function getLineStyleArrowParameters($arrow_selector, $property_selector) { + return $this->getLineStyleArrowSize($this->_line_properties['style']['arrow'][$arrow_selector]['size'], $property_selector); + } + + /** + * Set Shadow Properties + * + * @param int $sh_presets + * @param string $sh_color_value + * @param string $sh_color_type + * @param int $sh_color_alpha + * @param string $sh_blur + * @param int $sh_angle + * @param float $sh_distance + * + */ + + public function setShadowProperties($sh_presets, $sh_color_value = NULL, $sh_color_type = NULL, $sh_color_alpha = NULL, $sh_blur = NULL, $sh_angle = NULL, $sh_distance = NULL) { + $this + ->_activateObject() + ->_setShadowPresetsProperties((int) $sh_presets) + ->_setShadowColor( + is_null($sh_color_value) ? $this->_shadow_properties['color']['value'] : $sh_color_value + , is_null($sh_color_alpha) ? (int) $this->_shadow_properties['color']['alpha'] + : $this->getTrueAlpha($sh_color_alpha) + , is_null($sh_color_type) ? $this->_shadow_properties['color']['type'] : $sh_color_type) + ->_setShadowBlur($sh_blur) + ->_setShadowAngle($sh_angle) + ->_setShadowDistance($sh_distance); + } + + /** + * Set Shadow Presets Properties + * + * @param int $shadow_presets + * + * @return PHPExcel_Chart_GridLines + */ + + private function _setShadowPresetsProperties($shadow_presets) { + $this->_shadow_properties['presets'] = $shadow_presets; + $this->_setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets)); + + return $this; + } + + /** + * Set Shadow Properties Values + * + * @param array $properties_map + * @param * $reference + * + * @return PHPExcel_Chart_GridLines + */ + + private function _setShadowProperiesMapValues(array $properties_map, &$reference = NULL) { + $base_reference = $reference; + foreach ($properties_map as $property_key => $property_val) { + if (is_array($property_val)) { + if ($reference === NULL) { + $reference = & $this->_shadow_properties[$property_key]; + } else { + $reference = & $reference[$property_key]; + } + $this->_setShadowProperiesMapValues($property_val, $reference); + } else { + if ($base_reference === NULL) { + $this->_shadow_properties[$property_key] = $property_val; + } else { + $reference[$property_key] = $property_val; + } + } + } + + return $this; + } + + /** + * Set Shadow Color + * + * @param string $color + * @param int $alpha + * @param string $type + * + * @return PHPExcel_Chart_GridLines + */ + + private function _setShadowColor($color, $alpha, $type) { + if (!is_null($color)) { + $this->_shadow_properties['color']['value'] = (string) $color; + } + if (!is_null($alpha)) { + $this->_shadow_properties['color']['alpha'] = $this->getTrueAlpha((int) $alpha); + } + if (!is_null($type)) { + $this->_shadow_properties['color']['type'] = (string) $type; + } + + return $this; + } + + /** + * Set Shadow Blur + * + * @param float $blur + * + * @return PHPExcel_Chart_GridLines + */ + + private function _setShadowBlur($blur) { + if ($blur !== NULL) { + $this->_shadow_properties['blur'] = (string) $this->getExcelPointsWidth($blur); + } + + return $this; + } + + /** + * Set Shadow Angle + * + * @param int $angle + * + * @return PHPExcel_Chart_GridLines + */ + + private function _setShadowAngle($angle) { + if ($angle !== NULL) { + $this->_shadow_properties['direction'] = (string) $this->getExcelPointsAngle($angle); + } + + return $this; + } + + /** + * Set Shadow Distance + * + * @param float $distance + * + * @return PHPExcel_Chart_GridLines + */ + + private function _setShadowDistance($distance) { + if ($distance !== NULL) { + $this->_shadow_properties['distance'] = (string) $this->getExcelPointsWidth($distance); + } + + return $this; + } + + /** + * Get Shadow Property + * + * @param string $elements + * @param array $elements + * + * @return string + */ + + public function getShadowProperty($elements) { + return $this->getArrayElementsValue($this->_shadow_properties, $elements); + } + + /** + * Set Soft Edges Size + * + * @param float $size + */ + + public function setSoftEdgesSize($size) { + if (!is_null($size)) { + $this->_activateObject(); + $_soft_edges['size'] = (string) $this->getExcelPointsWidth($size); + } + } + + /** + * Get Soft Edges Size + * + * @return string + */ + + public function getSoftEdgesSize() { + return $this->_soft_edges['size']; + } +} \ No newline at end of file diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/Properties.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/Properties.php new file mode 100644 index 00000000000..7593983c091 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/Properties.php @@ -0,0 +1,359 @@ + (string) $type, + 'value' => (string) $color, + 'alpha' => (string) $this->getTrueAlpha($alpha) + ); + } + + protected function getLineStyleArrowSize($array_selector, $array_kay_selector) { + $sizes = array( + 1 => array('w' => 'sm', 'len' => 'sm'), + 2 => array('w' => 'sm', 'len' => 'med'), + 3 => array('w' => 'sm', 'len' => 'lg'), + 4 => array('w' => 'med', 'len' => 'sm'), + 5 => array('w' => 'med', 'len' => 'med'), + 6 => array('w' => 'med', 'len' => 'lg'), + 7 => array('w' => 'lg', 'len' => 'sm'), + 8 => array('w' => 'lg', 'len' => 'med'), + 9 => array('w' => 'lg', 'len' => 'lg') + ); + + return $sizes[$array_selector][$array_kay_selector]; + } + + protected function getShadowPresetsMap($shadow_presets_option) { + $presets_options = array( + //OUTER + 1 => array( + 'effect' => 'outerShdw', + 'blur' => '50800', + 'distance' => '38100', + 'direction' => '2700000', + 'algn' => 'tl', + 'rotWithShape' => '0' + ), + 2 => array( + 'effect' => 'outerShdw', + 'blur' => '50800', + 'distance' => '38100', + 'direction' => '5400000', + 'algn' => 't', + 'rotWithShape' => '0' + ), + 3 => array( + 'effect' => 'outerShdw', + 'blur' => '50800', + 'distance' => '38100', + 'direction' => '8100000', + 'algn' => 'tr', + 'rotWithShape' => '0' + ), + 4 => array( + 'effect' => 'outerShdw', + 'blur' => '50800', + 'distance' => '38100', + 'algn' => 'l', + 'rotWithShape' => '0' + ), + 5 => array( + 'effect' => 'outerShdw', + 'size' => array( + 'sx' => '102000', + 'sy' => '102000' + ) + , + 'blur' => '63500', + 'distance' => '38100', + 'algn' => 'ctr', + 'rotWithShape' => '0' + ), + 6 => array( + 'effect' => 'outerShdw', + 'blur' => '50800', + 'distance' => '38100', + 'direction' => '10800000', + 'algn' => 'r', + 'rotWithShape' => '0' + ), + 7 => array( + 'effect' => 'outerShdw', + 'blur' => '50800', + 'distance' => '38100', + 'direction' => '18900000', + 'algn' => 'bl', + 'rotWithShape' => '0' + ), + 8 => array( + 'effect' => 'outerShdw', + 'blur' => '50800', + 'distance' => '38100', + 'direction' => '16200000', + 'rotWithShape' => '0' + ), + 9 => array( + 'effect' => 'outerShdw', + 'blur' => '50800', + 'distance' => '38100', + 'direction' => '13500000', + 'algn' => 'br', + 'rotWithShape' => '0' + ), + //INNER + 10 => array( + 'effect' => 'innerShdw', + 'blur' => '63500', + 'distance' => '50800', + 'direction' => '2700000', + ), + 11 => array( + 'effect' => 'innerShdw', + 'blur' => '63500', + 'distance' => '50800', + 'direction' => '5400000', + ), + 12 => array( + 'effect' => 'innerShdw', + 'blur' => '63500', + 'distance' => '50800', + 'direction' => '8100000', + ), + 13 => array( + 'effect' => 'innerShdw', + 'blur' => '63500', + 'distance' => '50800', + ), + 14 => array( + 'effect' => 'innerShdw', + 'blur' => '114300', + ), + 15 => array( + 'effect' => 'innerShdw', + 'blur' => '63500', + 'distance' => '50800', + 'direction' => '10800000', + ), + 16 => array( + 'effect' => 'innerShdw', + 'blur' => '63500', + 'distance' => '50800', + 'direction' => '18900000', + ), + 17 => array( + 'effect' => 'innerShdw', + 'blur' => '63500', + 'distance' => '50800', + 'direction' => '16200000', + ), + 18 => array( + 'effect' => 'innerShdw', + 'blur' => '63500', + 'distance' => '50800', + 'direction' => '13500000', + ), + //perspective + 19 => array( + 'effect' => 'outerShdw', + 'blur' => '152400', + 'distance' => '317500', + 'size' => array( + 'sx' => '90000', + 'sy' => '-19000', + ), + 'direction' => '5400000', + 'rotWithShape' => '0', + ), + 20 => array( + 'effect' => 'outerShdw', + 'blur' => '76200', + 'direction' => '18900000', + 'size' => array( + 'sy' => '23000', + 'kx' => '-1200000', + ), + 'algn' => 'bl', + 'rotWithShape' => '0', + ), + 21 => array( + 'effect' => 'outerShdw', + 'blur' => '76200', + 'direction' => '13500000', + 'size' => array( + 'sy' => '23000', + 'kx' => '1200000', + ), + 'algn' => 'br', + 'rotWithShape' => '0', + ), + 22 => array( + 'effect' => 'outerShdw', + 'blur' => '76200', + 'distance' => '12700', + 'direction' => '2700000', + 'size' => array( + 'sy' => '-23000', + 'kx' => '-800400', + ), + 'algn' => 'bl', + 'rotWithShape' => '0', + ), + 23 => array( + 'effect' => 'outerShdw', + 'blur' => '76200', + 'distance' => '12700', + 'direction' => '8100000', + 'size' => array( + 'sy' => '-23000', + 'kx' => '800400', + ), + 'algn' => 'br', + 'rotWithShape' => '0', + ), + ); + + return $presets_options[$shadow_presets_option]; + } + + protected function getArrayElementsValue($properties, $elements) { + $reference = & $properties; + if (!is_array($elements)) { + return $reference[$elements]; + } else { + foreach ($elements as $keys) { + $reference = & $reference[$keys]; + } + + return $reference; + } + + return $this; + } + +} \ No newline at end of file diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/Renderer/jpgraph.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/Renderer/jpgraph.php index 5245d701ead..dc7de6e66b9 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/Renderer/jpgraph.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Chart/Renderer/jpgraph.php @@ -554,7 +554,7 @@ class PHPExcel_Chart_Renderer_jpgraph private function _renderAreaChart($groupCount, $dimensions = '2d') { - require_once('jpgraph_line.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); $this->_renderCartesianPlotArea(); @@ -565,7 +565,7 @@ class PHPExcel_Chart_Renderer_jpgraph private function _renderLineChart($groupCount, $dimensions = '2d') { - require_once('jpgraph_line.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); $this->_renderCartesianPlotArea(); @@ -576,7 +576,7 @@ class PHPExcel_Chart_Renderer_jpgraph private function _renderBarChart($groupCount, $dimensions = '2d') { - require_once('jpgraph_bar.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_bar.php'); $this->_renderCartesianPlotArea(); @@ -587,9 +587,9 @@ class PHPExcel_Chart_Renderer_jpgraph private function _renderScatterChart($groupCount) { - require_once('jpgraph_scatter.php'); - require_once('jpgraph_regstat.php'); - require_once('jpgraph_line.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_regstat.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); $this->_renderCartesianPlotArea('linlin'); @@ -600,7 +600,7 @@ class PHPExcel_Chart_Renderer_jpgraph private function _renderBubbleChart($groupCount) { - require_once('jpgraph_scatter.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php'); $this->_renderCartesianPlotArea('linlin'); @@ -611,9 +611,9 @@ class PHPExcel_Chart_Renderer_jpgraph private function _renderPieChart($groupCount, $dimensions = '2d', $doughnut = False, $multiplePlots = False) { - require_once('jpgraph_pie.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_pie.php'); if ($dimensions == '3d') { - require_once('jpgraph_pie3d.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_pie3d.php'); } $this->_renderPiePlotArea($doughnut); @@ -686,7 +686,7 @@ class PHPExcel_Chart_Renderer_jpgraph private function _renderRadarChart($groupCount) { - require_once('jpgraph_radar.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_radar.php'); $this->_renderRadarPlotArea(); @@ -697,7 +697,7 @@ class PHPExcel_Chart_Renderer_jpgraph private function _renderStockChart($groupCount) { - require_once('jpgraph_stock.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_stock.php'); $this->_renderCartesianPlotArea('intint'); @@ -708,7 +708,7 @@ class PHPExcel_Chart_Renderer_jpgraph private function _renderContourChart($groupCount,$dimensions) { - require_once('jpgraph_contour.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_contour.php'); $this->_renderCartesianPlotArea('intint'); @@ -719,11 +719,11 @@ class PHPExcel_Chart_Renderer_jpgraph private function _renderCombinationChart($groupCount,$dimensions,$outputDestination) { - require_once('jpgraph_line.php'); - require_once('jpgraph_bar.php'); - require_once('jpgraph_scatter.php'); - require_once('jpgraph_regstat.php'); - require_once('jpgraph_line.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_bar.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_regstat.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); $this->_renderCartesianPlotArea(); diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Helper/HTML.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Helper/HTML.php new file mode 100644 index 00000000000..9e30ae8a794 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Helper/HTML.php @@ -0,0 +1,762 @@ + 'f0f8ff', + 'antiquewhite' => 'faebd7', + 'antiquewhite1' => 'ffefdb', + 'antiquewhite2' => 'eedfcc', + 'antiquewhite3' => 'cdc0b0', + 'antiquewhite4' => '8b8378', + 'aqua' => '00ffff', + 'aquamarine1' => '7fffd4', + 'aquamarine2' => '76eec6', + 'aquamarine4' => '458b74', + 'azure1' => 'f0ffff', + 'azure2' => 'e0eeee', + 'azure3' => 'c1cdcd', + 'azure4' => '838b8b', + 'beige' => 'f5f5dc', + 'bisque1' => 'ffe4c4', + 'bisque2' => 'eed5b7', + 'bisque3' => 'cdb79e', + 'bisque4' => '8b7d6b', + 'black' => '000000', + 'blanchedalmond' => 'ffebcd', + 'blue' => '0000ff', + 'blue1' => '0000ff', + 'blue2' => '0000ee', + 'blue4' => '00008b', + 'blueviolet' => '8a2be2', + 'brown' => 'a52a2a', + 'brown1' => 'ff4040', + 'brown2' => 'ee3b3b', + 'brown3' => 'cd3333', + 'brown4' => '8b2323', + 'burlywood' => 'deb887', + 'burlywood1' => 'ffd39b', + 'burlywood2' => 'eec591', + 'burlywood3' => 'cdaa7d', + 'burlywood4' => '8b7355', + 'cadetblue' => '5f9ea0', + 'cadetblue1' => '98f5ff', + 'cadetblue2' => '8ee5ee', + 'cadetblue3' => '7ac5cd', + 'cadetblue4' => '53868b', + 'chartreuse1' => '7fff00', + 'chartreuse2' => '76ee00', + 'chartreuse3' => '66cd00', + 'chartreuse4' => '458b00', + 'chocolate' => 'd2691e', + 'chocolate1' => 'ff7f24', + 'chocolate2' => 'ee7621', + 'chocolate3' => 'cd661d', + 'coral' => 'ff7f50', + 'coral1' => 'ff7256', + 'coral2' => 'ee6a50', + 'coral3' => 'cd5b45', + 'coral4' => '8b3e2f', + 'cornflowerblue' => '6495ed', + 'cornsilk1' => 'fff8dc', + 'cornsilk2' => 'eee8cd', + 'cornsilk3' => 'cdc8b1', + 'cornsilk4' => '8b8878', + 'cyan1' => '00ffff', + 'cyan2' => '00eeee', + 'cyan3' => '00cdcd', + 'cyan4' => '008b8b', + 'darkgoldenrod' => 'b8860b', + 'darkgoldenrod1' => 'ffb90f', + 'darkgoldenrod2' => 'eead0e', + 'darkgoldenrod3' => 'cd950c', + 'darkgoldenrod4' => '8b6508', + 'darkgreen' => '006400', + 'darkkhaki' => 'bdb76b', + 'darkolivegreen' => '556b2f', + 'darkolivegreen1' => 'caff70', + 'darkolivegreen2' => 'bcee68', + 'darkolivegreen3' => 'a2cd5a', + 'darkolivegreen4' => '6e8b3d', + 'darkorange' => 'ff8c00', + 'darkorange1' => 'ff7f00', + 'darkorange2' => 'ee7600', + 'darkorange3' => 'cd6600', + 'darkorange4' => '8b4500', + 'darkorchid' => '9932cc', + 'darkorchid1' => 'bf3eff', + 'darkorchid2' => 'b23aee', + 'darkorchid3' => '9a32cd', + 'darkorchid4' => '68228b', + 'darksalmon' => 'e9967a', + 'darkseagreen' => '8fbc8f', + 'darkseagreen1' => 'c1ffc1', + 'darkseagreen2' => 'b4eeb4', + 'darkseagreen3' => '9bcd9b', + 'darkseagreen4' => '698b69', + 'darkslateblue' => '483d8b', + 'darkslategray' => '2f4f4f', + 'darkslategray1' => '97ffff', + 'darkslategray2' => '8deeee', + 'darkslategray3' => '79cdcd', + 'darkslategray4' => '528b8b', + 'darkturquoise' => '00ced1', + 'darkviolet' => '9400d3', + 'deeppink1' => 'ff1493', + 'deeppink2' => 'ee1289', + 'deeppink3' => 'cd1076', + 'deeppink4' => '8b0a50', + 'deepskyblue1' => '00bfff', + 'deepskyblue2' => '00b2ee', + 'deepskyblue3' => '009acd', + 'deepskyblue4' => '00688b', + 'dimgray' => '696969', + 'dodgerblue1' => '1e90ff', + 'dodgerblue2' => '1c86ee', + 'dodgerblue3' => '1874cd', + 'dodgerblue4' => '104e8b', + 'firebrick' => 'b22222', + 'firebrick1' => 'ff3030', + 'firebrick2' => 'ee2c2c', + 'firebrick3' => 'cd2626', + 'firebrick4' => '8b1a1a', + 'floralwhite' => 'fffaf0', + 'forestgreen' => '228b22', + 'fuchsia' => 'ff00ff', + 'gainsboro' => 'dcdcdc', + 'ghostwhite' => 'f8f8ff', + 'gold1' => 'ffd700', + 'gold2' => 'eec900', + 'gold3' => 'cdad00', + 'gold4' => '8b7500', + 'goldenrod' => 'daa520', + 'goldenrod1' => 'ffc125', + 'goldenrod2' => 'eeb422', + 'goldenrod3' => 'cd9b1d', + 'goldenrod4' => '8b6914', + 'gray' => 'bebebe', + 'gray1' => '030303', + 'gray10' => '1a1a1a', + 'gray11' => '1c1c1c', + 'gray12' => '1f1f1f', + 'gray13' => '212121', + 'gray14' => '242424', + 'gray15' => '262626', + 'gray16' => '292929', + 'gray17' => '2b2b2b', + 'gray18' => '2e2e2e', + 'gray19' => '303030', + 'gray2' => '050505', + 'gray20' => '333333', + 'gray21' => '363636', + 'gray22' => '383838', + 'gray23' => '3b3b3b', + 'gray24' => '3d3d3d', + 'gray25' => '404040', + 'gray26' => '424242', + 'gray27' => '454545', + 'gray28' => '474747', + 'gray29' => '4a4a4a', + 'gray3' => '080808', + 'gray30' => '4d4d4d', + 'gray31' => '4f4f4f', + 'gray32' => '525252', + 'gray33' => '545454', + 'gray34' => '575757', + 'gray35' => '595959', + 'gray36' => '5c5c5c', + 'gray37' => '5e5e5e', + 'gray38' => '616161', + 'gray39' => '636363', + 'gray4' => '0a0a0a', + 'gray40' => '666666', + 'gray41' => '696969', + 'gray42' => '6b6b6b', + 'gray43' => '6e6e6e', + 'gray44' => '707070', + 'gray45' => '737373', + 'gray46' => '757575', + 'gray47' => '787878', + 'gray48' => '7a7a7a', + 'gray49' => '7d7d7d', + 'gray5' => '0d0d0d', + 'gray50' => '7f7f7f', + 'gray51' => '828282', + 'gray52' => '858585', + 'gray53' => '878787', + 'gray54' => '8a8a8a', + 'gray55' => '8c8c8c', + 'gray56' => '8f8f8f', + 'gray57' => '919191', + 'gray58' => '949494', + 'gray59' => '969696', + 'gray6' => '0f0f0f', + 'gray60' => '999999', + 'gray61' => '9c9c9c', + 'gray62' => '9e9e9e', + 'gray63' => 'a1a1a1', + 'gray64' => 'a3a3a3', + 'gray65' => 'a6a6a6', + 'gray66' => 'a8a8a8', + 'gray67' => 'ababab', + 'gray68' => 'adadad', + 'gray69' => 'b0b0b0', + 'gray7' => '121212', + 'gray70' => 'b3b3b3', + 'gray71' => 'b5b5b5', + 'gray72' => 'b8b8b8', + 'gray73' => 'bababa', + 'gray74' => 'bdbdbd', + 'gray75' => 'bfbfbf', + 'gray76' => 'c2c2c2', + 'gray77' => 'c4c4c4', + 'gray78' => 'c7c7c7', + 'gray79' => 'c9c9c9', + 'gray8' => '141414', + 'gray80' => 'cccccc', + 'gray81' => 'cfcfcf', + 'gray82' => 'd1d1d1', + 'gray83' => 'd4d4d4', + 'gray84' => 'd6d6d6', + 'gray85' => 'd9d9d9', + 'gray86' => 'dbdbdb', + 'gray87' => 'dedede', + 'gray88' => 'e0e0e0', + 'gray89' => 'e3e3e3', + 'gray9' => '171717', + 'gray90' => 'e5e5e5', + 'gray91' => 'e8e8e8', + 'gray92' => 'ebebeb', + 'gray93' => 'ededed', + 'gray94' => 'f0f0f0', + 'gray95' => 'f2f2f2', + 'gray97' => 'f7f7f7', + 'gray98' => 'fafafa', + 'gray99' => 'fcfcfc', + 'green' => '00ff00', + 'green1' => '00ff00', + 'green2' => '00ee00', + 'green3' => '00cd00', + 'green4' => '008b00', + 'greenyellow' => 'adff2f', + 'honeydew1' => 'f0fff0', + 'honeydew2' => 'e0eee0', + 'honeydew3' => 'c1cdc1', + 'honeydew4' => '838b83', + 'hotpink' => 'ff69b4', + 'hotpink1' => 'ff6eb4', + 'hotpink2' => 'ee6aa7', + 'hotpink3' => 'cd6090', + 'hotpink4' => '8b3a62', + 'indianred' => 'cd5c5c', + 'indianred1' => 'ff6a6a', + 'indianred2' => 'ee6363', + 'indianred3' => 'cd5555', + 'indianred4' => '8b3a3a', + 'ivory1' => 'fffff0', + 'ivory2' => 'eeeee0', + 'ivory3' => 'cdcdc1', + 'ivory4' => '8b8b83', + 'khaki' => 'f0e68c', + 'khaki1' => 'fff68f', + 'khaki2' => 'eee685', + 'khaki3' => 'cdc673', + 'khaki4' => '8b864e', + 'lavender' => 'e6e6fa', + 'lavenderblush1' => 'fff0f5', + 'lavenderblush2' => 'eee0e5', + 'lavenderblush3' => 'cdc1c5', + 'lavenderblush4' => '8b8386', + 'lawngreen' => '7cfc00', + 'lemonchiffon1' => 'fffacd', + 'lemonchiffon2' => 'eee9bf', + 'lemonchiffon3' => 'cdc9a5', + 'lemonchiffon4' => '8b8970', + 'light' => 'eedd82', + 'lightblue' => 'add8e6', + 'lightblue1' => 'bfefff', + 'lightblue2' => 'b2dfee', + 'lightblue3' => '9ac0cd', + 'lightblue4' => '68838b', + 'lightcoral' => 'f08080', + 'lightcyan1' => 'e0ffff', + 'lightcyan2' => 'd1eeee', + 'lightcyan3' => 'b4cdcd', + 'lightcyan4' => '7a8b8b', + 'lightgoldenrod1' => 'ffec8b', + 'lightgoldenrod2' => 'eedc82', + 'lightgoldenrod3' => 'cdbe70', + 'lightgoldenrod4' => '8b814c', + 'lightgoldenrodyellow' => 'fafad2', + 'lightgray' => 'd3d3d3', + 'lightpink' => 'ffb6c1', + 'lightpink1' => 'ffaeb9', + 'lightpink2' => 'eea2ad', + 'lightpink3' => 'cd8c95', + 'lightpink4' => '8b5f65', + 'lightsalmon1' => 'ffa07a', + 'lightsalmon2' => 'ee9572', + 'lightsalmon3' => 'cd8162', + 'lightsalmon4' => '8b5742', + 'lightseagreen' => '20b2aa', + 'lightskyblue' => '87cefa', + 'lightskyblue1' => 'b0e2ff', + 'lightskyblue2' => 'a4d3ee', + 'lightskyblue3' => '8db6cd', + 'lightskyblue4' => '607b8b', + 'lightslateblue' => '8470ff', + 'lightslategray' => '778899', + 'lightsteelblue' => 'b0c4de', + 'lightsteelblue1' => 'cae1ff', + 'lightsteelblue2' => 'bcd2ee', + 'lightsteelblue3' => 'a2b5cd', + 'lightsteelblue4' => '6e7b8b', + 'lightyellow1' => 'ffffe0', + 'lightyellow2' => 'eeeed1', + 'lightyellow3' => 'cdcdb4', + 'lightyellow4' => '8b8b7a', + 'lime' => '00ff00', + 'limegreen' => '32cd32', + 'linen' => 'faf0e6', + 'magenta' => 'ff00ff', + 'magenta2' => 'ee00ee', + 'magenta3' => 'cd00cd', + 'magenta4' => '8b008b', + 'maroon' => 'b03060', + 'maroon1' => 'ff34b3', + 'maroon2' => 'ee30a7', + 'maroon3' => 'cd2990', + 'maroon4' => '8b1c62', + 'medium' => '66cdaa', + 'mediumaquamarine' => '66cdaa', + 'mediumblue' => '0000cd', + 'mediumorchid' => 'ba55d3', + 'mediumorchid1' => 'e066ff', + 'mediumorchid2' => 'd15fee', + 'mediumorchid3' => 'b452cd', + 'mediumorchid4' => '7a378b', + 'mediumpurple' => '9370db', + 'mediumpurple1' => 'ab82ff', + 'mediumpurple2' => '9f79ee', + 'mediumpurple3' => '8968cd', + 'mediumpurple4' => '5d478b', + 'mediumseagreen' => '3cb371', + 'mediumslateblue' => '7b68ee', + 'mediumspringgreen' => '00fa9a', + 'mediumturquoise' => '48d1cc', + 'mediumvioletred' => 'c71585', + 'midnightblue' => '191970', + 'mintcream' => 'f5fffa', + 'mistyrose1' => 'ffe4e1', + 'mistyrose2' => 'eed5d2', + 'mistyrose3' => 'cdb7b5', + 'mistyrose4' => '8b7d7b', + 'moccasin' => 'ffe4b5', + 'navajowhite1' => 'ffdead', + 'navajowhite2' => 'eecfa1', + 'navajowhite3' => 'cdb38b', + 'navajowhite4' => '8b795e', + 'navy' => '000080', + 'navyblue' => '000080', + 'oldlace' => 'fdf5e6', + 'olive' => '808000', + 'olivedrab' => '6b8e23', + 'olivedrab1' => 'c0ff3e', + 'olivedrab2' => 'b3ee3a', + 'olivedrab4' => '698b22', + 'orange' => 'ffa500', + 'orange1' => 'ffa500', + 'orange2' => 'ee9a00', + 'orange3' => 'cd8500', + 'orange4' => '8b5a00', + 'orangered1' => 'ff4500', + 'orangered2' => 'ee4000', + 'orangered3' => 'cd3700', + 'orangered4' => '8b2500', + 'orchid' => 'da70d6', + 'orchid1' => 'ff83fa', + 'orchid2' => 'ee7ae9', + 'orchid3' => 'cd69c9', + 'orchid4' => '8b4789', + 'pale' => 'db7093', + 'palegoldenrod' => 'eee8aa', + 'palegreen' => '98fb98', + 'palegreen1' => '9aff9a', + 'palegreen2' => '90ee90', + 'palegreen3' => '7ccd7c', + 'palegreen4' => '548b54', + 'paleturquoise' => 'afeeee', + 'paleturquoise1' => 'bbffff', + 'paleturquoise2' => 'aeeeee', + 'paleturquoise3' => '96cdcd', + 'paleturquoise4' => '668b8b', + 'palevioletred' => 'db7093', + 'palevioletred1' => 'ff82ab', + 'palevioletred2' => 'ee799f', + 'palevioletred3' => 'cd6889', + 'palevioletred4' => '8b475d', + 'papayawhip' => 'ffefd5', + 'peachpuff1' => 'ffdab9', + 'peachpuff2' => 'eecbad', + 'peachpuff3' => 'cdaf95', + 'peachpuff4' => '8b7765', + 'pink' => 'ffc0cb', + 'pink1' => 'ffb5c5', + 'pink2' => 'eea9b8', + 'pink3' => 'cd919e', + 'pink4' => '8b636c', + 'plum' => 'dda0dd', + 'plum1' => 'ffbbff', + 'plum2' => 'eeaeee', + 'plum3' => 'cd96cd', + 'plum4' => '8b668b', + 'powderblue' => 'b0e0e6', + 'purple' => 'a020f0', + 'rebeccapurple' => '663399', + 'purple1' => '9b30ff', + 'purple2' => '912cee', + 'purple3' => '7d26cd', + 'purple4' => '551a8b', + 'red' => 'ff0000', + 'red1' => 'ff0000', + 'red2' => 'ee0000', + 'red3' => 'cd0000', + 'red4' => '8b0000', + 'rosybrown' => 'bc8f8f', + 'rosybrown1' => 'ffc1c1', + 'rosybrown2' => 'eeb4b4', + 'rosybrown3' => 'cd9b9b', + 'rosybrown4' => '8b6969', + 'royalblue' => '4169e1', + 'royalblue1' => '4876ff', + 'royalblue2' => '436eee', + 'royalblue3' => '3a5fcd', + 'royalblue4' => '27408b', + 'saddlebrown' => '8b4513', + 'salmon' => 'fa8072', + 'salmon1' => 'ff8c69', + 'salmon2' => 'ee8262', + 'salmon3' => 'cd7054', + 'salmon4' => '8b4c39', + 'sandybrown' => 'f4a460', + 'seagreen1' => '54ff9f', + 'seagreen2' => '4eee94', + 'seagreen3' => '43cd80', + 'seagreen4' => '2e8b57', + 'seashell1' => 'fff5ee', + 'seashell2' => 'eee5de', + 'seashell3' => 'cdc5bf', + 'seashell4' => '8b8682', + 'sienna' => 'a0522d', + 'sienna1' => 'ff8247', + 'sienna2' => 'ee7942', + 'sienna3' => 'cd6839', + 'sienna4' => '8b4726', + 'silver' => 'c0c0c0', + 'skyblue' => '87ceeb', + 'skyblue1' => '87ceff', + 'skyblue2' => '7ec0ee', + 'skyblue3' => '6ca6cd', + 'skyblue4' => '4a708b', + 'slateblue' => '6a5acd', + 'slateblue1' => '836fff', + 'slateblue2' => '7a67ee', + 'slateblue3' => '6959cd', + 'slateblue4' => '473c8b', + 'slategray' => '708090', + 'slategray1' => 'c6e2ff', + 'slategray2' => 'b9d3ee', + 'slategray3' => '9fb6cd', + 'slategray4' => '6c7b8b', + 'snow1' => 'fffafa', + 'snow2' => 'eee9e9', + 'snow3' => 'cdc9c9', + 'snow4' => '8b8989', + 'springgreen1' => '00ff7f', + 'springgreen2' => '00ee76', + 'springgreen3' => '00cd66', + 'springgreen4' => '008b45', + 'steelblue' => '4682b4', + 'steelblue1' => '63b8ff', + 'steelblue2' => '5cacee', + 'steelblue3' => '4f94cd', + 'steelblue4' => '36648b', + 'tan' => 'd2b48c', + 'tan1' => 'ffa54f', + 'tan2' => 'ee9a49', + 'tan3' => 'cd853f', + 'tan4' => '8b5a2b', + 'teal' => '008080', + 'thistle' => 'd8bfd8', + 'thistle1' => 'ffe1ff', + 'thistle2' => 'eed2ee', + 'thistle3' => 'cdb5cd', + 'thistle4' => '8b7b8b', + 'tomato1' => 'ff6347', + 'tomato2' => 'ee5c42', + 'tomato3' => 'cd4f39', + 'tomato4' => '8b3626', + 'turquoise' => '40e0d0', + 'turquoise1' => '00f5ff', + 'turquoise2' => '00e5ee', + 'turquoise3' => '00c5cd', + 'turquoise4' => '00868b', + 'violet' => 'ee82ee', + 'violetred' => 'd02090', + 'violetred1' => 'ff3e96', + 'violetred2' => 'ee3a8c', + 'violetred3' => 'cd3278', + 'violetred4' => '8b2252', + 'wheat' => 'f5deb3', + 'wheat1' => 'ffe7ba', + 'wheat2' => 'eed8ae', + 'wheat3' => 'cdba96', + 'wheat4' => '8b7e66', + 'white' => 'ffffff', + 'whitesmoke' => 'f5f5f5', + 'yellow' => 'ffff00', + 'yellow1' => 'ffff00', + 'yellow2' => 'eeee00', + 'yellow3' => 'cdcd00', + 'yellow4' => '8b8b00', + 'yellowgreen' => '9acd32', + ); + + protected $face; + protected $size; + protected $color; + + protected $bold = false; + protected $italic = false; + protected $underline = false; + protected $superscript = false; + protected $subscript = false; + protected $strikethrough = false; + + protected $startTagCallbacks = array( + 'font' => 'startFontTag', + 'b' => 'startBoldTag', + 'strong' => 'startBoldTag', + 'i' => 'startItalicTag', + 'em' => 'startItalicTag', + 'u' => 'startUnderlineTag', + 'ins' => 'startUnderlineTag', + 'del' => 'startStrikethruTag', + 'sup' => 'startSuperscriptTag', + 'sub' => 'startSubscriptTag', + ); + + protected $endTagCallbacks = array( + 'font' => 'endFontTag', + 'b' => 'endBoldTag', + 'strong' => 'endBoldTag', + 'i' => 'endItalicTag', + 'em' => 'endItalicTag', + 'u' => 'endUnderlineTag', + 'ins' => 'endUnderlineTag', + 'del' => 'endStrikethruTag', + 'sup' => 'endSuperscriptTag', + 'sub' => 'endSubscriptTag', + 'br' => 'breakTag', + 'p' => 'breakTag', + 'h1' => 'breakTag', + 'h2' => 'breakTag', + 'h3' => 'breakTag', + 'h4' => 'breakTag', + 'h5' => 'breakTag', + 'h6' => 'breakTag', + ); + + protected $stack = array(); + + protected $stringData = ''; + + protected $richTextObject; + + protected function initialise() { + $this->face = $this->size = $this->color = null; + $this->bold = $this->italic = $this->underline = $this->superscript = $this->subscript = $this->strikethrough = false; + + $this->stack = array(); + + $this->stringData = ''; + } + + public function toRichTextObject($html) { + $this->initialise(); + + // Create a new DOM object + $dom = new domDocument; + // Load the HTML file into the DOM object + // Note the use of error suppression, because typically this will be an html fragment, so not fully valid markup + $loaded = @$dom->loadHTML($html); + + // Discard excess white space + $dom->preserveWhiteSpace = false; + + $this->richTextObject = new PHPExcel_RichText();; + $this->parseElements($dom); + return $this->richTextObject; + } + + protected function buildTextRun() { + $text = $this->stringData; + if (trim($text) === '') + return; + + $richtextRun = $this->richTextObject->createTextRun($this->stringData); + if ($this->face) { + $richtextRun->getFont()->setName($this->face); + } + if ($this->size) { + $richtextRun->getFont()->setSize($this->size); + } + if ($this->color) { + $richtextRun->getFont()->setColor( new PHPExcel_Style_Color( 'ff' . $this->color ) ); + } + if ($this->bold) { + $richtextRun->getFont()->setBold(true); + } + if ($this->italic) { + $richtextRun->getFont()->setItalic(true); + } + if ($this->underline) { + $richtextRun->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE); + } + if ($this->superscript) { + $richtextRun->getFont()->setSuperScript(true); + } + if ($this->subscript) { + $richtextRun->getFont()->setSubScript(true); + } + if ($this->strikethrough) { + $richtextRun->getFont()->setStrikethrough(true); + } + $this->stringData = ''; + } + + protected function rgbToColour($rgb) { + preg_match_all('/\d+/', $rgb, $values); + foreach($values[0] as &$value) { + $value = str_pad(dechex($value), 2, '0', STR_PAD_LEFT); + } + return implode($values[0]); + } + + protected function colourNameLookup($rgb) { + return self::$colourMap[$rgb]; + } + + protected function startFontTag($tag) { + foreach ($tag->attributes as $attribute) { + $attributeName = strtolower($attribute->name); + $attributeValue = $attribute->value; + + if ($attributeName == 'color') { + if (preg_match('/rgb\s*\(/', $attributeValue)) { + $this->$attributeName = $this->rgbToColour($attributeValue); + } elseif(strpos(trim($attributeValue), '#') === 0) { + $this->$attributeName = ltrim($attributeValue, '#'); + } else { + $this->$attributeName = $this->colourNameLookup($attributeValue); + } + } else { + $this->$attributeName = $attributeValue; + } + } + } + + protected function endFontTag() { + $this->face = $this->size = $this->color = null; + } + + protected function startBoldTag() { + $this->bold = true; + } + + protected function endBoldTag() { + $this->bold = false; + } + + protected function startItalicTag() { + $this->italic = true; + } + + protected function endItalicTag() { + $this->italic = false; + } + + protected function startUnderlineTag() { + $this->underline = true; + } + + protected function endUnderlineTag() { + $this->underline = false; + } + + protected function startSubscriptTag() { + $this->subscript = true; + } + + protected function endSubscriptTag() { + $this->subscript = false; + } + + protected function startSuperscriptTag() { + $this->superscript = true; + } + + protected function endSuperscriptTag() { + $this->superscript = false; + } + + protected function startStrikethruTag() { + $this->strikethrough = true; + } + + protected function endStrikethruTag() { + $this->strikethrough = false; + } + + protected function breakTag() { + $this->stringData .= PHP_EOL; + } + + protected function parseTextNode(DOMText $textNode) { + $domText = preg_replace('/\s+/u', ' ', ltrim($textNode->nodeValue)); + $this->stringData .= $domText; + $this->buildTextRun(); + } + + protected function handleCallback($element, $callbackTag, $callbacks) { + if (isset($callbacks[$callbackTag])) { + $elementHandler = $callbacks[$callbackTag]; + if (method_exists($this, $elementHandler)) { + call_user_func(array($this, $elementHandler), $element); + } + } + } + + protected function parseElementNode(DOMElement $element) { + $callbackTag = strtolower($element->nodeName); + $this->stack[] = $callbackTag; + + $this->handleCallback($element, $callbackTag, $this->startTagCallbacks); + + $this->parseElements($element); + $this->stringData .= ' '; + array_pop($this->stack); + + $this->handleCallback($element, $callbackTag, $this->endTagCallbacks); + } + + protected function parseElements(DOMNode $element) { + foreach ($element->childNodes as $child) { + if ($child instanceof DOMText) { + $this->parseTextNode($child); + } elseif ($child instanceof DOMElement) { + $this->parseElementNode($child); + } + } + } +} diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Abstract.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Abstract.php index e0f4c0dc3cb..2d3c964b60b 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Abstract.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Abstract.php @@ -145,7 +145,10 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader */ public function setLoadSheetsOnly($value = NULL) { - $this->_loadSheetsOnly = is_array($value) ? + if ($value === NULL) + return $this->setLoadAllSheets(); + + $this->_loadSheetsOnly = is_array($value) ? $value : array($value); return $this; } @@ -224,4 +227,29 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader return $readable; } + /** + * Scan theXML for use of securityScan(file_get_contents($filestream)); + } } diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/CSV.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/CSV.php index 043aeecf575..22176fdc99f 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/CSV.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/CSV.php @@ -68,14 +68,6 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R */ private $_enclosure = '"'; - /** - * Line ending - * - * @access private - * @var string - */ - private $_lineEnding = PHP_EOL; - /** * Sheet index to read * @@ -348,26 +340,6 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R return $this; } - /** - * Get line ending - * - * @return string - */ - public function getLineEnding() { - return $this->_lineEnding; - } - - /** - * Set line ending - * - * @param string $pValue Line ending, defaults to OS line ending (PHP_EOL) - * @return PHPExcel_Reader_CSV - */ - public function setLineEnding($pValue = PHP_EOL) { - $this->_lineEnding = $pValue; - return $this; - } - /** * Get sheet index * diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2003XML.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2003XML.php index 17472d0401b..851eaab1813 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2003XML.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2003XML.php @@ -49,14 +49,14 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P * * @var array */ - private $_styles = array(); + protected $_styles = array(); /** * Character set used in the file * * @var string */ - private $_charSet = 'UTF-8'; + protected $_charSet = 'UTF-8'; /** @@ -137,7 +137,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P $worksheetNames = array(); - $xml = simplexml_load_file($pFilename, 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $xml = simplexml_load_string($this->securityScan(file_get_contents($pFilename)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $namespaces = $xml->getNamespaces(true); $xml_ss = $xml->children($namespaces['ss']); @@ -165,7 +165,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P $worksheetInfo = array(); - $xml = simplexml_load_file($pFilename, 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $xml = simplexml_load_string($this->securityScan(file_get_contents($pFilename)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $namespaces = $xml->getNamespaces(true); $worksheetID = 1; @@ -232,13 +232,14 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P { // Create new PHPExcel $objPHPExcel = new PHPExcel(); + $objPHPExcel->removeSheetByIndex(0); // Load into this instance return $this->loadIntoExisting($pFilename, $objPHPExcel); } - private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) { + protected static function identifyFixedStyleValue($styleList,&$styleAttributeValue) { $styleAttributeValue = strtolower($styleAttributeValue); foreach($styleList as $style) { if ($styleAttributeValue == strtolower($style)) { @@ -255,7 +256,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P * @param pxs * @return */ - private static function _pixel2WidthUnits($pxs) { + protected static function _pixel2WidthUnits($pxs) { $UNIT_OFFSET_MAP = array(0, 36, 73, 109, 146, 182, 219); $widthUnits = 256 * ($pxs / 7); @@ -269,7 +270,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P * @param widthUnits * @return */ - private static function _widthUnits2Pixel($widthUnits) { + protected static function _widthUnits2Pixel($widthUnits) { $pixels = ($widthUnits / 256) * 7; $offsetWidthUnits = $widthUnits % 256; $pixels += round($offsetWidthUnits / (256 / 7)); @@ -277,7 +278,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P } - private static function _hex2str($hex) { + protected static function _hex2str($hex) { return chr(hexdec($hex[1])); } @@ -330,7 +331,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); } - $xml = simplexml_load_file($pFilename, 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $xml = simplexml_load_string($this->securityScan(file_get_contents($pFilename)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $namespaces = $xml->getNamespaces(true); $docProps = $objPHPExcel->getProperties(); @@ -576,6 +577,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P $rowID = 1; if (isset($worksheet->Table->Row)) { + $additionalMergedCells = 0; foreach($worksheet->Table->Row as $rowData) { $rowHasData = false; $row_ss = $rowData->attributes($namespaces['ss']); @@ -602,6 +604,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P if ((isset($cell_ss['MergeAcross'])) || (isset($cell_ss['MergeDown']))) { $columnTo = $columnID; if (isset($cell_ss['MergeAcross'])) { + $additionalMergedCells += (int)$cell_ss['MergeAcross']; $columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cell_ss['MergeAcross'] -1); } $rowTo = $rowID; @@ -759,6 +762,10 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P } } ++$columnID; + while ($additionalMergedCells > 0) { + ++$columnID; + $additionalMergedCells--; + } } if ($rowHasData) { @@ -783,7 +790,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P } - private static function _convertStringEncoding($string,$charset) { + protected static function _convertStringEncoding($string,$charset) { if ($charset != 'UTF-8') { return PHPExcel_Shared_String::ConvertEncoding($string,'UTF-8',$charset); } @@ -791,7 +798,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P } - private function _parseRichText($is = '') { + protected function _parseRichText($is = '') { $value = new PHPExcel_RichText(); $value->createText(self::_convertStringEncoding($is,$this->_charSet)); diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2007.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2007.php index 105904c64af..e41596afcac 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2007.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2007.php @@ -94,7 +94,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $zip = new $zipClass; if ($zip->open($pFilename) === true) { // check if it is an OOXML archive - $rels = simplexml_load_string($this->_getFromZipArchive($zip, "_rels/.rels"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $rels = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "_rels/.rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); if ($rels !== false) { foreach ($rels->Relationship as $rel) { switch ($rel["Type"]) { @@ -136,13 +136,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // The files we're looking at here are small enough that simpleXML is more efficient than XMLReader $rels = simplexml_load_string( - $this->_getFromZipArchive($zip, "_rels/.rels", 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()) + $this->securityScan($this->_getFromZipArchive($zip, "_rels/.rels"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()) ); //~ http://schemas.openxmlformats.org/package/2006/relationships"); foreach ($rels->Relationship as $rel) { switch ($rel["Type"]) { case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument": $xmlWorkbook = simplexml_load_string( - $this->_getFromZipArchive($zip, "{$rel['Target']}", 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()) + $this->securityScan($this->_getFromZipArchive($zip, "{$rel['Target']}"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()) ); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); if ($xmlWorkbook->sheets) { @@ -180,11 +180,11 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $zip = new $zipClass; $zip->open($pFilename); - $rels = simplexml_load_string($this->_getFromZipArchive($zip, "_rels/.rels"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $rels = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "_rels/.rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); foreach ($rels->Relationship as $rel) { if ($rel["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument") { $dir = dirname($rel["Target"]); - $relsWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/_rels/" . basename($rel["Target"]) . ".rels"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsWorkbook = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "$dir/_rels/" . basename($rel["Target"]) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $relsWorkbook->registerXPathNamespace("rel", "http://schemas.openxmlformats.org/package/2006/relationships"); $worksheets = array(); @@ -194,7 +194,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } } - $xmlWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); + $xmlWorkbook = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); if ($xmlWorkbook->sheets) { $dir = dirname($rel["Target"]); foreach ($xmlWorkbook->sheets->sheet as $eleSheet) { @@ -209,7 +209,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")]; $xml = new XMLReader(); - $res = $xml->open('zip://'.PHPExcel_Shared_File::realpath($pFilename).'#'."$dir/$fileWorksheet", null, PHPExcel_Settings::getLibXmlLoaderOptions()); + $res = $xml->xml($this->securityScanFile('zip://'.PHPExcel_Shared_File::realpath($pFilename).'#'."$dir/$fileWorksheet"), null, PHPExcel_Settings::getLibXmlLoaderOptions()); $xml->setParserProperty(2,true); $currCells = 0; @@ -338,6 +338,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE * Loads PHPExcel from file * * @param string $pFilename + * @return PHPExcel * @throws PHPExcel_Reader_Exception */ public function load($pFilename) @@ -361,14 +362,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $zip->open($pFilename); // Read the theme first, because we need the colour scheme when reading the styles - $wbRels = simplexml_load_string($this->_getFromZipArchive($zip, "xl/_rels/workbook.xml.rels"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $wbRels = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "xl/_rels/workbook.xml.rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); foreach ($wbRels->Relationship as $rel) { switch ($rel["Type"]) { case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme": $themeOrderArray = array('lt1','dk1','lt2','dk2'); $themeOrderAdditional = count($themeOrderArray); - $xmlTheme = simplexml_load_string($this->_getFromZipArchive($zip, "xl/{$rel['Target']}"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $xmlTheme = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "xl/{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); if (is_object($xmlTheme)) { $xmlThemeName = $xmlTheme->attributes(); $xmlTheme = $xmlTheme->children("http://schemas.openxmlformats.org/drawingml/2006/main"); @@ -398,11 +399,11 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } } - $rels = simplexml_load_string($this->_getFromZipArchive($zip, "_rels/.rels"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $rels = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "_rels/.rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); foreach ($rels->Relationship as $rel) { switch ($rel["Type"]) { case "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties": - $xmlCore = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $xmlCore = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); if (is_object($xmlCore)) { $xmlCore->registerXPathNamespace("dc", "http://purl.org/dc/elements/1.1/"); $xmlCore->registerXPathNamespace("dcterms", "http://purl.org/dc/terms/"); @@ -421,7 +422,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE break; case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties": - $xmlCore = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $xmlCore = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); if (is_object($xmlCore)) { $docProps = $excel->getProperties(); if (isset($xmlCore->Company)) @@ -432,7 +433,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE break; case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties": - $xmlCore = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $xmlCore = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); if (is_object($xmlCore)) { $docProps = $excel->getProperties(); foreach ($xmlCore as $xmlProperty) { @@ -458,12 +459,12 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE break; case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument": $dir = dirname($rel["Target"]); - $relsWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/_rels/" . basename($rel["Target"]) . ".rels"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsWorkbook = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "$dir/_rels/" . basename($rel["Target"]) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $relsWorkbook->registerXPathNamespace("rel", "http://schemas.openxmlformats.org/package/2006/relationships"); $sharedStrings = array(); $xpath = self::array_item($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings']")); - $xmlStrings = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/$xpath[Target]"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); + $xmlStrings = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "$dir/$xpath[Target]")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); if (isset($xmlStrings) && isset($xmlStrings->si)) { foreach ($xmlStrings->si as $val) { if (isset($val->t)) { @@ -478,7 +479,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $macros = $customUI = NULL; foreach ($relsWorkbook->Relationship as $ele) { switch($ele['Type']){ - case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet": + case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet": $worksheets[(string) $ele["Id"]] = $ele["Target"]; break; // a vbaProject ? (: some macros) @@ -502,7 +503,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $styles = array(); $cellStyles = array(); $xpath = self::array_item($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']")); - $xmlStyles = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/$xpath[Target]"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); + $xmlStyles = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "$dir/$xpath[Target]")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); $numFmts = null; if ($xmlStyles && $xmlStyles->numFmts[0]) { $numFmts = $xmlStyles->numFmts[0]; @@ -606,7 +607,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } } - $xmlWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); + $xmlWorkbook = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); // Set base date if ($xmlWorkbook->workbookPr) { @@ -649,7 +650,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // reverse $docSheet->setTitle((string) $eleSheet["name"],false); $fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")]; - $xmlSheet = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/$fileWorksheet"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); + $xmlSheet = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "$dir/$fileWorksheet")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); $sharedFormulas = array(); @@ -756,7 +757,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } if (isset($xmlSheet->sheetFormatPr['zeroHeight']) && ((string)$xmlSheet->sheetFormatPr['zeroHeight'] == '1')) { - $docSheet->getDefaultRowDimension()->setzeroHeight(true); + $docSheet->getDefaultRowDimension()->setZeroHeight(true); } } @@ -1005,102 +1006,106 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } if ($xmlSheet && $xmlSheet->autoFilter && !$this->_readDataOnly) { - $autoFilter = $docSheet->getAutoFilter(); - $autoFilter->setRange((string) $xmlSheet->autoFilter["ref"]); - foreach ($xmlSheet->autoFilter->filterColumn as $filterColumn) { - $column = $autoFilter->getColumnByOffset((integer) $filterColumn["colId"]); - // Check for standard filters - if ($filterColumn->filters) { - $column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER); - $filters = $filterColumn->filters; - if ((isset($filters["blank"])) && ($filters["blank"] == 1)) { - $column->createRule()->setRule( - NULL, // Operator is undefined, but always treated as EQUAL - '' - ) - ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER); - } - // Standard filters are always an OR join, so no join rule needs to be set - // Entries can be either filter elements - foreach ($filters->filter as $filterRule) { - $column->createRule()->setRule( - NULL, // Operator is undefined, but always treated as EQUAL - (string) $filterRule["val"] - ) - ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER); - } - // Or Date Group elements - foreach ($filters->dateGroupItem as $dateGroupItem) { - $column->createRule()->setRule( - NULL, // Operator is undefined, but always treated as EQUAL - array( - 'year' => (string) $dateGroupItem["year"], - 'month' => (string) $dateGroupItem["month"], - 'day' => (string) $dateGroupItem["day"], - 'hour' => (string) $dateGroupItem["hour"], - 'minute' => (string) $dateGroupItem["minute"], - 'second' => (string) $dateGroupItem["second"], - ), - (string) $dateGroupItem["dateTimeGrouping"] - ) - ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP); - } - } - // Check for custom filters - if ($filterColumn->customFilters) { - $column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER); - $customFilters = $filterColumn->customFilters; - // Custom filters can an AND or an OR join; - // and there should only ever be one or two entries - if ((isset($customFilters["and"])) && ($customFilters["and"] == 1)) { - $column->setJoin(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND); - } - foreach ($customFilters->customFilter as $filterRule) { - $column->createRule()->setRule( - (string) $filterRule["operator"], - (string) $filterRule["val"] - ) - ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); - } - } - // Check for dynamic filters - if ($filterColumn->dynamicFilter) { - $column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER); - // We should only ever have one dynamic filter - foreach ($filterColumn->dynamicFilter as $filterRule) { - $column->createRule()->setRule( - NULL, // Operator is undefined, but always treated as EQUAL - (string) $filterRule["val"], - (string) $filterRule["type"] - ) - ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER); - if (isset($filterRule["val"])) { - $column->setAttribute('val',(string) $filterRule["val"]); - } - if (isset($filterRule["maxVal"])) { - $column->setAttribute('maxVal',(string) $filterRule["maxVal"]); - } - } - } - // Check for dynamic filters - if ($filterColumn->top10) { - $column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER); - // We should only ever have one top10 filter - foreach ($filterColumn->top10 as $filterRule) { - $column->createRule()->setRule( - (((isset($filterRule["percent"])) && ($filterRule["percent"] == 1)) - ? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT - : PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE - ), - (string) $filterRule["val"], - (((isset($filterRule["top"])) && ($filterRule["top"] == 1)) - ? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP - : PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM - ) - ) - ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_TOPTENFILTER); - } - } + $autoFilterRange = (string) $xmlSheet->autoFilter["ref"]; + if (strpos($autoFilterRange, ':') !== false) { + $autoFilter = $docSheet->getAutoFilter(); + $autoFilter->setRange($autoFilterRange); + + foreach ($xmlSheet->autoFilter->filterColumn as $filterColumn) { + $column = $autoFilter->getColumnByOffset((integer) $filterColumn["colId"]); + // Check for standard filters + if ($filterColumn->filters) { + $column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER); + $filters = $filterColumn->filters; + if ((isset($filters["blank"])) && ($filters["blank"] == 1)) { + $column->createRule()->setRule( + NULL, // Operator is undefined, but always treated as EQUAL + '' + ) + ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER); + } + // Standard filters are always an OR join, so no join rule needs to be set + // Entries can be either filter elements + foreach ($filters->filter as $filterRule) { + $column->createRule()->setRule( + NULL, // Operator is undefined, but always treated as EQUAL + (string) $filterRule["val"] + ) + ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER); + } + // Or Date Group elements + foreach ($filters->dateGroupItem as $dateGroupItem) { + $column->createRule()->setRule( + NULL, // Operator is undefined, but always treated as EQUAL + array( + 'year' => (string) $dateGroupItem["year"], + 'month' => (string) $dateGroupItem["month"], + 'day' => (string) $dateGroupItem["day"], + 'hour' => (string) $dateGroupItem["hour"], + 'minute' => (string) $dateGroupItem["minute"], + 'second' => (string) $dateGroupItem["second"], + ), + (string) $dateGroupItem["dateTimeGrouping"] + ) + ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP); + } + } + // Check for custom filters + if ($filterColumn->customFilters) { + $column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER); + $customFilters = $filterColumn->customFilters; + // Custom filters can an AND or an OR join; + // and there should only ever be one or two entries + if ((isset($customFilters["and"])) && ($customFilters["and"] == 1)) { + $column->setJoin(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND); + } + foreach ($customFilters->customFilter as $filterRule) { + $column->createRule()->setRule( + (string) $filterRule["operator"], + (string) $filterRule["val"] + ) + ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER); + } + } + // Check for dynamic filters + if ($filterColumn->dynamicFilter) { + $column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER); + // We should only ever have one dynamic filter + foreach ($filterColumn->dynamicFilter as $filterRule) { + $column->createRule()->setRule( + NULL, // Operator is undefined, but always treated as EQUAL + (string) $filterRule["val"], + (string) $filterRule["type"] + ) + ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER); + if (isset($filterRule["val"])) { + $column->setAttribute('val',(string) $filterRule["val"]); + } + if (isset($filterRule["maxVal"])) { + $column->setAttribute('maxVal',(string) $filterRule["maxVal"]); + } + } + } + // Check for dynamic filters + if ($filterColumn->top10) { + $column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER); + // We should only ever have one top10 filter + foreach ($filterColumn->top10 as $filterRule) { + $column->createRule()->setRule( + (((isset($filterRule["percent"])) && ($filterRule["percent"] == 1)) + ? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT + : PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE + ), + (string) $filterRule["val"], + (((isset($filterRule["top"])) && ($filterRule["top"] == 1)) + ? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP + : PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM + ) + ) + ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_TOPTENFILTER); + } + } + } } } @@ -1234,7 +1239,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (!$this->_readDataOnly) { // Locate hyperlink relations if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { - $relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") , 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsWorksheet = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); foreach ($relsWorksheet->Relationship as $ele) { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink") { $hyperlinks[(string)$ele["Id"]] = (string)$ele["Target"]; @@ -1275,7 +1280,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (!$this->_readDataOnly) { // Locate comment relations if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { - $relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") , 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsWorksheet = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); foreach ($relsWorksheet->Relationship as $ele) { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments") { $comments[(string)$ele["Id"]] = (string)$ele["Target"]; @@ -1290,7 +1295,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE foreach ($comments as $relName => $relPath) { // Load comments file $relPath = PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath); - $commentsFile = simplexml_load_string($this->_getFromZipArchive($zip, $relPath) , 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $commentsFile = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, $relPath)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); // Utility variables $authors = array(); @@ -1302,7 +1307,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // Loop through contents foreach ($commentsFile->commentList->comment as $comment) { - $docSheet->getComment( (string)$comment['ref'] )->setAuthor( $authors[(string)$comment['authorId']] ); + if(!empty($comment['authorId'])) + $docSheet->getComment( (string)$comment['ref'] )->setAuthor( $authors[(string)$comment['authorId']] ); $docSheet->getComment( (string)$comment['ref'] )->setText( $this->_parseRichText($comment->text) ); } } @@ -1311,7 +1317,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE foreach ($vmlComments as $relName => $relPath) { // Load VML comments file $relPath = PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath); - $vmlCommentsFile = simplexml_load_string( $this->_getFromZipArchive($zip, $relPath) , 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $vmlCommentsFile = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, $relPath)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); $shapes = $vmlCommentsFile->xpath('//v:shape'); @@ -1362,7 +1368,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // Header/footer images if ($xmlSheet && $xmlSheet->legacyDrawingHF && !$this->_readDataOnly) { if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { - $relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") , 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsWorksheet = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $vmlRelationship = ''; foreach ($relsWorksheet->Relationship as $ele) { @@ -1373,7 +1379,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if ($vmlRelationship != '') { // Fetch linked images - $relsVML = simplexml_load_string($this->_getFromZipArchive($zip, dirname($vmlRelationship) . '/_rels/' . basename($vmlRelationship) . '.rels' ), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsVML = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname($vmlRelationship) . '/_rels/' . basename($vmlRelationship) . '.rels')), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $drawings = array(); foreach ($relsVML->Relationship as $ele) { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") { @@ -1382,7 +1388,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } // Fetch VML document - $vmlDrawing = simplexml_load_string($this->_getFromZipArchive($zip, $vmlRelationship), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $vmlDrawing = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, $vmlRelationship)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $vmlDrawing->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); $hfImages = array(); @@ -1421,7 +1427,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // TODO: Autoshapes from twoCellAnchors! if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { - $relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") , 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsWorksheet = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $drawings = array(); foreach ($relsWorksheet->Relationship as $ele) { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing") { @@ -1431,7 +1437,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if ($xmlSheet->drawing && !$this->_readDataOnly) { foreach ($xmlSheet->drawing as $drawing) { $fileDrawing = $drawings[(string) self::array_item($drawing->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")]; - $relsDrawing = simplexml_load_string($this->_getFromZipArchive($zip, dirname($fileDrawing) . "/_rels/" . basename($fileDrawing) . ".rels") , 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); + $relsDrawing = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname($fileDrawing) . "/_rels/" . basename($fileDrawing) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $images = array(); if ($relsDrawing && $relsDrawing->Relationship) { @@ -1447,7 +1453,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } } } - $xmlDrawing = simplexml_load_string($this->_getFromZipArchive($zip, $fileDrawing), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions())->children("http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"); + $xmlDrawing = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, $fileDrawing)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions())->children("http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"); if ($xmlDrawing->oneCellAnchor) { foreach ($xmlDrawing->oneCellAnchor as $oneCellAnchor) { @@ -1504,10 +1510,9 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff)); $objDrawing->setResizeProportional(false); - $objDrawing->setWidth(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cx"))); - $objDrawing->setHeight(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cy"))); - if ($xfrm) { + $objDrawing->setWidth(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cx"))); + $objDrawing->setHeight(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cy"))); $objDrawing->setRotation(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($xfrm->attributes(), "rot"))); } if ($outerShdw) { @@ -1573,7 +1578,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE case '_xlnm._FilterDatabase': if ((string)$definedName['hidden'] !== '1') { - $docSheet->getAutoFilter()->setRange($extractedRange); + $extractedRange = explode(',', $extractedRange); + foreach ($extractedRange as $range) { + $autoFilterRange = $range; + if (strpos($autoFilterRange, ':') !== false) { + $docSheet->getAutoFilter()->setRange($autoFilterRange); + } + } } break; @@ -1711,13 +1722,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (!$this->_readDataOnly) { - $contentTypes = simplexml_load_string($this->_getFromZipArchive($zip, "[Content_Types].xml"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $contentTypes = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "[Content_Types].xml")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); foreach ($contentTypes->Override as $contentType) { switch ($contentType["ContentType"]) { case "application/vnd.openxmlformats-officedocument.drawingml.chart+xml": if ($this->_includeCharts) { $chartEntryRef = ltrim($contentType['PartName'],'/'); - $chartElements = simplexml_load_string($this->_getFromZipArchive($zip, $chartEntryRef), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $chartElements = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, $chartEntryRef)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $objChart = PHPExcel_Reader_Excel2007_Chart::readChart($chartElements,basename($chartEntryRef,'.xml')); // echo 'Chart ',$chartEntryRef,'
'; @@ -1878,6 +1889,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $docStyle->getAlignment()->setWrapText(self::boolean((string) $style->alignment["wrapText"])); $docStyle->getAlignment()->setShrinkToFit(self::boolean((string) $style->alignment["shrinkToFit"])); $docStyle->getAlignment()->setIndent( intval((string)$style->alignment["indent"]) > 0 ? intval((string)$style->alignment["indent"]) : 0 ); + $docStyle->getAlignment()->setReadorder( intval((string)$style->alignment["readingOrder"]) > 0 ? intval((string)$style->alignment["readingOrder"]) : 0 ); } // protection @@ -1922,6 +1934,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (isset($is->t)) { $value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $is->t ) ); } else { + if(is_object($is->r)) { foreach ($is->r as $run) { if (!isset($run->rPr)) { $objText = $value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $run->t ) ); @@ -1973,6 +1986,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } } } + } } return $value; @@ -1984,14 +1998,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $nameCustomUI = basename($customUITarget); // get the xml file (ribbon) $localRibbon = $this->_getFromZipArchive($zip, $customUITarget); - $customUIImagesNames = array(); + $customUIImagesNames = array(); $customUIImagesBinaries = array(); // something like customUI/_rels/customUI.xml.rels $pathRels = $baseDir . '/_rels/' . $nameCustomUI . '.rels'; $dataRels = $this->_getFromZipArchive($zip, $pathRels); if ($dataRels) { // exists and not empty if the ribbon have some pictures (other than internal MSO) - $UIRels = simplexml_load_string($dataRels, 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $UIRels = simplexml_load_string($this->securityScan($dataRels), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); if ($UIRels) { // we need to save id and target to avoid parsing customUI.xml and "guess" if it's a pseudo callback who load the image foreach ($UIRels->Relationship as $ele) { diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php index 5c957e41674..2de1852f68c 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php @@ -1089,6 +1089,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce } } } + $this->_data = null; return $this->_phpExcel; } @@ -4561,6 +4562,9 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $offset += 4; // offset: var; size: $us; character array of the URL, no Unicode string header, always 16-bit characters, zero-terminated $url = self::_encodeUTF16(substr($recordData, $offset, $us - 2), false); + $nullOffset = strpos($url, 0x00); + if ($nullOffset) + $url = substr($url,0,$nullOffset); $url .= $hasText ? '#' : ''; $offset += $us; break; diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Gnumeric.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Gnumeric.php index d8121495d12..584ded2879b 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Gnumeric.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/Gnumeric.php @@ -116,8 +116,8 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx } $xml = new XMLReader(); - $xml->open( - 'compress.zlib://'.realpath($pFilename), null, PHPExcel_Settings::getLibXmlLoaderOptions() + $xml->xml( + $this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions() ); $xml->setParserProperty(2,true); @@ -150,8 +150,8 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx } $xml = new XMLReader(); - $xml->open( - 'compress.zlib://'.realpath($pFilename), null, PHPExcel_Settings::getLibXmlLoaderOptions() + $xml->xml( + $this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions() ); $xml->setParserProperty(2,true); @@ -243,7 +243,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx // echo htmlentities($gFileData,ENT_QUOTES,'UTF-8'); // echo '
'; // - $xml = simplexml_load_string($gFileData, 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $xml = simplexml_load_string($this->securityScan($gFileData), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $namespacesMeta = $xml->getNamespaces(true); // var_dump($namespacesMeta); diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/HTML.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/HTML.php index 5b32c92234f..26cc598c159 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/HTML.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Reader/HTML.php @@ -1,4 +1,5 @@ array( 'font' => array( 'bold' => true, - 'size' => 24, - ), - ), // Bold, 24pt - 'h2' => array( 'font' => array( 'bold' => true, - 'size' => 18, - ), - ), // Bold, 18pt - 'h3' => array( 'font' => array( 'bold' => true, - 'size' => 13.5, - ), - ), // Bold, 13.5pt - 'h4' => array( 'font' => array( 'bold' => true, - 'size' => 12, - ), - ), // Bold, 12pt - 'h5' => array( 'font' => array( 'bold' => true, - 'size' => 10, - ), - ), // Bold, 10pt - 'h6' => array( 'font' => array( 'bold' => true, - 'size' => 7.5, - ), - ), // Bold, 7.5pt - 'a' => array( 'font' => array( 'underline' => true, - 'color' => array( 'argb' => PHPExcel_Style_Color::COLOR_BLUE, - ), - ), - ), // Blue underlined - 'hr' => array( 'borders' => array( 'bottom' => array( 'style' => PHPExcel_Style_Border::BORDER_THIN, - 'color' => array( PHPExcel_Style_Color::COLOR_BLACK, - ), - ), - ), - ), // Bottom border - ); + /** + * Sheet index to read + * + * @var int + */ + protected $_sheetIndex = 0; + /** + * Formats + * + * @var array + */ + protected $_formats = array( + 'h1' => array('font' => array('bold' => true, + 'size' => 24, + ), + ), // Bold, 24pt + 'h2' => array('font' => array('bold' => true, + 'size' => 18, + ), + ), // Bold, 18pt + 'h3' => array('font' => array('bold' => true, + 'size' => 13.5, + ), + ), // Bold, 13.5pt + 'h4' => array('font' => array('bold' => true, + 'size' => 12, + ), + ), // Bold, 12pt + 'h5' => array('font' => array('bold' => true, + 'size' => 10, + ), + ), // Bold, 10pt + 'h6' => array('font' => array('bold' => true, + 'size' => 7.5, + ), + ), // Bold, 7.5pt + 'a' => array('font' => array('underline' => true, + 'color' => array('argb' => PHPExcel_Style_Color::COLOR_BLUE, + ), + ), + ), // Blue underlined + 'hr' => array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN, + 'color' => array(\PHPExcel_Style_Color::COLOR_BLACK, + ), + ), + ), + ), // Bottom border + ); - /** - * Create a new PHPExcel_Reader_HTML - */ - public function __construct() { - $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); - } + protected $rowspan = array(); - /** - * Validate that the current file is an HTML file - * - * @return boolean - */ - protected function _isValidFormat() - { - // Reading 2048 bytes should be enough to validate that the format is HTML - $data = fread($this->_fileHandle, 2048); - if ((strpos($data, '<') !== FALSE) && - (strlen($data) !== strlen(strip_tags($data)))) { - return TRUE; - } + /** + * Create a new PHPExcel_Reader_HTML + */ + public function __construct() + { + $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); + } - return FALSE; - } + /** + * Validate that the current file is an HTML file + * + * @return boolean + */ + protected function _isValidFormat() + { + // Reading 2048 bytes should be enough to validate that the format is HTML + $data = fread($this->_fileHandle, 2048); + if ((strpos($data, '<') !== FALSE) && + (strlen($data) !== strlen(strip_tags($data)))) { + return TRUE; + } - /** - * Loads PHPExcel from file - * - * @param string $pFilename - * @return PHPExcel - * @throws PHPExcel_Reader_Exception - */ - public function load($pFilename) - { - // Create new PHPExcel - $objPHPExcel = new PHPExcel(); + return FALSE; + } - // Load into this instance - return $this->loadIntoExisting($pFilename, $objPHPExcel); - } + /** + * Loads PHPExcel from file + * + * @param string $pFilename + * @return PHPExcel + * @throws PHPExcel_Reader_Exception + */ + public function load($pFilename) + { + // Create new PHPExcel + $objPHPExcel = new PHPExcel(); - /** - * Set input encoding - * - * @param string $pValue Input encoding - */ - public function setInputEncoding($pValue = 'ANSI') - { - $this->_inputEncoding = $pValue; - return $this; - } + // Load into this instance + return $this->loadIntoExisting($pFilename, $objPHPExcel); + } - /** - * Get input encoding - * - * @return string - */ - public function getInputEncoding() - { - return $this->_inputEncoding; - } + /** + * Set input encoding + * + * @param string $pValue Input encoding + */ + public function setInputEncoding($pValue = 'ANSI') + { + $this->_inputEncoding = $pValue; - // Data Array used for testing only, should write to PHPExcel object on completion of tests - private $_dataArray = array(); + return $this; + } - private $_tableLevel = 0; - private $_nestedColumn = array('A'); + /** + * Get input encoding + * + * @return string + */ + public function getInputEncoding() + { + return $this->_inputEncoding; + } - private function _setTableStartColumn($column) { - if ($this->_tableLevel == 0) - $column = 'A'; - ++$this->_tableLevel; - $this->_nestedColumn[$this->_tableLevel] = $column; + // Data Array used for testing only, should write to PHPExcel object on completion of tests + protected $_dataArray = array(); + protected $_tableLevel = 0; + protected $_nestedColumn = array('A'); - return $this->_nestedColumn[$this->_tableLevel]; - } + protected function _setTableStartColumn($column) + { + if ($this->_tableLevel == 0) + $column = 'A'; + ++$this->_tableLevel; + $this->_nestedColumn[$this->_tableLevel] = $column; - private function _getTableStartColumn() { - return $this->_nestedColumn[$this->_tableLevel]; - } + return $this->_nestedColumn[$this->_tableLevel]; + } - private function _releaseTableStartColumn() { - --$this->_tableLevel; - return array_pop($this->_nestedColumn); - } + protected function _getTableStartColumn() + { + return $this->_nestedColumn[$this->_tableLevel]; + } - private function _flushCell($sheet,$column,$row,&$cellContent) { - if (is_string($cellContent)) { - // Simple String content - if (trim($cellContent) > '') { - // Only actually write it if there's content in the string + protected function _releaseTableStartColumn() + { + --$this->_tableLevel; + + return array_pop($this->_nestedColumn); + } + + protected function _flushCell($sheet, $column, $row, &$cellContent) + { + if (is_string($cellContent)) { + // Simple String content + if (trim($cellContent) > '') { + // Only actually write it if there's content in the string // echo 'FLUSH CELL: ' , $column , $row , ' => ' , $cellContent , '
'; - // Write to worksheet to be done here... - // ... we return the cell so we can mess about with styles more easily - $cell = $sheet->setCellValue($column.$row,$cellContent,true); - $this->_dataArray[$row][$column] = $cellContent; - } - } else { - // We have a Rich Text run - // TODO - $this->_dataArray[$row][$column] = 'RICH TEXT: ' . $cellContent; - } - $cellContent = (string) ''; - } + // Write to worksheet to be done here... + // ... we return the cell so we can mess about with styles more easily + $sheet->setCellValue($column . $row, $cellContent, true); + $this->_dataArray[$row][$column] = $cellContent; + } + } else { + // We have a Rich Text run + // TODO + $this->_dataArray[$row][$column] = 'RICH TEXT: ' . $cellContent; + } + $cellContent = (string) ''; + } - private function _processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent){ - foreach($element->childNodes as $child){ - if ($child instanceof DOMText) { - $domText = preg_replace('/\s+/',' ',trim($child->nodeValue)); - if (is_string($cellContent)) { - // simply append the text if the cell content is a plain text string - $cellContent .= $domText; - } else { - // but if we have a rich text run instead, we need to append it correctly - // TODO - } - } elseif($child instanceof DOMElement) { + protected function _processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent, $format = null) + { + foreach ($element->childNodes as $child) { + if ($child instanceof DOMText) { + $domText = preg_replace('/\s+/u', ' ', trim($child->nodeValue)); + if (is_string($cellContent)) { + // simply append the text if the cell content is a plain text string + $cellContent .= $domText; + } else { + // but if we have a rich text run instead, we need to append it correctly + // TODO + } + } elseif ($child instanceof DOMElement) { // echo 'DOM ELEMENT: ' , strtoupper($child->nodeName) , '
'; - $attributeArray = array(); - foreach($child->attributes as $attribute) { + $attributeArray = array(); + foreach ($child->attributes as $attribute) { // echo 'ATTRIBUTE: ' , $attribute->name , ' => ' , $attribute->value , '
'; - $attributeArray[$attribute->name] = $attribute->value; - } + $attributeArray[$attribute->name] = $attribute->value; + } - switch($child->nodeName) { - case 'meta' : - foreach($attributeArray as $attributeName => $attributeValue) { - switch($attributeName) { - case 'content': - // TODO - // Extract character set, so we can convert to UTF-8 if required - break; - } - } - $this->_processDomElement($child,$sheet,$row,$column,$cellContent); - break; - case 'title' : - $this->_processDomElement($child,$sheet,$row,$column,$cellContent); - $sheet->setTitle($cellContent); - $cellContent = ''; - break; - case 'span' : - case 'div' : - case 'font' : - case 'i' : - case 'em' : - case 'strong': - case 'b' : + switch ($child->nodeName) { + case 'meta' : + foreach ($attributeArray as $attributeName => $attributeValue) { + switch ($attributeName) { + case 'content': + // TODO + // Extract character set, so we can convert to UTF-8 if required + break; + } + } + $this->_processDomElement($child, $sheet, $row, $column, $cellContent); + break; + case 'title' : + $this->_processDomElement($child, $sheet, $row, $column, $cellContent); + $sheet->setTitle($cellContent); + $cellContent = ''; + break; + case 'span' : + case 'div' : + case 'font' : + case 'i' : + case 'em' : + case 'strong': + case 'b' : // echo 'STYLING, SPAN OR DIV
'; - if ($cellContent > '') - $cellContent .= ' '; - $this->_processDomElement($child,$sheet,$row,$column,$cellContent); - if ($cellContent > '') - $cellContent .= ' '; + if ($cellContent > '') + $cellContent .= ' '; + $this->_processDomElement($child, $sheet, $row, $column, $cellContent); + if ($cellContent > '') + $cellContent .= ' '; // echo 'END OF STYLING, SPAN OR DIV
'; - break; - case 'hr' : - $this->_flushCell($sheet,$column,$row,$cellContent); - ++$row; - if (isset($this->_formats[$child->nodeName])) { - $sheet->getStyle($column.$row)->applyFromArray($this->_formats[$child->nodeName]); - } else { - $cellContent = '----------'; - $this->_flushCell($sheet,$column,$row,$cellContent); - } - ++$row; - case 'br' : - if ($this->_tableLevel > 0) { - // If we're inside a table, replace with a \n - $cellContent .= "\n"; - } else { - // Otherwise flush our existing content and move the row cursor on - $this->_flushCell($sheet,$column,$row,$cellContent); - ++$row; - } + break; + case 'hr' : + $this->_flushCell($sheet, $column, $row, $cellContent); + ++$row; + if (isset($this->_formats[$child->nodeName])) { + $sheet->getStyle($column . $row)->applyFromArray($this->_formats[$child->nodeName]); + } else { + $cellContent = '----------'; + $this->_flushCell($sheet, $column, $row, $cellContent); + } + ++$row; + case 'br' : + if ($this->_tableLevel > 0) { + // If we're inside a table, replace with a \n + $cellContent .= "\n"; + } else { + // Otherwise flush our existing content and move the row cursor on + $this->_flushCell($sheet, $column, $row, $cellContent); + ++$row; + } // echo 'HARD LINE BREAK: ' , '
'; - break; - case 'a' : + break; + case 'a' : // echo 'START OF HYPERLINK: ' , '
'; - foreach($attributeArray as $attributeName => $attributeValue) { - switch($attributeName) { - case 'href': + foreach ($attributeArray as $attributeName => $attributeValue) { + switch ($attributeName) { + case 'href': // echo 'Link to ' , $attributeValue , '
'; - $sheet->getCell($column.$row)->getHyperlink()->setUrl($attributeValue); - if (isset($this->_formats[$child->nodeName])) { - $sheet->getStyle($column.$row)->applyFromArray($this->_formats[$child->nodeName]); - } - break; - } - } - $cellContent .= ' '; - $this->_processDomElement($child,$sheet,$row,$column,$cellContent); + $sheet->getCell($column . $row)->getHyperlink()->setUrl($attributeValue); + if (isset($this->_formats[$child->nodeName])) { + $sheet->getStyle($column . $row)->applyFromArray($this->_formats[$child->nodeName]); + } + break; + } + } + $cellContent .= ' '; + $this->_processDomElement($child, $sheet, $row, $column, $cellContent); // echo 'END OF HYPERLINK:' , '
'; - break; - case 'h1' : - case 'h2' : - case 'h3' : - case 'h4' : - case 'h5' : - case 'h6' : - case 'ol' : - case 'ul' : - case 'p' : - if ($this->_tableLevel > 0) { - // If we're inside a table, replace with a \n - $cellContent .= "\n"; + break; + case 'h1' : + case 'h2' : + case 'h3' : + case 'h4' : + case 'h5' : + case 'h6' : + case 'ol' : + case 'ul' : + case 'p' : + if ($this->_tableLevel > 0) { + // If we're inside a table, replace with a \n + $cellContent .= "\n"; // echo 'LIST ENTRY: ' , '
'; - $this->_processDomElement($child,$sheet,$row,$column,$cellContent); + $this->_processDomElement($child, $sheet, $row, $column, $cellContent); // echo 'END OF LIST ENTRY:' , '
'; - } else { - if ($cellContent > '') { - $this->_flushCell($sheet,$column,$row,$cellContent); - $row += 2; - } + } else { + if ($cellContent > '') { + $this->_flushCell($sheet, $column, $row, $cellContent); + $row++; + } // echo 'START OF PARAGRAPH: ' , '
'; - $this->_processDomElement($child,$sheet,$row,$column,$cellContent); + $this->_processDomElement($child, $sheet, $row, $column, $cellContent); // echo 'END OF PARAGRAPH:' , '
'; - $this->_flushCell($sheet,$column,$row,$cellContent); + $this->_flushCell($sheet, $column, $row, $cellContent); - if (isset($this->_formats[$child->nodeName])) { - $sheet->getStyle($column.$row)->applyFromArray($this->_formats[$child->nodeName]); - } + if (isset($this->_formats[$child->nodeName])) { + $sheet->getStyle($column . $row)->applyFromArray($this->_formats[$child->nodeName]); + } - $row += 2; - $column = 'A'; - } - break; - case 'li' : - if ($this->_tableLevel > 0) { - // If we're inside a table, replace with a \n - $cellContent .= "\n"; + $row++; + $column = 'A'; + } + break; + case 'li' : + if ($this->_tableLevel > 0) { + // If we're inside a table, replace with a \n + $cellContent .= "\n"; // echo 'LIST ENTRY: ' , '
'; - $this->_processDomElement($child,$sheet,$row,$column,$cellContent); + $this->_processDomElement($child, $sheet, $row, $column, $cellContent); // echo 'END OF LIST ENTRY:' , '
'; - } else { - if ($cellContent > '') { - $this->_flushCell($sheet,$column,$row,$cellContent); - } - ++$row; + } else { + if ($cellContent > '') { + $this->_flushCell($sheet, $column, $row, $cellContent); + } + ++$row; // echo 'LIST ENTRY: ' , '
'; - $this->_processDomElement($child,$sheet,$row,$column,$cellContent); + $this->_processDomElement($child, $sheet, $row, $column, $cellContent); // echo 'END OF LIST ENTRY:' , '
'; - $this->_flushCell($sheet,$column,$row,$cellContent); - $column = 'A'; - } - break; - case 'table' : - $this->_flushCell($sheet,$column,$row,$cellContent); - $column = $this->_setTableStartColumn($column); + $this->_flushCell($sheet, $column, $row, $cellContent); + $column = 'A'; + } + break; + case 'table' : + $this->_flushCell($sheet, $column, $row, $cellContent); + $column = $this->_setTableStartColumn($column); // echo 'START OF TABLE LEVEL ' , $this->_tableLevel , '
'; - if ($this->_tableLevel > 1) - --$row; - $this->_processDomElement($child,$sheet,$row,$column,$cellContent); + if ($this->_tableLevel > 1) + --$row; + $this->_processDomElement($child, $sheet, $row, $column, $cellContent); // echo 'END OF TABLE LEVEL ' , $this->_tableLevel , '
'; - $column = $this->_releaseTableStartColumn(); - if ($this->_tableLevel > 1) { - ++$column; - } else { - ++$row; - } - break; - case 'thead' : - case 'tbody' : - $this->_processDomElement($child,$sheet,$row,$column,$cellContent); - break; - case 'tr' : - ++$row; - $column = $this->_getTableStartColumn(); - $cellContent = ''; + $column = $this->_releaseTableStartColumn(); + if ($this->_tableLevel > 1) { + ++$column; + } else { + ++$row; + } + break; + case 'thead' : + case 'tbody' : + $this->_processDomElement($child, $sheet, $row, $column, $cellContent); + break; + case 'tr' : + $column = $this->_getTableStartColumn(); + $cellContent = ''; // echo 'START OF TABLE ' , $this->_tableLevel , ' ROW
'; - $this->_processDomElement($child,$sheet,$row,$column,$cellContent); + $this->_processDomElement($child, $sheet, $row, $column, $cellContent); + ++$row; // echo 'END OF TABLE ' , $this->_tableLevel , ' ROW
'; - break; - case 'th' : - case 'td' : + break; + case 'th' : + case 'td' : // echo 'START OF TABLE ' , $this->_tableLevel , ' CELL
'; - $this->_processDomElement($child,$sheet,$row,$column,$cellContent); + $this->_processDomElement($child, $sheet, $row, $column, $cellContent); // echo 'END OF TABLE ' , $this->_tableLevel , ' CELL
'; - $this->_flushCell($sheet,$column,$row,$cellContent); - ++$column; - break; - case 'body' : - $row = 1; - $column = 'A'; - $content = ''; - $this->_tableLevel = 0; - $this->_processDomElement($child,$sheet,$row,$column,$cellContent); - break; - default: - $this->_processDomElement($child,$sheet,$row,$column,$cellContent); - } - } - } - } - /** - * Loads PHPExcel from file into PHPExcel instance - * - * @param string $pFilename - * @param PHPExcel $objPHPExcel - * @return PHPExcel - * @throws PHPExcel_Reader_Exception - */ - public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) - { - // Open file to validate - $this->_openFile($pFilename); - if (!$this->_isValidFormat()) { - fclose ($this->_fileHandle); - throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid HTML file."); - } - // Close after validating - fclose ($this->_fileHandle); + while (isset($this->rowspan[$column . $row])) { + ++$column; + } - // Create new PHPExcel - while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) { - $objPHPExcel->createSheet(); - } - $objPHPExcel->setActiveSheetIndex( $this->_sheetIndex ); + $this->_flushCell($sheet, $column, $row, $cellContent); - // Create a new DOM object - $dom = new domDocument; - // Reload the HTML file into the DOM object - $loaded = $dom->loadHTMLFile($pFilename, PHPExcel_Settings::getLibXmlLoaderOptions()); - if ($loaded === FALSE) { - throw new PHPExcel_Reader_Exception('Failed to load ',$pFilename,' as a DOM Document'); - } +// if (isset($attributeArray['style']) && !empty($attributeArray['style'])) { +// $styleAry = $this->getPhpExcelStyleArray($attributeArray['style']); +// +// if (!empty($styleAry)) { +// $sheet->getStyle($column . $row)->applyFromArray($styleAry); +// } +// } - // Discard white space - $dom->preserveWhiteSpace = false; + if (isset($attributeArray['rowspan']) && isset($attributeArray['colspan'])) { + //create merging rowspan and colspan + $columnTo = $column; + for ($i = 0; $i < $attributeArray['colspan'] - 1; $i++) { + ++$columnTo; + } + $range = $column . $row . ':' . $columnTo . ($row + $attributeArray['rowspan'] - 1); + foreach (\PHPExcel_Cell::extractAllCellReferencesInRange($range) as $value) { + $this->rowspan[$value] = true; + } + $sheet->mergeCells($range); + $column = $columnTo; + } elseif (isset($attributeArray['rowspan'])) { + //create merging rowspan + $range = $column . $row . ':' . $column . ($row + $attributeArray['rowspan'] - 1); + foreach (\PHPExcel_Cell::extractAllCellReferencesInRange($range) as $value) { + $this->rowspan[$value] = true; + } + $sheet->mergeCells($range); + } elseif (isset($attributeArray['colspan'])) { + //create merging colspan + $columnTo = $column; + for ($i = 0; $i < $attributeArray['colspan'] - 1; $i++) { + ++$columnTo; + } + $sheet->mergeCells($column . $row . ':' . $columnTo . $row); + $column = $columnTo; + } + ++$column; + break; + case 'body' : + $row = 1; + $column = 'A'; + $content = ''; + $this->_tableLevel = 0; + $this->_processDomElement($child, $sheet, $row, $column, $cellContent); + break; + default: + $this->_processDomElement($child, $sheet, $row, $column, $cellContent); + } + } + } + } + /** + * Loads PHPExcel from file into PHPExcel instance + * + * @param string $pFilename + * @param PHPExcel $objPHPExcel + * @return PHPExcel + * @throws PHPExcel_Reader_Exception + */ + public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) + { + // Open file to validate + $this->_openFile($pFilename); + if (!$this->_isValidFormat()) { + fclose($this->_fileHandle); + throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid HTML file."); + } + // Close after validating + fclose($this->_fileHandle); - $row = 0; - $column = 'A'; - $content = ''; - $this->_processDomElement($dom,$objPHPExcel->getActiveSheet(),$row,$column,$content); + // Create new PHPExcel + while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) { + $objPHPExcel->createSheet(); + } + $objPHPExcel->setActiveSheetIndex($this->_sheetIndex); -// echo '
'; -// var_dump($this->_dataArray); + // Create a new DOM object + $dom = new domDocument; + // Reload the HTML file into the DOM object + $loaded = $dom->loadHTML($this->securityScanFile($pFilename)); + if ($loaded === FALSE) { + throw new PHPExcel_Reader_Exception('Failed to load ', $pFilename, ' as a DOM Document'); + } + + // Discard white space + $dom->preserveWhiteSpace = false; + + $row = 0; + $column = 'A'; + $content = ''; + $this->_processDomElement($dom, $objPHPExcel->getActiveSheet(), $row, $column, $content); // Return - return $objPHPExcel; - } + return $objPHPExcel; + } + + /** + * Get sheet index + * + * @return int + */ + public function getSheetIndex() + { + return $this->_sheetIndex; + } + + /** + * Set sheet index + * + * @param int $pValue Sheet index + * @return PHPExcel_Reader_HTML + */ + public function setSheetIndex($pValue = 0) + { + $this->_sheetIndex = $pValue; + + return $this; + } /** - * Get sheet index + * Scan theXML for use of _sheetIndex; - } - - /** - * Set sheet index - * - * @param int $pValue Sheet index - * @return PHPExcel_Reader_HTML - */ - public function setSheetIndex($pValue = 0) { - $this->_sheetIndex = $pValue; - return $this; - } + public function securityScan($xml) + { + $pattern = '/\\0?' . implode('\\0?', str_split('getFromName($stat['name']); } elseif($stat = $zip->statName('META-INF/manifest.xml')) { - $xml = simplexml_load_string($zip->getFromName('META-INF/manifest.xml'), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $xml = simplexml_load_string($this->securityScan($zip->getFromName('META-INF/manifest.xml')), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $namespacesContent = $xml->getNamespaces(true); if (isset($namespacesContent['manifest'])) { $manifest = $xml->children($namespacesContent['manifest']); @@ -136,7 +136,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce $worksheetNames = array(); $xml = new XMLReader(); - $res = $xml->open('zip://'.realpath($pFilename).'#content.xml', null, PHPExcel_Settings::getLibXmlLoaderOptions()); + $res = $xml->xml($this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'), null, PHPExcel_Settings::getLibXmlLoaderOptions()); $xml->setParserProperty(2,true); // Step into the first level of content of the XML @@ -188,7 +188,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce } $xml = new XMLReader(); - $res = $xml->open('zip://'.realpath($pFilename).'#content.xml', null, PHPExcel_Settings::getLibXmlLoaderOptions()); + $res = $xml->xml($this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'), null, PHPExcel_Settings::getLibXmlLoaderOptions()); $xml->setParserProperty(2,true); // Step into the first level of content of the XML @@ -345,7 +345,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce } // echo '

Meta Information

'; - $xml = simplexml_load_string($zip->getFromName("meta.xml"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $xml = simplexml_load_string($this->securityScan($zip->getFromName("meta.xml")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $namespacesMeta = $xml->getNamespaces(true); // echo '
';
 //		print_r($namespacesMeta);
@@ -431,7 +431,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
 
 
 //		echo '

Workbook Content

'; - $xml = simplexml_load_string($zip->getFromName("content.xml"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); + $xml = simplexml_load_string($this->securityScan($zip->getFromName("content.xml")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $namespacesContent = $xml->getNamespaces(true); // echo '
';
 //		print_r($namespacesContent);
@@ -515,9 +515,13 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
 									$annotationText = $cellDataOffice->annotation->children($namespacesContent['text']);
 									$textArray = array();
 									foreach($annotationText as $t) {
-										foreach($t->span as $text) {
-											$textArray[] = (string)$text;
-										}
+									    if (isset($t->span)) {
+    										foreach($t->span as $text) {
+    											$textArray[] = (string)$text;
+    										}
+									    } else {
+									        $textArray[] = (string) $t;
+									    }
 									}
 									$text = implode("\n",$textArray);
 //									echo $text,'
'; diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Settings.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Settings.php index 839231ba02d..c78d9350df7 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Settings.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Settings.php @@ -363,10 +363,12 @@ class PHPExcel_Settings */ public static function setLibXmlLoaderOptions($options = null) { - if (is_null($options)) { + if (is_null($options) && defined(LIBXML_DTDLOAD)) { $options = LIBXML_DTDLOAD | LIBXML_DTDATTR; } - @libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR)); + if (version_compare(PHP_VERSION, '5.2.11') >= 0) { + @libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR)); + } self::$_libXmlLoaderOptions = $options; } // function setLibXmlLoaderOptions @@ -378,10 +380,12 @@ class PHPExcel_Settings */ public static function getLibXmlLoaderOptions() { - if (is_null(self::$_libXmlLoaderOptions)) { + if (is_null(self::$_libXmlLoaderOptions) && defined(LIBXML_DTDLOAD)) { self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR); } - @libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR)); + if (version_compare(PHP_VERSION, '5.2.11') >= 0) { + @libxml_disable_entity_loader(self::$_libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR)); + } return self::$_libXmlLoaderOptions; } // function getLibXmlLoaderOptions } diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/CodePage.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/CodePage.php index d1c4e1a592f..89e2d19cfff 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/CodePage.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/CodePage.php @@ -83,12 +83,16 @@ class PHPExcel_Shared_CodePage case 1258: return 'CP1258'; break; // ANSI Vietnamese case 1361: return 'CP1361'; break; // ANSI Korean (Johab) case 10000: return 'MAC'; break; // Apple Roman + case 10001: return 'CP932'; break; // Macintosh Japanese + case 10002: return 'CP950'; break; // Macintosh Chinese Traditional + case 10003: return 'CP1361'; break; // Macintosh Korean case 10006: return 'MACGREEK'; break; // Macintosh Greek - case 10007: return 'MACCYRILLIC'; break; // Macintosh Cyrillic - case 10008: return 'CP936'; break; // Macintosh - Simplified Chinese (GB 2312) - case 10029: return 'MACCENTRALEUROPE'; break; // Macintosh Central Europe - case 10079: return 'MACICELAND'; break; // Macintosh Icelandic - case 10081: return 'MACTURKISH'; break; // Macintosh Turkish + case 10007: return 'MACCYRILLIC'; break; // Macintosh Cyrillic + case 10008: return 'CP936'; break; // Macintosh - Simplified Chinese (GB 2312) + case 10029: return 'MACCENTRALEUROPE'; break; // Macintosh Central Europe + case 10079: return 'MACICELAND'; break; // Macintosh Icelandic + case 10081: return 'MACTURKISH'; break; // Macintosh Turkish + case 21010: return 'UTF-16LE'; break; // UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE case 32768: return 'MAC'; break; // Apple Roman case 32769: throw new PHPExcel_Exception('Code page 32769 not supported.'); break; // ANSI Latin I (BIFF2-BIFF3) diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/Date.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/Date.php index f253786d6aa..75f367eac5a 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/Date.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/Date.php @@ -155,7 +155,7 @@ class PHPExcel_Shared_Date * Convert a date from Excel to a PHP Date/Time object * * @param integer $dateValue Excel date/time value - * @return integer PHP date/time object + * @return DateTime PHP date/time object */ public static function ExcelToPHPObject($dateValue = 0) { $dateTime = self::ExcelToPHP($dateValue); diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/Font.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/Font.php index 9effd91ec03..8e5b27b8fc1 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/Font.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/Font.php @@ -199,7 +199,6 @@ class PHPExcel_Shared_Font if (!in_array($pValue,self::$_autoSizeMethods)) { return FALSE; } - self::$autoSizeMethod = $pValue; return TRUE; @@ -241,7 +240,7 @@ class PHPExcel_Shared_Font return self::$trueTypeFontPath; } - /** + /** * Calculate an (approximate) OpenXML column width, based on font size and text contained * * @param PHPExcel_Style_Font $font Font object @@ -251,7 +250,6 @@ class PHPExcel_Shared_Font * @return integer Column width */ public static function calculateColumnWidth(PHPExcel_Style_Font $font, $cellText = '', $rotation = 0, PHPExcel_Style_Font $defaultFont = null) { - // If it is rich text, use plain text if ($cellText instanceof PHPExcel_RichText) { $cellText = $cellText->getPlainText(); @@ -260,7 +258,7 @@ class PHPExcel_Shared_Font // Special case if there are one or more newline characters ("\n") if (strpos($cellText, "\n") !== false) { $lineTexts = explode("\n", $cellText); - $lineWitdhs = array(); + $lineWidths = array(); foreach ($lineTexts as $lineText) { $lineWidths[] = self::calculateColumnWidth($font, $lineText, $rotation = 0, $defaultFont); } @@ -268,25 +266,24 @@ class PHPExcel_Shared_Font } // Try to get the exact text width in pixels - try { - // If autosize method is set to 'approx', use approximation - if (self::$autoSizeMethod == self::AUTOSIZE_METHOD_APPROX) { - throw new PHPExcel_Exception('AutoSize method is set to approx'); - } + $approximate = self::$autoSizeMethod == self::AUTOSIZE_METHOD_APPROX; + if (!$approximate) { + $columnWidthAdjust = ceil(self::getTextWidthPixelsExact('n', $font, 0) * 1.07); + try { + // Width of text in pixels excl. padding + // and addition because Excel adds some padding, just use approx width of 'n' glyph + $columnWidth = self::getTextWidthPixelsExact($cellText, $font, $rotation) + $columnWidthAdjust; + } catch (PHPExcel_Exception $e) { + $approximate = true; + } + } - // Width of text in pixels excl. padding - $columnWidth = self::getTextWidthPixelsExact($cellText, $font, $rotation); - - // Excel adds some padding, use 1.07 of the width of an 'n' glyph - $columnWidth += ceil(self::getTextWidthPixelsExact('0', $font, 0) * 1.07); // pixels incl. padding - - } catch (PHPExcel_Exception $e) { + if ($approximate) { + $columnWidthAdjust = self::getTextWidthPixelsApprox('n', $font, 0); // Width of text in pixels excl. padding, approximation - $columnWidth = self::getTextWidthPixelsApprox($cellText, $font, $rotation); - - // Excel adds some padding, just use approx width of 'n' glyph - $columnWidth += self::getTextWidthPixelsApprox('n', $font, 0); - } + // and addition because Excel adds some padding, just use approx width of 'n' glyph + $columnWidth = self::getTextWidthPixelsApprox($cellText, $font, $rotation) + $columnWidthAdjust; + } // Convert from pixel width to column width $columnWidth = PHPExcel_Shared_Drawing::pixelsToCellDimension($columnWidth, $defaultFont); @@ -316,13 +313,13 @@ class PHPExcel_Shared_Font // Get corners positions $lowerLeftCornerX = $textBox[0]; - $lowerLeftCornerY = $textBox[1]; +// $lowerLeftCornerY = $textBox[1]; $lowerRightCornerX = $textBox[2]; - $lowerRightCornerY = $textBox[3]; +// $lowerRightCornerY = $textBox[3]; $upperRightCornerX = $textBox[4]; - $upperRightCornerY = $textBox[5]; +// $upperRightCornerY = $textBox[5]; $upperLeftCornerX = $textBox[6]; - $upperLeftCornerY = $textBox[7]; +// $upperLeftCornerY = $textBox[7]; // Consider the rotation when calculating the width $textWidth = max($lowerRightCornerX - $upperLeftCornerX, $upperRightCornerX - $lowerLeftCornerX); @@ -353,9 +350,11 @@ class PHPExcel_Shared_Font case 'Arial': // value 7 was found via interpolation by inspecting real Excel files with Arial 10 font. - $columnWidth = (int) (7 * PHPExcel_Shared_String::CountCharacters($columnText)); +// $columnWidth = (int) (7 * PHPExcel_Shared_String::CountCharacters($columnText)); + // value 8 was set because of experience in different exports at Arial 10 font. + $columnWidth = (int) (8 * PHPExcel_Shared_String::CountCharacters($columnText)); $columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size - break; + break; case 'Verdana': // value 8 was found via interpolation by inspecting real Excel files with Verdana 10 font. @@ -383,8 +382,7 @@ class PHPExcel_Shared_Font } // pixel width is an integer - $columnWidth = (int) $columnWidth; - return $columnWidth; + return (int) $columnWidth; } /** diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/JAMA/Matrix.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/JAMA/Matrix.php index b893a447a8e..1e7c334ac51 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/JAMA/Matrix.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/JAMA/Matrix.php @@ -1028,7 +1028,7 @@ class PHPExcel_Shared_JAMA_Matrix { $LU = new PHPExcel_Shared_JAMA_LUDecomposition($this); return $LU->solve($B); } else { - $QR = new QRDecomposition($this); + $QR = new PHPExcel_Shared_JAMA_QRDecomposition($this); return $QR->solve($B); } } // function solve() @@ -1054,6 +1054,4 @@ class PHPExcel_Shared_JAMA_Matrix { $L = new PHPExcel_Shared_JAMA_LUDecomposition($this); return $L->det(); } // function det() - - } // class PHPExcel_Shared_JAMA_Matrix diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/OLE/ChainedBlockStream.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/OLE/ChainedBlockStream.php index 5145206e71a..0736fc23248 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/OLE/ChainedBlockStream.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/OLE/ChainedBlockStream.php @@ -161,14 +161,6 @@ class PHPExcel_Shared_OLE_ChainedBlockStream */ public function stream_eof() { -// As we don't support below 5.2 anymore, this is simply redundancy and overhead -// $eof = $this->pos >= strlen($this->data); -// // Workaround for bug in PHP 5.0.x: http://bugs.php.net/27508 -// if (version_compare(PHP_VERSION, '5.0', '>=') && -// version_compare(PHP_VERSION, '5.1', '<')) { -// $eof = !$eof; -// } -// return $eof; return $this->pos >= strlen($this->data); } diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php index e7facc1eaa1..7d1936aa245 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/PCLZip/pclzip.lib.php @@ -5689,6 +5689,3 @@ return $p_path; } // -------------------------------------------------------------------------------- - - -?> diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/String.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/String.php index fc86d537d18..7d6b4192b07 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/String.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/String.php @@ -403,7 +403,7 @@ class PHPExcel_Shared_String * @return boolean */ public static function IsUTF8($value = '') { - return $string === '' || preg_match('/^./su', $string) === 1; + return $value === '' || preg_match('/^./su', $value) === 1; } /** @@ -626,6 +626,41 @@ class PHPExcel_Shared_String return ucwords($pValue); } + public static function mb_is_upper($char) + { + return mb_strtolower($char, "UTF-8") != $char; + } + + public static function mb_str_split($string) + { + # Split at all position not after the start: ^ + # and not before the end: $ + return preg_split('/(?setIndent($pStyles['indent']); } + if (isset($pStyles['readorder'])) { + $this->setReadorder($pStyles['readorder']); + } } } else { throw new PHPExcel_Exception("Invalid style array passed."); @@ -389,6 +404,37 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE return $this; } + /** + * Get read order + * + * @return integer + */ + public function getReadorder() { + if ($this->_isSupervisor) { + return $this->getSharedComponent()->getReadorder(); + } + return $this->_readorder; + } + + /** + * Set read order + * + * @param int $pValue + * @return PHPExcel_Style_Alignment + */ + public function setReadorder($pValue = 0) { + if ($pValue < 0 || $pValue > 2) { + $pValue = 0; + } + if ($this->_isSupervisor) { + $styleArray = $this->getStyleArray(array('readorder' => $pValue)); + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); + } else { + $this->_readorder = $pValue; + } + return $this; + } + /** * Get hash code * @@ -405,6 +451,7 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE . ($this->_wrapText ? 't' : 'f') . ($this->_shrinkToFit ? 't' : 'f') . $this->_indent + . $this->_readorder . __CLASS__ ); } diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Style/NumberFormat.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Style/NumberFormat.php index 0d7d93de279..62ab3e2752c 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Style/NumberFormat.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Style/NumberFormat.php @@ -120,6 +120,7 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P if ($isConditional) { $this->_formatCode = NULL; + $this->_builtInFormatCode = FALSE; } } @@ -497,13 +498,15 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P } } - private static function _complexNumberFormatMask($number, $mask) { + private static function _complexNumberFormatMask($number, $mask, $level = 0) { + $sign = ($number < 0.0); + $number = abs($number); if (strpos($mask,'.') !== false) { $numbers = explode('.', $number . '.0'); $masks = explode('.', $mask . '.0'); - $result1 = self::_complexNumberFormatMask($numbers[0], $masks[0]); - $result2 = strrev(self::_complexNumberFormatMask(strrev($numbers[1]), strrev($masks[1]))); - return $result1 . '.' . $result2; + $result1 = self::_complexNumberFormatMask($numbers[0], $masks[0], 1); + $result2 = strrev(self::_complexNumberFormatMask(strrev($numbers[1]), strrev($masks[1]), 1)); + return (($sign) ? '-' : '') . $result1 . '.' . $result2; } $r = preg_match_all('/0+/', $mask, $result, PREG_OFFSET_CAPTURE); @@ -520,7 +523,7 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P fmod($number, $divisor) ); $number = floor($number / $divisor); - $mask = substr_replace($mask,$blockValue, $offset, $size); + $mask = substr_replace($mask, $blockValue, $offset, $size); } if ($number > 0) { $mask = substr_replace($mask, $number, $offset, 0); @@ -530,7 +533,7 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P $result = $number; } - return $result; + return (($sign) ? '-' : '') . $result; } /** @@ -613,9 +616,12 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P // Some non-number characters are escaped with \, which we don't need $format = preg_replace("/\\\\/", '', $format); +// Handle escaped characters, such as \" to display a literal " or \\ to display a literal \ +// $format = preg_replace('/(?getCell($pCoordinate)->setValue($pValue); + $cell = $this->getCell(strtoupper($pCoordinate))->setValue($pValue); return ($returnCell) ? $cell : $this; } @@ -1123,7 +1123,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable public function setCellValueExplicit($pCoordinate = 'A1', $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING, $returnCell = false) { // Set value - $cell = $this->getCell($pCoordinate)->setValueExplicit($pValue, $pDataType); + $cell = $this->getCell(strtoupper($pCoordinate))->setValueExplicit($pValue, $pDataType); return ($returnCell) ? $cell : $this; } @@ -1152,6 +1152,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable */ public function getCell($pCoordinate = 'A1') { + $pCoordinate = strtoupper($pCoordinate); // Check cell collection if ($this->_cellCollection->isDataSet($pCoordinate)) { return $this->_cellCollection->getCacheData($pCoordinate); @@ -1254,10 +1255,10 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable */ public function cellExists($pCoordinate = 'A1') { - // Worksheet reference? + // Worksheet reference? if (strpos($pCoordinate, '!') !== false) { $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true); - return $this->_parent->getSheetByName($worksheetReference[0])->cellExists($worksheetReference[1]); + return $this->_parent->getSheetByName($worksheetReference[0])->cellExists(strtoupper($worksheetReference[1])); } // Named range? @@ -1405,7 +1406,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable /** * Get style for cell * - * @param string $pCellCoordinate Cell coordinate to get style for + * @param string $pCellCoordinate Cell coordinate (or range) to get style for * @return PHPExcel_Style * @throws PHPExcel_Exception */ @@ -1415,7 +1416,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable $this->_parent->setActiveSheetIndex($this->_parent->getIndex($this)); // set cell coordinate as active - $this->setSelectedCells($pCellCoordinate); + $this->setSelectedCells(strtoupper($pCellCoordinate)); return $this->_parent->getCellXfSupervisor(); } @@ -1428,6 +1429,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable */ public function getConditionalStyles($pCoordinate = 'A1') { + $pCoordinate = strtoupper($pCoordinate); if (!isset($this->_conditionalStylesCollection[$pCoordinate])) { $this->_conditionalStylesCollection[$pCoordinate] = array(); } @@ -1442,7 +1444,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable */ public function conditionalStylesExists($pCoordinate = 'A1') { - if (isset($this->_conditionalStylesCollection[$pCoordinate])) { + if (isset($this->_conditionalStylesCollection[strtoupper($pCoordinate)])) { return true; } return false; @@ -1456,7 +1458,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable */ public function removeConditionalStyles($pCoordinate = 'A1') { - unset($this->_conditionalStylesCollection[$pCoordinate]); + unset($this->_conditionalStylesCollection[strtoupper($pCoordinate)]); return $this; } @@ -1479,7 +1481,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable */ public function setConditionalStyles($pCoordinate = 'A1', $pValue) { - $this->_conditionalStylesCollection[$pCoordinate] = $pValue; + $this->_conditionalStylesCollection[strtoupper($pCoordinate)] = $pValue; return $this; } @@ -1488,10 +1490,18 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable * * @param int $pColumn Numeric column coordinate of the cell * @param int $pRow Numeric row coordinate of the cell + * @param int pColumn2 Numeric column coordinate of the range cell + * @param int pRow2 Numeric row coordinate of the range cell * @return PHPExcel_Style */ - public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1) + public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1, $pColumn2 = null, $pRow2 = null) { + if (!is_null($pColumn2) && !is_null($pRow2)) { + $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow . ':' . + PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2; + return $this->getStyle($cellRange); + } + return $this->getStyle(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); } @@ -1894,6 +1904,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable */ public function setAutoFilter($pValue) { + $pRange = strtoupper($pValue); + if (is_string($pValue)) { $this->_autoFilter->setRange($pValue); } elseif(is_object($pValue) && ($pValue instanceof PHPExcel_Worksheet_AutoFilter)) { @@ -2052,8 +2064,13 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable */ public function removeRow($pRow = 1, $pNumRows = 1) { if ($pRow >= 1) { + $highestRow = $this->getHighestDataRow(); $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); $objReferenceHelper->insertNewBefore('A' . ($pRow + $pNumRows), 0, -$pNumRows, $this); + for($r = 0; $r < $pNumRows; ++$r) { + $this->getCellCacheController()->removeRow($highestRow); + --$highestRow; + } } else { throw new PHPExcel_Exception("Rows to be deleted should at least start from row 1."); } @@ -2063,16 +2080,21 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable /** * Remove a column, updating all possible related data * - * @param int $pColumn Remove starting with this one - * @param int $pNumCols Number of columns to remove + * @param string $pColumn Remove starting with this one + * @param int $pNumCols Number of columns to remove * @throws PHPExcel_Exception * @return PHPExcel_Worksheet */ public function removeColumn($pColumn = 'A', $pNumCols = 1) { if (!is_numeric($pColumn)) { + $highestColumn = $this->getHighestDataColumn(); $pColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($pColumn) - 1 + $pNumCols); $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); $objReferenceHelper->insertNewBefore($pColumn . '1', -$pNumCols, 0, $this); + for($c = 0; $c < $pNumCols; ++$c) { + $this->getCellCacheController()->removeColumn($highestColumn); + $highestColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($highestColumn) - 2); + } } else { throw new PHPExcel_Exception("Column references should not be numeric."); } @@ -2537,11 +2559,25 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable /** * Get row iterator * - * @param integer $startRow The row number at which to start iterating + * @param integer $startRow The row number at which to start iterating + * @param integer $endRow The row number at which to stop iterating + * * @return PHPExcel_Worksheet_RowIterator */ - public function getRowIterator($startRow = 1) { - return new PHPExcel_Worksheet_RowIterator($this,$startRow); + public function getRowIterator($startRow = 1, $endRow = null) { + return new PHPExcel_Worksheet_RowIterator($this, $startRow, $endRow); + } + + /** + * Get column iterator + * + * @param string $startColumn The column address at which to start iterating + * @param string $endColumn The column address at which to stop iterating + * + * @return PHPExcel_Worksheet_ColumnIterator + */ + public function getColumnIterator($startColumn = 'A', $endColumn = null) { + return new PHPExcel_Worksheet_ColumnIterator($this, $startColumn, $endColumn); } /** diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/AutoFilter.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/AutoFilter.php index d0fa8b6df2f..22c3574899c 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/AutoFilter.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/AutoFilter.php @@ -633,7 +633,11 @@ class PHPExcel_Worksheet_AutoFilter ); } else { // Filter on date group values - $arguments = array(); + $arguments = array( + 'date' => array(), + 'time' => array(), + 'dateTime' => array(), + ); foreach($ruleDataSet as $ruleValue) { $date = $time = ''; if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR])) && diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/AutoFilter/Column/Rule.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/AutoFilter/Column/Rule.php index 4a14d7d7d2a..e602646401b 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/AutoFilter/Column/Rule.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/AutoFilter/Column/Rule.php @@ -257,7 +257,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule * * @var string */ - private $_operator = ''; + private $_operator = self::AUTOFILTER_COLUMN_RULE_EQUAL; /** * DateTimeGrouping Group Value diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/BaseDrawing.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/BaseDrawing.php index 0250035ccec..5a760fcad11 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/BaseDrawing.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/BaseDrawing.php @@ -321,7 +321,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable public function setWidth($pValue = 0) { // Resize proportional? if ($this->_resizeProportional && $pValue != 0) { - $ratio = $this->_height / $this->_width; + $ratio = $this->_height / ($this->_width != 0 ? $this->_width : 1); $this->_height = round($ratio * $pValue); } @@ -349,7 +349,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable public function setHeight($pValue = 0) { // Resize proportional? if ($this->_resizeProportional && $pValue != 0) { - $ratio = $this->_width / $this->_height; + $ratio = $this->_width / ($this->_height != 0 ? $this->_height : 1); $this->_width = round($ratio * $pValue); } @@ -373,8 +373,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable * @return PHPExcel_Worksheet_BaseDrawing */ public function setWidthAndHeight($width = 0, $height = 0) { - $xratio = $width / $this->_width; - $yratio = $height / $this->_height; + $xratio = $width / ($this->_width != 0 ? $this->_width : 1); + $yratio = $height / ($this->_height != 0 ? $this->_height : 1); if ($this->_resizeProportional && !($width == 0 || $height == 0)) { if (($xratio * $this->_height) < $height) { $this->_height = ceil($xratio * $this->_height); @@ -383,7 +383,11 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable $this->_width = ceil($yratio * $this->_width); $this->_height = $height; } - } + } else { + $this->_width = $width; + $this->_height = $height; + } + return $this; } diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/CellIterator.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/CellIterator.php index 27cdc94c3a3..239cb4ff1f5 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/CellIterator.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/CellIterator.php @@ -22,7 +22,7 @@ * @package PHPExcel_Worksheet * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version ##VERSION##, ##DATE## + * @version 1.8.0, 2014-03-02 */ @@ -35,47 +35,28 @@ * @package PHPExcel_Worksheet * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Worksheet_CellIterator implements Iterator +abstract class PHPExcel_Worksheet_CellIterator { /** * PHPExcel_Worksheet to iterate * * @var PHPExcel_Worksheet */ - private $_subject; - - /** - * Row index - * - * @var int - */ - private $_rowIndex; + protected $_subject; /** * Current iterator position * - * @var int + * @var mixed */ - private $_position = 0; + protected $_position = null; /** - * Loop only existing cells + * Iterate only existing cells * * @var boolean */ - private $_onlyExistingCells = true; - - /** - * Create a new cell iterator - * - * @param PHPExcel_Worksheet $subject - * @param int $rowIndex - */ - public function __construct(PHPExcel_Worksheet $subject = null, $rowIndex = 1) { - // Set subject and row index - $this->_subject = $subject; - $this->_rowIndex = $rowIndex; - } + protected $_onlyExistingCells = false; /** * Destructor @@ -84,63 +65,6 @@ class PHPExcel_Worksheet_CellIterator implements Iterator unset($this->_subject); } - /** - * Rewind iterator - */ - public function rewind() { - $this->_position = 0; - } - - /** - * Current PHPExcel_Cell - * - * @return PHPExcel_Cell - */ - public function current() { - return $this->_subject->getCellByColumnAndRow($this->_position, $this->_rowIndex); - } - - /** - * Current key - * - * @return int - */ - public function key() { - return $this->_position; - } - - /** - * Next value - */ - public function next() { - ++$this->_position; - } - - /** - * Are there any more PHPExcel_Cell instances available? - * - * @return boolean - */ - public function valid() { - // columnIndexFromString() returns an index based at one, - // treat it as a count when comparing it to the base zero - // position. - $columnCount = PHPExcel_Cell::columnIndexFromString($this->_subject->getHighestColumn()); - - if ($this->_onlyExistingCells) { - // If we aren't looking at an existing cell, either - // because the first column doesn't exist or next() has - // been called onto a nonexistent cell, then loop until we - // find one, or pass the last column. - while ($this->_position < $columnCount && - !$this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex)) { - ++$this->_position; - } - } - - return $this->_position < $columnCount; - } - /** * Get loop only existing cells * @@ -150,12 +74,22 @@ class PHPExcel_Worksheet_CellIterator implements Iterator return $this->_onlyExistingCells; } + /** + * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary + * + * @throws PHPExcel_Exception + */ + abstract protected function adjustForExistingOnlyRange(); + /** * Set the iterator to loop only existing cells * * @param boolean $value + * @throws PHPExcel_Exception */ public function setIterateOnlyExistingCells($value = true) { - $this->_onlyExistingCells = $value; + $this->_onlyExistingCells = (boolean) $value; + + $this->adjustForExistingOnlyRange(); } } diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/Column.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/Column.php new file mode 100644 index 00000000000..94af2135725 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/Column.php @@ -0,0 +1,92 @@ +_parent = $parent; + $this->_columnIndex = $columnIndex; + } + + /** + * Destructor + */ + public function __destruct() { + unset($this->_parent); + } + + /** + * Get column index + * + * @return int + */ + public function getColumnIndex() { + return $this->_columnIndex; + } + + /** + * Get cell iterator + * + * @param integer $startRow The row number at which to start iterating + * @param integer $endRow Optionally, the row number at which to stop iterating + * @return PHPExcel_Worksheet_CellIterator + */ + public function getCellIterator($startRow = 1, $endRow = null) { + return new PHPExcel_Worksheet_ColumnCellIterator($this->_parent, $this->_columnIndex, $startRow, $endRow); + } +} diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/ColumnCellIterator.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/ColumnCellIterator.php new file mode 100644 index 00000000000..a9ef49f00d7 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/ColumnCellIterator.php @@ -0,0 +1,215 @@ +_subject = $subject; + $this->_columnIndex = PHPExcel_Cell::columnIndexFromString($columnIndex) - 1; + $this->resetEnd($endRow); + $this->resetStart($startRow); + } + + /** + * Destructor + */ + public function __destruct() { + unset($this->_subject); + } + + /** + * (Re)Set the start row and the current row pointer + * + * @param integer $startRow The row number at which to start iterating + * @return PHPExcel_Worksheet_ColumnCellIterator + * @throws PHPExcel_Exception + */ + public function resetStart($startRow = 1) { + $this->_startRow = $startRow; + $this->adjustForExistingOnlyRange(); + $this->seek($startRow); + + return $this; + } + + /** + * (Re)Set the end row + * + * @param integer $endRow The row number at which to stop iterating + * @return PHPExcel_Worksheet_ColumnCellIterator + * @throws PHPExcel_Exception + */ + public function resetEnd($endRow = null) { + $this->_endRow = ($endRow) ? $endRow : $this->_subject->getHighestRow(); + $this->adjustForExistingOnlyRange(); + + return $this; + } + + /** + * Set the row pointer to the selected row + * + * @param integer $row The row number to set the current pointer at + * @return PHPExcel_Worksheet_ColumnCellIterator + * @throws PHPExcel_Exception + */ + public function seek($row = 1) { + if (($row < $this->_startRow) || ($row > $this->_endRow)) { + throw new PHPExcel_Exception("Row $row is out of range ({$this->_startRow} - {$this->_endRow})"); + } elseif ($this->_onlyExistingCells && !($this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $row))) { + throw new PHPExcel_Exception('In "IterateOnlyExistingCells" mode and Cell does not exist'); + } + $this->_position = $row; + + return $this; + } + + /** + * Rewind the iterator to the starting row + */ + public function rewind() { + $this->_position = $this->_startRow; + } + + /** + * Return the current cell in this worksheet column + * + * @return PHPExcel_Worksheet_Row + */ + public function current() { + return $this->_subject->getCellByColumnAndRow($this->_columnIndex, $this->_position); + } + + /** + * Return the current iterator key + * + * @return int + */ + public function key() { + return $this->_position; + } + + /** + * Set the iterator to its next value + */ + public function next() { + do { + ++$this->_position; + } while (($this->_onlyExistingCells) && + (!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_position)) && + ($this->_position <= $this->_endRow)); + } + + /** + * Set the iterator to its previous value + */ + public function prev() { + if ($this->_position <= $this->_startRow) { + throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->_startRow} - {$this->_endRow})"); + } + + do { + --$this->_position; + } while (($this->_onlyExistingCells) && + (!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_position)) && + ($this->_position >= $this->_startRow)); + } + + /** + * Indicate if more rows exist in the worksheet range of rows that we're iterating + * + * @return boolean + */ + public function valid() { + return $this->_position <= $this->_endRow; + } + + /** + * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary + * + * @throws PHPExcel_Exception + */ + protected function adjustForExistingOnlyRange() { + if ($this->_onlyExistingCells) { + while ((!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_startRow)) && + ($this->_startRow <= $this->_endRow)) { + ++$this->_startRow; + } + if ($this->_startRow > $this->_endRow) { + throw new PHPExcel_Exception('No cells exist within the specified range'); + } + while ((!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_endRow)) && + ($this->_endRow >= $this->_startRow)) { + --$this->_endRow; + } + if ($this->_endRow < $this->_startRow) { + throw new PHPExcel_Exception('No cells exist within the specified range'); + } + } + } + +} diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/ColumnIterator.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/ColumnIterator.php new file mode 100644 index 00000000000..3030b3f434c --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/ColumnIterator.php @@ -0,0 +1,192 @@ +_subject = $subject; + $this->resetEnd($endColumn); + $this->resetStart($startColumn); + } + + /** + * Destructor + */ + public function __destruct() { + unset($this->_subject); + } + + /** + * (Re)Set the start column and the current column pointer + * + * @param integer $startColumn The column address at which to start iterating + * @return PHPExcel_Worksheet_ColumnIterator + */ + public function resetStart($startColumn = 'A') { + $startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1; + $this->_startColumn = $startColumnIndex; + $this->seek($startColumn); + + return $this; + } + + /** + * (Re)Set the end column + * + * @param string $endColumn The column address at which to stop iterating + * @return PHPExcel_Worksheet_ColumnIterator + */ + public function resetEnd($endColumn = null) { + $endColumn = ($endColumn) ? $endColumn : $this->_subject->getHighestColumn(); + $this->_endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1; + + return $this; + } + + /** + * Set the column pointer to the selected column + * + * @param string $column The column address to set the current pointer at + * @return PHPExcel_Worksheet_ColumnIterator + * @throws PHPExcel_Exception + */ + public function seek($column = 'A') { + $column = PHPExcel_Cell::columnIndexFromString($column) - 1; + if (($column < $this->_startColumn) || ($column > $this->_endColumn)) { + throw new PHPExcel_Exception("Column $column is out of range ({$this->_startColumn} - {$this->_endColumn})"); + } + $this->_position = $column; + + return $this; + } + + /** + * Rewind the iterator to the starting column + */ + public function rewind() { + $this->_position = $this->_startColumn; + } + + /** + * Return the current column in this worksheet + * + * @return PHPExcel_Worksheet_Column + */ + public function current() { + return new PHPExcel_Worksheet_Column($this->_subject, PHPExcel_Cell::stringFromColumnIndex($this->_position)); + } + + /** + * Return the current iterator key + * + * @return string + */ + public function key() { + return PHPExcel_Cell::stringFromColumnIndex($this->_position); + } + + /** + * Set the iterator to its next value + */ + public function next() { + ++$this->_position; + } + + /** + * Set the iterator to its previous value + * + * @throws PHPExcel_Exception + */ + public function prev() { + if ($this->_position <= $this->_startColumn) { + throw new PHPExcel_Exception( + "Column is already at the beginning of range (" . + PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . " - " . + PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . ")" + ); + } + + --$this->_position; + } + + /** + * Indicate if more columns exist in the worksheet range of columns that we're iterating + * + * @return boolean + */ + public function valid() { + return $this->_position <= $this->_endColumn; + } +} diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/Row.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/Row.php index df16d33c219..33043279035 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/Row.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/Row.php @@ -82,9 +82,11 @@ class PHPExcel_Worksheet_Row /** * Get cell iterator * + * @param string $startColumn The column address at which to start iterating + * @param string $endColumn Optionally, the column address at which to stop iterating * @return PHPExcel_Worksheet_CellIterator */ - public function getCellIterator() { - return new PHPExcel_Worksheet_CellIterator($this->_parent, $this->_rowIndex); + public function getCellIterator($startColumn = 'A', $endColumn = null) { + return new PHPExcel_Worksheet_RowCellIterator($this->_parent, $this->_rowIndex, $startColumn, $endColumn); } } diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/RowCellIterator.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/RowCellIterator.php new file mode 100644 index 00000000000..96c6b419c5e --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/RowCellIterator.php @@ -0,0 +1,224 @@ +_subject = $subject; + $this->_rowIndex = $rowIndex; + $this->resetEnd($endColumn); + $this->resetStart($startColumn); + } + + /** + * Destructor + */ + public function __destruct() { + unset($this->_subject); + } + + /** + * (Re)Set the start column and the current column pointer + * + * @param integer $startColumn The column address at which to start iterating + * @return PHPExcel_Worksheet_RowCellIterator + * @throws PHPExcel_Exception + */ + public function resetStart($startColumn = 'A') { + $startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1; + $this->_startColumn = $startColumnIndex; + $this->adjustForExistingOnlyRange(); + $this->seek(PHPExcel_Cell::stringFromColumnIndex($this->_startColumn)); + + return $this; + } + + /** + * (Re)Set the end column + * + * @param string $endColumn The column address at which to stop iterating + * @return PHPExcel_Worksheet_RowCellIterator + * @throws PHPExcel_Exception + */ + public function resetEnd($endColumn = null) { + $endColumn = ($endColumn) ? $endColumn : $this->_subject->getHighestColumn(); + $this->_endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1; + $this->adjustForExistingOnlyRange(); + + return $this; + } + + /** + * Set the column pointer to the selected column + * + * @param string $column The column address to set the current pointer at + * @return PHPExcel_Worksheet_RowCellIterator + * @throws PHPExcel_Exception + */ + public function seek($column = 'A') { + $column = PHPExcel_Cell::columnIndexFromString($column) - 1; + if (($column < $this->_startColumn) || ($column > $this->_endColumn)) { + throw new PHPExcel_Exception("Column $column is out of range ({$this->_startColumn} - {$this->_endColumn})"); + } elseif ($this->_onlyExistingCells && !($this->_subject->cellExistsByColumnAndRow($column, $this->_rowIndex))) { + throw new PHPExcel_Exception('In "IterateOnlyExistingCells" mode and Cell does not exist'); + } + $this->_position = $column; + + return $this; + } + + /** + * Rewind the iterator to the starting column + */ + public function rewind() { + $this->_position = $this->_startColumn; + } + + /** + * Return the current cell in this worksheet row + * + * @return PHPExcel_Cell + */ + public function current() { + return $this->_subject->getCellByColumnAndRow($this->_position, $this->_rowIndex); + } + + /** + * Return the current iterator key + * + * @return string + */ + public function key() { + return PHPExcel_Cell::stringFromColumnIndex($this->_position); + } + + /** + * Set the iterator to its next value + */ + public function next() { + do { + ++$this->_position; + } while (($this->_onlyExistingCells) && + (!$this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex)) && + ($this->_position <= $this->_endColumn)); + } + + /** + * Set the iterator to its previous value + * + * @throws PHPExcel_Exception + */ + public function prev() { + if ($this->_position <= $this->_startColumn) { + throw new PHPExcel_Exception( + "Column is already at the beginning of range (" . + PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . " - " . + PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . ")" + ); + } + + do { + --$this->_position; + } while (($this->_onlyExistingCells) && + (!$this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex)) && + ($this->_position >= $this->_startColumn)); + } + + /** + * Indicate if more columns exist in the worksheet range of columns that we're iterating + * + * @return boolean + */ + public function valid() { + return $this->_position <= $this->_endColumn; + } + + /** + * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary + * + * @throws PHPExcel_Exception + */ + protected function adjustForExistingOnlyRange() { + if ($this->_onlyExistingCells) { + while ((!$this->_subject->cellExistsByColumnAndRow($this->_startColumn, $this->_rowIndex)) && + ($this->_startColumn <= $this->_endColumn)) { + ++$this->_startColumn; + } + if ($this->_startColumn > $this->_endColumn) { + throw new PHPExcel_Exception('No cells exist within the specified range'); + } + while ((!$this->_subject->cellExistsByColumnAndRow($this->_endColumn, $this->_rowIndex)) && + ($this->_endColumn >= $this->_startColumn)) { + --$this->_endColumn; + } + if ($this->_endColumn < $this->_startColumn) { + throw new PHPExcel_Exception('No cells exist within the specified range'); + } + } + } + +} diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/RowDimension.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/RowDimension.php index 93535f55ec2..bff89a0809e 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/RowDimension.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/RowDimension.php @@ -145,7 +145,7 @@ class PHPExcel_Worksheet_RowDimension * * @return bool */ - public function getzeroHeight() { + public function getZeroHeight() { return $this->_zeroHeight; } @@ -155,7 +155,7 @@ class PHPExcel_Worksheet_RowDimension * @param bool $pValue * @return PHPExcel_Worksheet_RowDimension */ - public function setzeroHeight($pValue = false) { + public function setZeroHeight($pValue = false) { $this->_zeroHeight = $pValue; return $this; } diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/RowIterator.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/RowIterator.php index 642ec763d13..110d8621437 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/RowIterator.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/RowIterator.php @@ -59,15 +59,25 @@ class PHPExcel_Worksheet_RowIterator implements Iterator private $_startRow = 1; + /** + * End position + * + * @var int + */ + private $_endRow = 1; + + /** * Create a new row iterator * * @param PHPExcel_Worksheet $subject The worksheet to iterate over * @param integer $startRow The row number at which to start iterating + * @param integer $endRow Optionally, the row number at which to stop iterating */ - public function __construct(PHPExcel_Worksheet $subject = null, $startRow = 1) { + public function __construct(PHPExcel_Worksheet $subject = null, $startRow = 1, $endRow = null) { // Set subject $this->_subject = $subject; + $this->resetEnd($endRow); $this->resetStart($startRow); } @@ -82,19 +92,41 @@ class PHPExcel_Worksheet_RowIterator implements Iterator * (Re)Set the start row and the current row pointer * * @param integer $startRow The row number at which to start iterating + * @return PHPExcel_Worksheet_RowIterator */ public function resetStart($startRow = 1) { $this->_startRow = $startRow; $this->seek($startRow); + + return $this; + } + + /** + * (Re)Set the end row + * + * @param integer $endRow The row number at which to stop iterating + * @return PHPExcel_Worksheet_RowIterator + */ + public function resetEnd($endRow = null) { + $this->_endRow = ($endRow) ? $endRow : $this->_subject->getHighestRow(); + + return $this; } /** * Set the row pointer to the selected row * * @param integer $row The row number to set the current pointer at + * @return PHPExcel_Worksheet_RowIterator + * @throws PHPExcel_Exception */ public function seek($row = 1) { + if (($row < $this->_startRow) || ($row > $this->_endRow)) { + throw new PHPExcel_Exception("Row $row is out of range ({$this->_startRow} - {$this->_endRow})"); + } $this->_position = $row; + + return $this; } /** @@ -133,16 +165,19 @@ class PHPExcel_Worksheet_RowIterator implements Iterator * Set the iterator to its previous value */ public function prev() { - if ($this->_position > 1) - --$this->_position; + if ($this->_position <= $this->_startRow) { + throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->_startRow} - {$this->_endRow})"); + } + + --$this->_position; } /** - * Indicate if more rows exist in the worksheet + * Indicate if more rows exist in the worksheet range of rows that we're iterating * * @return boolean */ public function valid() { - return $this->_position <= $this->_subject->getHighestRow(); + return $this->_position <= $this->_endRow; } } diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Chart.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Chart.php index 0b686b9124a..4846910fa29 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Chart.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Chart.php @@ -25,7 +25,6 @@ * @version ##VERSION##, ##DATE## */ - /** * PHPExcel_Writer_Excel2007_Chart * @@ -33,1171 +32,1575 @@ * @package PHPExcel_Writer_Excel2007 * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPart -{ - /** - * Write charts to XML format - * - * @param PHPExcel_Chart $pChart - * @return string XML Output - * @throws PHPExcel_Writer_Exception - */ - public function writeChart(PHPExcel_Chart $pChart = null) - { - // Create XML writer - $objWriter = null; - if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY); - } - // Ensure that data series values are up-to-date before we save - $pChart->refresh(); - - // XML header - $objWriter->startDocument('1.0','UTF-8','yes'); - - // c:chartSpace - $objWriter->startElement('c:chartSpace'); - $objWriter->writeAttribute('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart'); - $objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); - $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - - $objWriter->startElement('c:date1904'); - $objWriter->writeAttribute('val', 0); - $objWriter->endElement(); - $objWriter->startElement('c:lang'); - $objWriter->writeAttribute('val', "en-GB"); - $objWriter->endElement(); - $objWriter->startElement('c:roundedCorners'); - $objWriter->writeAttribute('val', 0); - $objWriter->endElement(); - - $this->_writeAlternateContent($objWriter); - - $objWriter->startElement('c:chart'); - - $this->_writeTitle($pChart->getTitle(), $objWriter); - - $objWriter->startElement('c:autoTitleDeleted'); - $objWriter->writeAttribute('val', 0); - $objWriter->endElement(); - - $this->_writePlotArea($pChart->getPlotArea(), - $pChart->getXAxisLabel(), - $pChart->getYAxisLabel(), - $objWriter, - $pChart->getWorksheet() - ); - - $this->_writeLegend($pChart->getLegend(), $objWriter); - - - $objWriter->startElement('c:plotVisOnly'); - $objWriter->writeAttribute('val', 1); - $objWriter->endElement(); - - $objWriter->startElement('c:dispBlanksAs'); - $objWriter->writeAttribute('val', "gap"); - $objWriter->endElement(); - - $objWriter->startElement('c:showDLblsOverMax'); - $objWriter->writeAttribute('val', 0); - $objWriter->endElement(); - - $objWriter->endElement(); - - $this->_writePrintSettings($objWriter); - - $objWriter->endElement(); - - // Return - return $objWriter->getData(); - } - - /** - * Write Chart Title - * - * @param PHPExcel_Chart_Title $title - * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @throws PHPExcel_Writer_Exception - */ - private function _writeTitle(PHPExcel_Chart_Title $title = null, $objWriter) - { - if (is_null($title)) { - return; - } - - $objWriter->startElement('c:title'); - $objWriter->startElement('c:tx'); - $objWriter->startElement('c:rich'); - - $objWriter->startElement('a:bodyPr'); - $objWriter->endElement(); - - $objWriter->startElement('a:lstStyle'); - $objWriter->endElement(); - - $objWriter->startElement('a:p'); - - $caption = $title->getCaption(); - if ((is_array($caption)) && (count($caption) > 0)) - $caption = $caption[0]; - $this->getParentWriter()->getWriterPart('stringtable')->writeRichTextForCharts($objWriter, $caption, 'a'); - - $objWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); - - $layout = $title->getLayout(); - $this->_writeLayout($layout, $objWriter); - - $objWriter->startElement('c:overlay'); - $objWriter->writeAttribute('val', 0); - $objWriter->endElement(); - - $objWriter->endElement(); - } - - /** - * Write Chart Legend - * - * @param PHPExcel_Chart_Legend $legend - * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @throws PHPExcel_Writer_Exception - */ - private function _writeLegend(PHPExcel_Chart_Legend $legend = null, $objWriter) - { - if (is_null($legend)) { - return; - } - - $objWriter->startElement('c:legend'); - - $objWriter->startElement('c:legendPos'); - $objWriter->writeAttribute('val', $legend->getPosition()); - $objWriter->endElement(); - - $layout = $legend->getLayout(); - $this->_writeLayout($layout, $objWriter); - - $objWriter->startElement('c:overlay'); - $objWriter->writeAttribute('val', ($legend->getOverlay()) ? '1' : '0'); - $objWriter->endElement(); - - $objWriter->startElement('c:txPr'); - $objWriter->startElement('a:bodyPr'); - $objWriter->endElement(); - - $objWriter->startElement('a:lstStyle'); - $objWriter->endElement(); - - $objWriter->startElement('a:p'); - $objWriter->startElement('a:pPr'); - $objWriter->writeAttribute('rtl', 0); - - $objWriter->startElement('a:defRPr'); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->startElement('a:endParaRPr'); - $objWriter->writeAttribute('lang', "en-US"); - $objWriter->endElement(); - - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->endElement(); - } - - /** - * Write Chart Plot Area - * - * @param PHPExcel_Chart_PlotArea $plotArea - * @param PHPExcel_Chart_Title $xAxisLabel - * @param PHPExcel_Chart_Title $yAxisLabel - * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @throws PHPExcel_Writer_Exception - */ - private function _writePlotArea(PHPExcel_Chart_PlotArea $plotArea, - PHPExcel_Chart_Title $xAxisLabel = NULL, - PHPExcel_Chart_Title $yAxisLabel = NULL, - $objWriter, - PHPExcel_Worksheet $pSheet) - { - if (is_null($plotArea)) { - return; - } - - $id1 = $id2 = 0; - $this->_seriesIndex = 0; - $objWriter->startElement('c:plotArea'); - - $layout = $plotArea->getLayout(); - - $this->_writeLayout($layout, $objWriter); - - $chartTypes = self::_getChartType($plotArea); - $catIsMultiLevelSeries = $valIsMultiLevelSeries = FALSE; - $plotGroupingType = ''; - foreach($chartTypes as $chartType) { - $objWriter->startElement('c:'.$chartType); - - $groupCount = $plotArea->getPlotGroupCount(); - for($i = 0; $i < $groupCount; ++$i) { - $plotGroup = $plotArea->getPlotGroupByIndex($i); - $groupType = $plotGroup->getPlotType(); - if ($groupType == $chartType) { - - $plotStyle = $plotGroup->getPlotStyle(); - if ($groupType === PHPExcel_Chart_DataSeries::TYPE_RADARCHART) { - $objWriter->startElement('c:radarStyle'); - $objWriter->writeAttribute('val', $plotStyle ); - $objWriter->endElement(); - } elseif ($groupType === PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART) { - $objWriter->startElement('c:scatterStyle'); - $objWriter->writeAttribute('val', $plotStyle ); - $objWriter->endElement(); - } - - $this->_writePlotGroup($plotGroup, $chartType, $objWriter, $catIsMultiLevelSeries, $valIsMultiLevelSeries, $plotGroupingType, $pSheet); - } - } - - $this->_writeDataLbls($objWriter, $layout); - - if ($chartType === PHPExcel_Chart_DataSeries::TYPE_LINECHART) { - // Line only, Line3D can't be smoothed - - $objWriter->startElement('c:smooth'); - $objWriter->writeAttribute('val', (integer) $plotGroup->getSmoothLine() ); - $objWriter->endElement(); - } elseif (($chartType === PHPExcel_Chart_DataSeries::TYPE_BARCHART) || - ($chartType === PHPExcel_Chart_DataSeries::TYPE_BARCHART_3D)) { - - $objWriter->startElement('c:gapWidth'); - $objWriter->writeAttribute('val', 150 ); - $objWriter->endElement(); - - if ($plotGroupingType == 'percentStacked' || - $plotGroupingType == 'stacked') { - - $objWriter->startElement('c:overlap'); - $objWriter->writeAttribute('val', 100 ); - $objWriter->endElement(); - } - } elseif ($chartType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) { - - $objWriter->startElement('c:bubbleScale'); - $objWriter->writeAttribute('val', 25 ); - $objWriter->endElement(); - - $objWriter->startElement('c:showNegBubbles'); - $objWriter->writeAttribute('val', 0 ); - $objWriter->endElement(); - } elseif ($chartType === PHPExcel_Chart_DataSeries::TYPE_STOCKCHART) { - - $objWriter->startElement('c:hiLowLines'); - $objWriter->endElement(); - - $objWriter->startElement( 'c:upDownBars' ); - - $objWriter->startElement( 'c:gapWidth' ); - $objWriter->writeAttribute('val', 300); - $objWriter->endElement(); - - $objWriter->startElement( 'c:upBars' ); - $objWriter->endElement(); - - $objWriter->startElement( 'c:downBars' ); - $objWriter->endElement(); - - $objWriter->endElement(); - } - - // Generate 2 unique numbers to use for axId values -// $id1 = $id2 = rand(10000000,99999999); -// do { -// $id2 = rand(10000000,99999999); -// } while ($id1 == $id2); - $id1 = '75091328'; - $id2 = '75089408'; - - if (($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART) && - ($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) && - ($chartType !== PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)) { - - $objWriter->startElement('c:axId'); - $objWriter->writeAttribute('val', $id1 ); - $objWriter->endElement(); - $objWriter->startElement('c:axId'); - $objWriter->writeAttribute('val', $id2 ); - $objWriter->endElement(); - } else { - $objWriter->startElement('c:firstSliceAng'); - $objWriter->writeAttribute('val', 0); - $objWriter->endElement(); - - if ($chartType === PHPExcel_Chart_DataSeries::TYPE_DONUTCHART) { - - $objWriter->startElement('c:holeSize'); - $objWriter->writeAttribute('val', 50); - $objWriter->endElement(); - } - } - - $objWriter->endElement(); - } - - if (($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART) && - ($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) && - ($chartType !== PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)) { - - if ($chartType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) { - $this->_writeValAx($objWriter,$plotArea,$xAxisLabel,$chartType,$id1,$id2,$catIsMultiLevelSeries); - } else { - $this->_writeCatAx($objWriter,$plotArea,$xAxisLabel,$chartType,$id1,$id2,$catIsMultiLevelSeries); - } - - $this->_writeValAx($objWriter,$plotArea,$yAxisLabel,$chartType,$id1,$id2,$valIsMultiLevelSeries); - } - - $objWriter->endElement(); - } - - /** - * Write Data Labels - * - * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @param PHPExcel_Chart_Layout $chartLayout Chart layout - * @throws PHPExcel_Writer_Exception - */ - private function _writeDataLbls($objWriter, $chartLayout) - { - $objWriter->startElement('c:dLbls'); - - $objWriter->startElement('c:showLegendKey'); - $showLegendKey = (empty($chartLayout)) ? 0 : $chartLayout->getShowLegendKey(); - $objWriter->writeAttribute('val', ((empty($showLegendKey)) ? 0 : 1) ); - $objWriter->endElement(); - - - $objWriter->startElement('c:showVal'); - $showVal = (empty($chartLayout)) ? 0 : $chartLayout->getShowVal(); - $objWriter->writeAttribute('val', ((empty($showVal)) ? 0 : 1) ); - $objWriter->endElement(); - - $objWriter->startElement('c:showCatName'); - $showCatName = (empty($chartLayout)) ? 0 : $chartLayout->getShowCatName(); - $objWriter->writeAttribute('val', ((empty($showCatName)) ? 0 : 1) ); - $objWriter->endElement(); - - $objWriter->startElement('c:showSerName'); - $showSerName = (empty($chartLayout)) ? 0 : $chartLayout->getShowSerName(); - $objWriter->writeAttribute('val', ((empty($showSerName)) ? 0 : 1) ); - $objWriter->endElement(); - - $objWriter->startElement('c:showPercent'); - $showPercent = (empty($chartLayout)) ? 0 : $chartLayout->getShowPercent(); - $objWriter->writeAttribute('val', ((empty($showPercent)) ? 0 : 1) ); - $objWriter->endElement(); - - $objWriter->startElement('c:showBubbleSize'); - $showBubbleSize = (empty($chartLayout)) ? 0 : $chartLayout->getShowBubbleSize(); - $objWriter->writeAttribute('val', ((empty($showBubbleSize)) ? 0 : 1) ); - $objWriter->endElement(); - - $objWriter->startElement('c:showLeaderLines'); - $showLeaderLines = (empty($chartLayout)) ? 1 : $chartLayout->getShowLeaderLines(); - $objWriter->writeAttribute('val', ((empty($showLeaderLines)) ? 0 : 1) ); - $objWriter->endElement(); - - $objWriter->endElement(); - } - - /** - * Write Category Axis - * - * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @param PHPExcel_Chart_PlotArea $plotArea - * @param PHPExcel_Chart_Title $xAxisLabel - * @param string $groupType Chart type - * @param string $id1 - * @param string $id2 - * @param boolean $isMultiLevelSeries - * @throws PHPExcel_Writer_Exception - */ - private function _writeCatAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $xAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries) - { - $objWriter->startElement('c:catAx'); - - if ($id1 > 0) { - $objWriter->startElement('c:axId'); - $objWriter->writeAttribute('val', $id1); - $objWriter->endElement(); - } - - $objWriter->startElement('c:scaling'); - $objWriter->startElement('c:orientation'); - $objWriter->writeAttribute('val', "minMax"); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->startElement('c:delete'); - $objWriter->writeAttribute('val', 0); - $objWriter->endElement(); - - $objWriter->startElement('c:axPos'); - $objWriter->writeAttribute('val', "b"); - $objWriter->endElement(); - - if (!is_null($xAxisLabel)) { - $objWriter->startElement('c:title'); - $objWriter->startElement('c:tx'); - $objWriter->startElement('c:rich'); - - $objWriter->startElement('a:bodyPr'); - $objWriter->endElement(); - - $objWriter->startElement('a:lstStyle'); - $objWriter->endElement(); - - $objWriter->startElement('a:p'); - $objWriter->startElement('a:r'); - - $caption = $xAxisLabel->getCaption(); - if (is_array($caption)) - $caption = $caption[0]; - $objWriter->startElement('a:t'); -// $objWriter->writeAttribute('xml:space', 'preserve'); - $objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $caption )); - $objWriter->endElement(); - - $objWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); - - $layout = $xAxisLabel->getLayout(); - $this->_writeLayout($layout, $objWriter); - - $objWriter->startElement('c:overlay'); - $objWriter->writeAttribute('val', 0); - $objWriter->endElement(); - - $objWriter->endElement(); - - } - - $objWriter->startElement('c:numFmt'); - $objWriter->writeAttribute('formatCode', "General"); - $objWriter->writeAttribute('sourceLinked', 1); - $objWriter->endElement(); - - $objWriter->startElement('c:majorTickMark'); - $objWriter->writeAttribute('val', "out"); - $objWriter->endElement(); - - $objWriter->startElement('c:minorTickMark'); - $objWriter->writeAttribute('val', "none"); - $objWriter->endElement(); - - $objWriter->startElement('c:tickLblPos'); - $objWriter->writeAttribute('val', "nextTo"); - $objWriter->endElement(); - - if ($id2 > 0) { - $objWriter->startElement('c:crossAx'); - $objWriter->writeAttribute('val', $id2); - $objWriter->endElement(); - - $objWriter->startElement('c:crosses'); - $objWriter->writeAttribute('val', "autoZero"); - $objWriter->endElement(); - } - - $objWriter->startElement('c:auto'); - $objWriter->writeAttribute('val', 1); - $objWriter->endElement(); - - $objWriter->startElement('c:lblAlgn'); - $objWriter->writeAttribute('val', "ctr"); - $objWriter->endElement(); - - $objWriter->startElement('c:lblOffset'); - $objWriter->writeAttribute('val', 100); - $objWriter->endElement(); - - if ($isMultiLevelSeries) { - $objWriter->startElement('c:noMultiLvlLbl'); - $objWriter->writeAttribute('val', 0); - $objWriter->endElement(); - } - $objWriter->endElement(); - - } - - - /** - * Write Value Axis - * - * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @param PHPExcel_Chart_PlotArea $plotArea - * @param PHPExcel_Chart_Title $yAxisLabel - * @param string $groupType Chart type - * @param string $id1 - * @param string $id2 - * @param boolean $isMultiLevelSeries - * @throws PHPExcel_Writer_Exception - */ - private function _writeValAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries) - { - $objWriter->startElement('c:valAx'); - - if ($id2 > 0) { - $objWriter->startElement('c:axId'); - $objWriter->writeAttribute('val', $id2); - $objWriter->endElement(); - } - - $objWriter->startElement('c:scaling'); - $objWriter->startElement('c:orientation'); - $objWriter->writeAttribute('val', "minMax"); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->startElement('c:delete'); - $objWriter->writeAttribute('val', 0); - $objWriter->endElement(); - - $objWriter->startElement('c:axPos'); - $objWriter->writeAttribute('val', "l"); - $objWriter->endElement(); - - $objWriter->startElement('c:majorGridlines'); - $objWriter->endElement(); - - if (!is_null($yAxisLabel)) { - $objWriter->startElement('c:title'); - $objWriter->startElement('c:tx'); - $objWriter->startElement('c:rich'); - - $objWriter->startElement('a:bodyPr'); - $objWriter->endElement(); - - $objWriter->startElement('a:lstStyle'); - $objWriter->endElement(); - - $objWriter->startElement('a:p'); - $objWriter->startElement('a:r'); - - $caption = $yAxisLabel->getCaption(); - if (is_array($caption)) - $caption = $caption[0]; - $objWriter->startElement('a:t'); -// $objWriter->writeAttribute('xml:space', 'preserve'); - $objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $caption )); - $objWriter->endElement(); - - $objWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); - - if ($groupType !== PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) { - $layout = $yAxisLabel->getLayout(); - $this->_writeLayout($layout, $objWriter); - } - - $objWriter->startElement('c:overlay'); - $objWriter->writeAttribute('val', 0); - $objWriter->endElement(); - - $objWriter->endElement(); - } - - $objWriter->startElement('c:numFmt'); - $objWriter->writeAttribute('formatCode', "General"); - $objWriter->writeAttribute('sourceLinked', 1); - $objWriter->endElement(); - - $objWriter->startElement('c:majorTickMark'); - $objWriter->writeAttribute('val', "out"); - $objWriter->endElement(); - - $objWriter->startElement('c:minorTickMark'); - $objWriter->writeAttribute('val', "none"); - $objWriter->endElement(); - - $objWriter->startElement('c:tickLblPos'); - $objWriter->writeAttribute('val', "nextTo"); - $objWriter->endElement(); - - if ($id1 > 0) { - $objWriter->startElement('c:crossAx'); - $objWriter->writeAttribute('val', $id2); - $objWriter->endElement(); - - $objWriter->startElement('c:crosses'); - $objWriter->writeAttribute('val', "autoZero"); - $objWriter->endElement(); - - $objWriter->startElement('c:crossBetween'); - $objWriter->writeAttribute('val', "midCat"); - $objWriter->endElement(); - } - - if ($isMultiLevelSeries) { - if ($groupType !== PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) { - $objWriter->startElement('c:noMultiLvlLbl'); - $objWriter->writeAttribute('val', 0); - $objWriter->endElement(); - } - } - $objWriter->endElement(); - - } - - - /** - * Get the data series type(s) for a chart plot series - * - * @param PHPExcel_Chart_PlotArea $plotArea - * @return string|array - * @throws PHPExcel_Writer_Exception - */ - private static function _getChartType($plotArea) - { - $groupCount = $plotArea->getPlotGroupCount(); - - if ($groupCount == 1) { - $chartType = array($plotArea->getPlotGroupByIndex(0)->getPlotType()); - } else { - $chartTypes = array(); - for($i = 0; $i < $groupCount; ++$i) { - $chartTypes[] = $plotArea->getPlotGroupByIndex($i)->getPlotType(); - } - $chartType = array_unique($chartTypes); - if (count($chartTypes) == 0) { - throw new PHPExcel_Writer_Exception('Chart is not yet implemented'); - } - } - - return $chartType; - } - - /** - * Write Plot Group (series of related plots) - * - * @param PHPExcel_Chart_DataSeries $plotGroup - * @param string $groupType Type of plot for dataseries - * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @param boolean &$catIsMultiLevelSeries Is category a multi-series category - * @param boolean &$valIsMultiLevelSeries Is value set a multi-series set - * @param string &$plotGroupingType Type of grouping for multi-series values - * @param PHPExcel_Worksheet $pSheet - * @throws PHPExcel_Writer_Exception - */ - private function _writePlotGroup( $plotGroup, - $groupType, - $objWriter, - &$catIsMultiLevelSeries, - &$valIsMultiLevelSeries, - &$plotGroupingType, - PHPExcel_Worksheet $pSheet - ) - { - if (is_null($plotGroup)) { - return; - } - - if (($groupType == PHPExcel_Chart_DataSeries::TYPE_BARCHART) || - ($groupType == PHPExcel_Chart_DataSeries::TYPE_BARCHART_3D)) { - $objWriter->startElement('c:barDir'); - $objWriter->writeAttribute('val', $plotGroup->getPlotDirection()); - $objWriter->endElement(); - } - - if (!is_null($plotGroup->getPlotGrouping())) { - $plotGroupingType = $plotGroup->getPlotGrouping(); - $objWriter->startElement('c:grouping'); - $objWriter->writeAttribute('val', $plotGroupingType); - $objWriter->endElement(); - } - - // Get these details before the loop, because we can use the count to check for varyColors - $plotSeriesOrder = $plotGroup->getPlotOrder(); - $plotSeriesCount = count($plotSeriesOrder); - - if (($groupType !== PHPExcel_Chart_DataSeries::TYPE_RADARCHART) && - ($groupType !== PHPExcel_Chart_DataSeries::TYPE_STOCKCHART)) { - - if ($groupType !== PHPExcel_Chart_DataSeries::TYPE_LINECHART) { - if (($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART) || - ($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) || - ($groupType == PHPExcel_Chart_DataSeries::TYPE_DONUTCHART) || - ($plotSeriesCount > 1)) { - $objWriter->startElement('c:varyColors'); - $objWriter->writeAttribute('val', 1); - $objWriter->endElement(); - } else { - $objWriter->startElement('c:varyColors'); - $objWriter->writeAttribute('val', 0); - $objWriter->endElement(); - } - } - } - - foreach($plotSeriesOrder as $plotSeriesIdx => $plotSeriesRef) { - $objWriter->startElement('c:ser'); - - $objWriter->startElement('c:idx'); - $objWriter->writeAttribute('val', $this->_seriesIndex + $plotSeriesIdx); - $objWriter->endElement(); - - $objWriter->startElement('c:order'); - $objWriter->writeAttribute('val', $this->_seriesIndex + $plotSeriesRef); - $objWriter->endElement(); - - if (($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART) || - ($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) || - ($groupType == PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)) { - - $objWriter->startElement('c:dPt'); - $objWriter->startElement('c:idx'); - $objWriter->writeAttribute('val', 3); - $objWriter->endElement(); - - $objWriter->startElement('c:bubble3D'); - $objWriter->writeAttribute('val', 0); - $objWriter->endElement(); - - $objWriter->startElement('c:spPr'); - $objWriter->startElement('a:solidFill'); - $objWriter->startElement('a:srgbClr'); - $objWriter->writeAttribute('val', 'FF9900'); - $objWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); - $objWriter->endElement(); - } - - // Labels - $plotSeriesLabel = $plotGroup->getPlotLabelByIndex($plotSeriesRef); - if ($plotSeriesLabel && ($plotSeriesLabel->getPointCount() > 0)) { - $objWriter->startElement('c:tx'); - $objWriter->startElement('c:strRef'); - $this->_writePlotSeriesLabel($plotSeriesLabel, $objWriter); - $objWriter->endElement(); - $objWriter->endElement(); - } - - // Formatting for the points - if (($groupType == PHPExcel_Chart_DataSeries::TYPE_LINECHART) || - ($groupType == PHPExcel_Chart_DataSeries::TYPE_STOCKCHART)) { - $objWriter->startElement('c:spPr'); - $objWriter->startElement('a:ln'); - $objWriter->writeAttribute('w', 12700); - if ($groupType == PHPExcel_Chart_DataSeries::TYPE_STOCKCHART) { - $objWriter->startElement('a:noFill'); - $objWriter->endElement(); - } - $objWriter->endElement(); - $objWriter->endElement(); - } - - $plotSeriesValues = $plotGroup->getPlotValuesByIndex($plotSeriesRef); - if ($plotSeriesValues) { - $plotSeriesMarker = $plotSeriesValues->getPointMarker(); - if ($plotSeriesMarker) { - $objWriter->startElement('c:marker'); - $objWriter->startElement('c:symbol'); - $objWriter->writeAttribute('val', $plotSeriesMarker); - $objWriter->endElement(); - - if ($plotSeriesMarker !== 'none') { - $objWriter->startElement('c:size'); - $objWriter->writeAttribute('val', 3); - $objWriter->endElement(); - } - $objWriter->endElement(); - } - } - - if (($groupType === PHPExcel_Chart_DataSeries::TYPE_BARCHART) || - ($groupType === PHPExcel_Chart_DataSeries::TYPE_BARCHART_3D) || - ($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART)) { - - $objWriter->startElement('c:invertIfNegative'); - $objWriter->writeAttribute('val', 0); - $objWriter->endElement(); - } - - // Category Labels - $plotSeriesCategory = $plotGroup->getPlotCategoryByIndex($plotSeriesRef); - if ($plotSeriesCategory && ($plotSeriesCategory->getPointCount() > 0)) { - $catIsMultiLevelSeries = $catIsMultiLevelSeries || $plotSeriesCategory->isMultiLevelSeries(); - - if (($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART) || - ($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) || - ($groupType == PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)) { - - if (!is_null($plotGroup->getPlotStyle())) { - $plotStyle = $plotGroup->getPlotStyle(); - if ($plotStyle) { - $objWriter->startElement('c:explosion'); - $objWriter->writeAttribute('val', 25); - $objWriter->endElement(); - } - } - } - - if (($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) || - ($groupType === PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART)) { - $objWriter->startElement('c:xVal'); - } else { - $objWriter->startElement('c:cat'); - } - - $this->_writePlotSeriesValues($plotSeriesCategory, $objWriter, $groupType, 'str', $pSheet); - $objWriter->endElement(); - } - - // Values - if ($plotSeriesValues) { - $valIsMultiLevelSeries = $valIsMultiLevelSeries || $plotSeriesValues->isMultiLevelSeries(); - - if (($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) || - ($groupType === PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART)) { - $objWriter->startElement('c:yVal'); - } else { - $objWriter->startElement('c:val'); - } - - $this->_writePlotSeriesValues($plotSeriesValues, $objWriter, $groupType, 'num', $pSheet); - $objWriter->endElement(); - } - - if ($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) { - $this->_writeBubbles($plotSeriesValues, $objWriter, $pSheet); - } - - $objWriter->endElement(); - - } - - $this->_seriesIndex += $plotSeriesIdx + 1; - } - - /** - * Write Plot Series Label - * - * @param PHPExcel_Chart_DataSeriesValues $plotSeriesLabel - * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @throws PHPExcel_Writer_Exception - */ - private function _writePlotSeriesLabel($plotSeriesLabel, $objWriter) - { - if (is_null($plotSeriesLabel)) { - return; - } - - $objWriter->startElement('c:f'); - $objWriter->writeRawData($plotSeriesLabel->getDataSource()); - $objWriter->endElement(); - - $objWriter->startElement('c:strCache'); - $objWriter->startElement('c:ptCount'); - $objWriter->writeAttribute('val', $plotSeriesLabel->getPointCount() ); - $objWriter->endElement(); - - foreach($plotSeriesLabel->getDataValues() as $plotLabelKey => $plotLabelValue) { - $objWriter->startElement('c:pt'); - $objWriter->writeAttribute('idx', $plotLabelKey ); - - $objWriter->startElement('c:v'); - $objWriter->writeRawData( $plotLabelValue ); - $objWriter->endElement(); - $objWriter->endElement(); - } - $objWriter->endElement(); - - } - - /** - * Write Plot Series Values - * - * @param PHPExcel_Chart_DataSeriesValues $plotSeriesValues - * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @param string $groupType Type of plot for dataseries - * @param string $dataType Datatype of series values - * @param PHPExcel_Worksheet $pSheet - * @throws PHPExcel_Writer_Exception - */ - private function _writePlotSeriesValues( $plotSeriesValues, - $objWriter, - $groupType, - $dataType='str', - PHPExcel_Worksheet $pSheet - ) - { - if (is_null($plotSeriesValues)) { - return; - } - - if ($plotSeriesValues->isMultiLevelSeries()) { - $levelCount = $plotSeriesValues->multiLevelCount(); - - $objWriter->startElement('c:multiLvlStrRef'); - - $objWriter->startElement('c:f'); - $objWriter->writeRawData( $plotSeriesValues->getDataSource() ); - $objWriter->endElement(); - - $objWriter->startElement('c:multiLvlStrCache'); - - $objWriter->startElement('c:ptCount'); - $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount() ); - $objWriter->endElement(); - - for ($level = 0; $level < $levelCount; ++$level) { - $objWriter->startElement('c:lvl'); - - foreach($plotSeriesValues->getDataValues() as $plotSeriesKey => $plotSeriesValue) { - if (isset($plotSeriesValue[$level])) { - $objWriter->startElement('c:pt'); - $objWriter->writeAttribute('idx', $plotSeriesKey ); - - $objWriter->startElement('c:v'); - $objWriter->writeRawData( $plotSeriesValue[$level] ); - $objWriter->endElement(); - $objWriter->endElement(); - } - } - - $objWriter->endElement(); - } - - $objWriter->endElement(); - - $objWriter->endElement(); - } else { - $objWriter->startElement('c:'.$dataType.'Ref'); - - $objWriter->startElement('c:f'); - $objWriter->writeRawData( $plotSeriesValues->getDataSource() ); - $objWriter->endElement(); - - $objWriter->startElement('c:'.$dataType.'Cache'); - - if (($groupType != PHPExcel_Chart_DataSeries::TYPE_PIECHART) && - ($groupType != PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) && - ($groupType != PHPExcel_Chart_DataSeries::TYPE_DONUTCHART)) { - - if (($plotSeriesValues->getFormatCode() !== NULL) && - ($plotSeriesValues->getFormatCode() !== '')) { - $objWriter->startElement('c:formatCode'); - $objWriter->writeRawData( $plotSeriesValues->getFormatCode() ); - $objWriter->endElement(); - } - } - - $objWriter->startElement('c:ptCount'); - $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount() ); - $objWriter->endElement(); - - $dataValues = $plotSeriesValues->getDataValues(); - if (!empty($dataValues)) { - if (is_array($dataValues)) { - foreach($dataValues as $plotSeriesKey => $plotSeriesValue) { - $objWriter->startElement('c:pt'); - $objWriter->writeAttribute('idx', $plotSeriesKey ); - - $objWriter->startElement('c:v'); - $objWriter->writeRawData( $plotSeriesValue ); - $objWriter->endElement(); - $objWriter->endElement(); - } - } - } - - $objWriter->endElement(); - - $objWriter->endElement(); - } - } - - /** - * Write Bubble Chart Details - * - * @param PHPExcel_Chart_DataSeriesValues $plotSeriesValues - * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @throws PHPExcel_Writer_Exception - */ - private function _writeBubbles($plotSeriesValues, $objWriter, PHPExcel_Worksheet $pSheet) - { - if (is_null($plotSeriesValues)) { - return; - } - - $objWriter->startElement('c:bubbleSize'); - $objWriter->startElement('c:numLit'); - - $objWriter->startElement('c:formatCode'); - $objWriter->writeRawData( 'General' ); - $objWriter->endElement(); - - $objWriter->startElement('c:ptCount'); - $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount() ); - $objWriter->endElement(); - - $dataValues = $plotSeriesValues->getDataValues(); - if (!empty($dataValues)) { - if (is_array($dataValues)) { - foreach($dataValues as $plotSeriesKey => $plotSeriesValue) { - $objWriter->startElement('c:pt'); - $objWriter->writeAttribute('idx', $plotSeriesKey ); - $objWriter->startElement('c:v'); - $objWriter->writeRawData( 1 ); - $objWriter->endElement(); - $objWriter->endElement(); - } - } - } - - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->startElement('c:bubble3D'); - $objWriter->writeAttribute('val', 0 ); - $objWriter->endElement(); - } - - /** - * Write Layout - * - * @param PHPExcel_Chart_Layout $layout - * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @throws PHPExcel_Writer_Exception - */ - private function _writeLayout(PHPExcel_Chart_Layout $layout = NULL, $objWriter) - { - $objWriter->startElement('c:layout'); - - if (!is_null($layout)) { - $objWriter->startElement('c:manualLayout'); - - $layoutTarget = $layout->getLayoutTarget(); - if (!is_null($layoutTarget)) { - $objWriter->startElement('c:layoutTarget'); - $objWriter->writeAttribute('val', $layoutTarget); - $objWriter->endElement(); - } - - $xMode = $layout->getXMode(); - if (!is_null($xMode)) { - $objWriter->startElement('c:xMode'); - $objWriter->writeAttribute('val', $xMode); - $objWriter->endElement(); - } - - $yMode = $layout->getYMode(); - if (!is_null($yMode)) { - $objWriter->startElement('c:yMode'); - $objWriter->writeAttribute('val', $yMode); - $objWriter->endElement(); - } - - $x = $layout->getXPosition(); - if (!is_null($x)) { - $objWriter->startElement('c:x'); - $objWriter->writeAttribute('val', $x); - $objWriter->endElement(); - } - - $y = $layout->getYPosition(); - if (!is_null($y)) { - $objWriter->startElement('c:y'); - $objWriter->writeAttribute('val', $y); - $objWriter->endElement(); - } - - $w = $layout->getWidth(); - if (!is_null($w)) { - $objWriter->startElement('c:w'); - $objWriter->writeAttribute('val', $w); - $objWriter->endElement(); - } - - $h = $layout->getHeight(); - if (!is_null($h)) { - $objWriter->startElement('c:h'); - $objWriter->writeAttribute('val', $h); - $objWriter->endElement(); - } - - $objWriter->endElement(); - } - - $objWriter->endElement(); - } - - /** - * Write Alternate Content block - * - * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @throws PHPExcel_Writer_Exception - */ - private function _writeAlternateContent($objWriter) - { - $objWriter->startElement('mc:AlternateContent'); - $objWriter->writeAttribute('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); - - $objWriter->startElement('mc:Choice'); - $objWriter->writeAttribute('xmlns:c14', 'http://schemas.microsoft.com/office/drawing/2007/8/2/chart'); - $objWriter->writeAttribute('Requires', 'c14'); - - $objWriter->startElement('c14:style'); - $objWriter->writeAttribute('val', '102'); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->startElement('mc:Fallback'); - $objWriter->startElement('c:style'); - $objWriter->writeAttribute('val', '2'); - $objWriter->endElement(); - $objWriter->endElement(); - - $objWriter->endElement(); - } - - /** - * Write Printer Settings - * - * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * @throws PHPExcel_Writer_Exception - */ - private function _writePrintSettings($objWriter) - { - $objWriter->startElement('c:printSettings'); - - $objWriter->startElement('c:headerFooter'); - $objWriter->endElement(); - - $objWriter->startElement('c:pageMargins'); - $objWriter->writeAttribute('footer', 0.3); - $objWriter->writeAttribute('header', 0.3); - $objWriter->writeAttribute('r', 0.7); - $objWriter->writeAttribute('l', 0.7); - $objWriter->writeAttribute('t', 0.75); - $objWriter->writeAttribute('b', 0.75); - $objWriter->endElement(); - - $objWriter->startElement('c:pageSetup'); - $objWriter->writeAttribute('orientation', "portrait"); - $objWriter->endElement(); - - $objWriter->endElement(); - } +class PHPExcel_Writer_Excel2007_Chart extends + PHPExcel_Writer_Excel2007_WriterPart { + + /** + * Write charts to XML format + * + * @param PHPExcel_Chart $pChart + * + * @return string XML Output + * @throws PHPExcel_Writer_Exception + */ + public function writeChart(PHPExcel_Chart $pChart = NULL) { + // Create XML writer + $objWriter = NULL; + if ($this->getParentWriter() + ->getUseDiskCaching() + ) { + $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter() + ->getDiskCachingDirectory()); + } else { + $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY); + } + // Ensure that data series values are up-to-date before we save + $pChart->refresh(); + + // XML header + $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + + // c:chartSpace + $objWriter->startElement('c:chartSpace'); + $objWriter->writeAttribute('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart'); + $objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); + $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + + $objWriter->startElement('c:date1904'); + $objWriter->writeAttribute('val', 0); + $objWriter->endElement(); + $objWriter->startElement('c:lang'); + $objWriter->writeAttribute('val', "en-GB"); + $objWriter->endElement(); + $objWriter->startElement('c:roundedCorners'); + $objWriter->writeAttribute('val', 0); + $objWriter->endElement(); + + $this->_writeAlternateContent($objWriter); + + $objWriter->startElement('c:chart'); + + $this->_writeTitle($pChart->getTitle(), $objWriter); + + $objWriter->startElement('c:autoTitleDeleted'); + $objWriter->writeAttribute('val', 0); + $objWriter->endElement(); + + $this->_writePlotArea( + $pChart->getPlotArea(), + $pChart->getXAxisLabel(), + $pChart->getYAxisLabel(), + $objWriter, + $pChart->getWorksheet(), + $pChart->getChartAxisX(), + $pChart->getChartAxisY(), + $pChart->getMajorGridlines(), + $pChart->getMinorGridlines() + ); + + $this->_writeLegend($pChart->getLegend(), $objWriter); + + $objWriter->startElement('c:plotVisOnly'); + $objWriter->writeAttribute('val', 1); + $objWriter->endElement(); + + $objWriter->startElement('c:dispBlanksAs'); + $objWriter->writeAttribute('val', "gap"); + $objWriter->endElement(); + + $objWriter->startElement('c:showDLblsOverMax'); + $objWriter->writeAttribute('val', 0); + $objWriter->endElement(); + + $objWriter->endElement(); + + $this->_writePrintSettings($objWriter); + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } + + /** + * Write Chart Title + * + * @param PHPExcel_Chart_Title $title + * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer + * + * @throws PHPExcel_Writer_Exception + */ + private function _writeTitle(PHPExcel_Chart_Title $title = NULL, $objWriter) { + if (is_null($title)) { + return; + } + + $objWriter->startElement('c:title'); + $objWriter->startElement('c:tx'); + $objWriter->startElement('c:rich'); + + $objWriter->startElement('a:bodyPr'); + $objWriter->endElement(); + + $objWriter->startElement('a:lstStyle'); + $objWriter->endElement(); + + $objWriter->startElement('a:p'); + + $caption = $title->getCaption(); + if ((is_array($caption)) && (count($caption) > 0)) { + $caption = $caption[0]; + } + $this->getParentWriter() + ->getWriterPart('stringtable') + ->writeRichTextForCharts($objWriter, $caption, 'a'); + + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + + $layout = $title->getLayout(); + $this->_writeLayout($layout, $objWriter); + + $objWriter->startElement('c:overlay'); + $objWriter->writeAttribute('val', 0); + $objWriter->endElement(); + + $objWriter->endElement(); + } + + /** + * Write Chart Legend + * + * @param PHPExcel_Chart_Legend $legend + * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer + * + * @throws PHPExcel_Writer_Exception + */ + private function _writeLegend(PHPExcel_Chart_Legend $legend = NULL, $objWriter) { + if (is_null($legend)) { + return; + } + + $objWriter->startElement('c:legend'); + + $objWriter->startElement('c:legendPos'); + $objWriter->writeAttribute('val', $legend->getPosition()); + $objWriter->endElement(); + + $layout = $legend->getLayout(); + $this->_writeLayout($layout, $objWriter); + + $objWriter->startElement('c:overlay'); + $objWriter->writeAttribute('val', ($legend->getOverlay()) ? '1' : '0'); + $objWriter->endElement(); + + $objWriter->startElement('c:txPr'); + $objWriter->startElement('a:bodyPr'); + $objWriter->endElement(); + + $objWriter->startElement('a:lstStyle'); + $objWriter->endElement(); + + $objWriter->startElement('a:p'); + $objWriter->startElement('a:pPr'); + $objWriter->writeAttribute('rtl', 0); + + $objWriter->startElement('a:defRPr'); + $objWriter->endElement(); + $objWriter->endElement(); + + $objWriter->startElement('a:endParaRPr'); + $objWriter->writeAttribute('lang', "en-US"); + $objWriter->endElement(); + + $objWriter->endElement(); + $objWriter->endElement(); + + $objWriter->endElement(); + } + + /** + * Write Chart Plot Area + * + * @param PHPExcel_Chart_PlotArea $plotArea + * @param PHPExcel_Chart_Title $xAxisLabel + * @param PHPExcel_Chart_Title $yAxisLabel + * @param PHPExcel_Chart_Axis $xAxis + * @param PHPExcel_Chart_Axis $yAxis + * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer + * + * @throws PHPExcel_Writer_Exception + */ + private function _writePlotArea(PHPExcel_Chart_PlotArea $plotArea, + PHPExcel_Chart_Title $xAxisLabel = NULL, + PHPExcel_Chart_Title $yAxisLabel = NULL, + $objWriter, + PHPExcel_Worksheet $pSheet, + PHPExcel_Chart_Axis $xAxis, + PHPExcel_Chart_Axis $yAxis, + PHPExcel_Chart_GridLines $majorGridlines, + PHPExcel_Chart_GridLines $minorGridlines + ) { + if (is_null($plotArea)) { + return; + } + + $id1 = $id2 = 0; + $this->_seriesIndex = 0; + $objWriter->startElement('c:plotArea'); + + $layout = $plotArea->getLayout(); + + $this->_writeLayout($layout, $objWriter); + + $chartTypes = self::_getChartType($plotArea); + $catIsMultiLevelSeries = $valIsMultiLevelSeries = FALSE; + $plotGroupingType = ''; + foreach ($chartTypes as $chartType) { + $objWriter->startElement('c:' . $chartType); + + $groupCount = $plotArea->getPlotGroupCount(); + for ($i = 0; $i < $groupCount; ++$i) { + $plotGroup = $plotArea->getPlotGroupByIndex($i); + $groupType = $plotGroup->getPlotType(); + if ($groupType == $chartType) { + + $plotStyle = $plotGroup->getPlotStyle(); + if ($groupType === PHPExcel_Chart_DataSeries::TYPE_RADARCHART) { + $objWriter->startElement('c:radarStyle'); + $objWriter->writeAttribute('val', $plotStyle); + $objWriter->endElement(); + } elseif ($groupType === PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART) { + $objWriter->startElement('c:scatterStyle'); + $objWriter->writeAttribute('val', $plotStyle); + $objWriter->endElement(); + } + + $this->_writePlotGroup($plotGroup, $chartType, $objWriter, $catIsMultiLevelSeries, $valIsMultiLevelSeries, $plotGroupingType, $pSheet); + } + } + + $this->_writeDataLbls($objWriter, $layout); + + if ($chartType === PHPExcel_Chart_DataSeries::TYPE_LINECHART) { + // Line only, Line3D can't be smoothed + + $objWriter->startElement('c:smooth'); + $objWriter->writeAttribute('val', (integer) $plotGroup->getSmoothLine()); + $objWriter->endElement(); + } elseif (($chartType === PHPExcel_Chart_DataSeries::TYPE_BARCHART) || + ($chartType === PHPExcel_Chart_DataSeries::TYPE_BARCHART_3D) + ) { + + $objWriter->startElement('c:gapWidth'); + $objWriter->writeAttribute('val', 150); + $objWriter->endElement(); + + if ($plotGroupingType == 'percentStacked' || + $plotGroupingType == 'stacked' + ) { + + $objWriter->startElement('c:overlap'); + $objWriter->writeAttribute('val', 100); + $objWriter->endElement(); + } + } elseif ($chartType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) { + + $objWriter->startElement('c:bubbleScale'); + $objWriter->writeAttribute('val', 25); + $objWriter->endElement(); + + $objWriter->startElement('c:showNegBubbles'); + $objWriter->writeAttribute('val', 0); + $objWriter->endElement(); + } elseif ($chartType === PHPExcel_Chart_DataSeries::TYPE_STOCKCHART) { + + $objWriter->startElement('c:hiLowLines'); + $objWriter->endElement(); + + $objWriter->startElement('c:upDownBars'); + + $objWriter->startElement('c:gapWidth'); + $objWriter->writeAttribute('val', 300); + $objWriter->endElement(); + + $objWriter->startElement('c:upBars'); + $objWriter->endElement(); + + $objWriter->startElement('c:downBars'); + $objWriter->endElement(); + + $objWriter->endElement(); + } + + // Generate 2 unique numbers to use for axId values + // $id1 = $id2 = rand(10000000,99999999); + // do { + // $id2 = rand(10000000,99999999); + // } while ($id1 == $id2); + $id1 = '75091328'; + $id2 = '75089408'; + + if (($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART) && + ($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) && + ($chartType !== PHPExcel_Chart_DataSeries::TYPE_DONUTCHART) + ) { + + $objWriter->startElement('c:axId'); + $objWriter->writeAttribute('val', $id1); + $objWriter->endElement(); + $objWriter->startElement('c:axId'); + $objWriter->writeAttribute('val', $id2); + $objWriter->endElement(); + } else { + $objWriter->startElement('c:firstSliceAng'); + $objWriter->writeAttribute('val', 0); + $objWriter->endElement(); + + if ($chartType === PHPExcel_Chart_DataSeries::TYPE_DONUTCHART) { + + $objWriter->startElement('c:holeSize'); + $objWriter->writeAttribute('val', 50); + $objWriter->endElement(); + } + } + + $objWriter->endElement(); + } + + if (($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART) && + ($chartType !== PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) && + ($chartType !== PHPExcel_Chart_DataSeries::TYPE_DONUTCHART) + ) { + + if ($chartType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) { + $this->_writeValAx($objWriter, $plotArea, $xAxisLabel, $chartType, $id1, $id2, $catIsMultiLevelSeries, $xAxis, $yAxis, $majorGridlines, $minorGridlines); + } else { + $this->_writeCatAx($objWriter, $plotArea, $xAxisLabel, $chartType, $id1, $id2, $catIsMultiLevelSeries, $xAxis, $yAxis); + } + + $this->_writeValAx($objWriter, $plotArea, $yAxisLabel, $chartType, $id1, $id2, $valIsMultiLevelSeries, $xAxis, $yAxis, $majorGridlines, $minorGridlines); + } + + $objWriter->endElement(); + } + + /** + * Write Data Labels + * + * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer + * @param PHPExcel_Chart_Layout $chartLayout Chart layout + * + * @throws PHPExcel_Writer_Exception + */ + private function _writeDataLbls($objWriter, $chartLayout) { + $objWriter->startElement('c:dLbls'); + + $objWriter->startElement('c:showLegendKey'); + $showLegendKey = (empty($chartLayout)) ? 0 : $chartLayout->getShowLegendKey(); + $objWriter->writeAttribute('val', ((empty($showLegendKey)) ? 0 : 1)); + $objWriter->endElement(); + + $objWriter->startElement('c:showVal'); + $showVal = (empty($chartLayout)) ? 0 : $chartLayout->getShowVal(); + $objWriter->writeAttribute('val', ((empty($showVal)) ? 0 : 1)); + $objWriter->endElement(); + + $objWriter->startElement('c:showCatName'); + $showCatName = (empty($chartLayout)) ? 0 : $chartLayout->getShowCatName(); + $objWriter->writeAttribute('val', ((empty($showCatName)) ? 0 : 1)); + $objWriter->endElement(); + + $objWriter->startElement('c:showSerName'); + $showSerName = (empty($chartLayout)) ? 0 : $chartLayout->getShowSerName(); + $objWriter->writeAttribute('val', ((empty($showSerName)) ? 0 : 1)); + $objWriter->endElement(); + + $objWriter->startElement('c:showPercent'); + $showPercent = (empty($chartLayout)) ? 0 : $chartLayout->getShowPercent(); + $objWriter->writeAttribute('val', ((empty($showPercent)) ? 0 : 1)); + $objWriter->endElement(); + + $objWriter->startElement('c:showBubbleSize'); + $showBubbleSize = (empty($chartLayout)) ? 0 : $chartLayout->getShowBubbleSize(); + $objWriter->writeAttribute('val', ((empty($showBubbleSize)) ? 0 : 1)); + $objWriter->endElement(); + + $objWriter->startElement('c:showLeaderLines'); + $showLeaderLines = (empty($chartLayout)) ? 1 : $chartLayout->getShowLeaderLines(); + $objWriter->writeAttribute('val', ((empty($showLeaderLines)) ? 0 : 1)); + $objWriter->endElement(); + + $objWriter->endElement(); + } + + /** + * Write Category Axis + * + * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer + * @param PHPExcel_Chart_PlotArea $plotArea + * @param PHPExcel_Chart_Title $xAxisLabel + * @param string $groupType Chart type + * @param string $id1 + * @param string $id2 + * @param boolean $isMultiLevelSeries + * + * @throws PHPExcel_Writer_Exception + */ + private function _writeCatAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $xAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, $xAxis, $yAxis) { + $objWriter->startElement('c:catAx'); + + if ($id1 > 0) { + $objWriter->startElement('c:axId'); + $objWriter->writeAttribute('val', $id1); + $objWriter->endElement(); + } + + $objWriter->startElement('c:scaling'); + $objWriter->startElement('c:orientation'); + $objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('orientation')); + $objWriter->endElement(); + $objWriter->endElement(); + + $objWriter->startElement('c:delete'); + $objWriter->writeAttribute('val', 0); + $objWriter->endElement(); + + $objWriter->startElement('c:axPos'); + $objWriter->writeAttribute('val', "b"); + $objWriter->endElement(); + + if (!is_null($xAxisLabel)) { + $objWriter->startElement('c:title'); + $objWriter->startElement('c:tx'); + $objWriter->startElement('c:rich'); + + $objWriter->startElement('a:bodyPr'); + $objWriter->endElement(); + + $objWriter->startElement('a:lstStyle'); + $objWriter->endElement(); + + $objWriter->startElement('a:p'); + $objWriter->startElement('a:r'); + + $caption = $xAxisLabel->getCaption(); + if (is_array($caption)) { + $caption = $caption[0]; + } + $objWriter->startElement('a:t'); + // $objWriter->writeAttribute('xml:space', 'preserve'); + $objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML($caption)); + $objWriter->endElement(); + + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + + $layout = $xAxisLabel->getLayout(); + $this->_writeLayout($layout, $objWriter); + + $objWriter->startElement('c:overlay'); + $objWriter->writeAttribute('val', 0); + $objWriter->endElement(); + + $objWriter->endElement(); + + } + + $objWriter->startElement('c:numFmt'); + $objWriter->writeAttribute('formatCode', $yAxis->getAxisNumberFormat()); + $objWriter->writeAttribute('sourceLinked', $yAxis->getAxisNumberSourceLinked()); + $objWriter->endElement(); + + $objWriter->startElement('c:majorTickMark'); + $objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('major_tick_mark')); + $objWriter->endElement(); + + $objWriter->startElement('c:minorTickMark'); + $objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('minor_tick_mark')); + $objWriter->endElement(); + + $objWriter->startElement('c:tickLblPos'); + $objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('axis_labels')); + $objWriter->endElement(); + + if ($id2 > 0) { + $objWriter->startElement('c:crossAx'); + $objWriter->writeAttribute('val', $id2); + $objWriter->endElement(); + + $objWriter->startElement('c:crosses'); + $objWriter->writeAttribute('val', $yAxis->getAxisOptionsProperty('horizontal_crosses')); + $objWriter->endElement(); + } + + $objWriter->startElement('c:auto'); + $objWriter->writeAttribute('val', 1); + $objWriter->endElement(); + + $objWriter->startElement('c:lblAlgn'); + $objWriter->writeAttribute('val', "ctr"); + $objWriter->endElement(); + + $objWriter->startElement('c:lblOffset'); + $objWriter->writeAttribute('val', 100); + $objWriter->endElement(); + + if ($isMultiLevelSeries) { + $objWriter->startElement('c:noMultiLvlLbl'); + $objWriter->writeAttribute('val', 0); + $objWriter->endElement(); + } + $objWriter->endElement(); + } + + /** + * Write Value Axis + * + * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer + * @param PHPExcel_Chart_PlotArea $plotArea + * @param PHPExcel_Chart_Title $yAxisLabel + * @param string $groupType Chart type + * @param string $id1 + * @param string $id2 + * @param boolean $isMultiLevelSeries + * + * @throws PHPExcel_Writer_Exception + */ + private function _writeValAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, $xAxis, $yAxis, $majorGridlines, $minorGridlines) { + $objWriter->startElement('c:valAx'); + + if ($id2 > 0) { + $objWriter->startElement('c:axId'); + $objWriter->writeAttribute('val', $id2); + $objWriter->endElement(); + } + + $objWriter->startElement('c:scaling'); + $objWriter->startElement('c:orientation'); + $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('orientation')); + + if (!is_null($xAxis->getAxisOptionsProperty('maximum'))) { + $objWriter->startElement('c:max'); + $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('maximum')); + $objWriter->endElement(); + } + + if (!is_null($xAxis->getAxisOptionsProperty('minimum'))) { + $objWriter->startElement('c:min'); + $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('minimum')); + $objWriter->endElement(); + } + + $objWriter->endElement(); + $objWriter->endElement(); + + $objWriter->startElement('c:delete'); + $objWriter->writeAttribute('val', 0); + $objWriter->endElement(); + + $objWriter->startElement('c:axPos'); + $objWriter->writeAttribute('val', "l"); + $objWriter->endElement(); + + $objWriter->startElement('c:majorGridlines'); + $objWriter->startElement('c:spPr'); + + if (!is_null($majorGridlines->getLineColorProperty('value'))) { + $objWriter->startElement('a:ln'); + $objWriter->writeAttribute('w', $majorGridlines->getLineStyleProperty('width')); + $objWriter->startElement('a:solidFill'); + $objWriter->startElement("a:{$majorGridlines->getLineColorProperty('type')}"); + $objWriter->writeAttribute('val', $majorGridlines->getLineColorProperty('value')); + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', $majorGridlines->getLineColorProperty('alpha')); + $objWriter->endElement(); //end alpha + $objWriter->endElement(); //end srgbClr + $objWriter->endElement(); //end solidFill + + $objWriter->startElement('a:prstDash'); + $objWriter->writeAttribute('val', $majorGridlines->getLineStyleProperty('dash')); + $objWriter->endElement(); + + if ($majorGridlines->getLineStyleProperty('join') == 'miter') { + $objWriter->startElement('a:miter'); + $objWriter->writeAttribute('lim', '800000'); + $objWriter->endElement(); + } else { + $objWriter->startElement('a:bevel'); + $objWriter->endElement(); + } + + if (!is_null($majorGridlines->getLineStyleProperty(array('arrow', 'head', 'type')))) { + $objWriter->startElement('a:headEnd'); + $objWriter->writeAttribute('type', $majorGridlines->getLineStyleProperty(array('arrow', 'head', 'type'))); + $objWriter->writeAttribute('w', $majorGridlines->getLineStyleArrowParameters('head', 'w')); + $objWriter->writeAttribute('len', $majorGridlines->getLineStyleArrowParameters('head', 'len')); + $objWriter->endElement(); + } + + if (!is_null($majorGridlines->getLineStyleProperty(array('arrow', 'end', 'type')))) { + $objWriter->startElement('a:tailEnd'); + $objWriter->writeAttribute('type', $majorGridlines->getLineStyleProperty(array('arrow', 'end', 'type'))); + $objWriter->writeAttribute('w', $majorGridlines->getLineStyleArrowParameters('end', 'w')); + $objWriter->writeAttribute('len', $majorGridlines->getLineStyleArrowParameters('end', 'len')); + $objWriter->endElement(); + } + $objWriter->endElement(); //end ln + } + $objWriter->startElement('a:effectLst'); + + if (!is_null($majorGridlines->getGlowSize())) { + $objWriter->startElement('a:glow'); + $objWriter->writeAttribute('rad', $majorGridlines->getGlowSize()); + $objWriter->startElement("a:{$majorGridlines->getGlowColor('type')}"); + $objWriter->writeAttribute('val', $majorGridlines->getGlowColor('value')); + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', $majorGridlines->getGlowColor('alpha')); + $objWriter->endElement(); //end alpha + $objWriter->endElement(); //end schemeClr + $objWriter->endElement(); //end glow + } + + if (!is_null($majorGridlines->getShadowProperty('presets'))) { + $objWriter->startElement("a:{$majorGridlines->getShadowProperty('effect')}"); + if (!is_null($majorGridlines->getShadowProperty('blur'))) { + $objWriter->writeAttribute('blurRad', $majorGridlines->getShadowProperty('blur')); + } + if (!is_null($majorGridlines->getShadowProperty('distance'))) { + $objWriter->writeAttribute('dist', $majorGridlines->getShadowProperty('distance')); + } + if (!is_null($majorGridlines->getShadowProperty('direction'))) { + $objWriter->writeAttribute('dir', $majorGridlines->getShadowProperty('direction')); + } + if (!is_null($majorGridlines->getShadowProperty('algn'))) { + $objWriter->writeAttribute('algn', $majorGridlines->getShadowProperty('algn')); + } + if (!is_null($majorGridlines->getShadowProperty(array('size', 'sx')))) { + $objWriter->writeAttribute('sx', $majorGridlines->getShadowProperty(array('size', 'sx'))); + } + if (!is_null($majorGridlines->getShadowProperty(array('size', 'sy')))) { + $objWriter->writeAttribute('sy', $majorGridlines->getShadowProperty(array('size', 'sy'))); + } + if (!is_null($majorGridlines->getShadowProperty(array('size', 'kx')))) { + $objWriter->writeAttribute('kx', $majorGridlines->getShadowProperty(array('size', 'kx'))); + } + if (!is_null($majorGridlines->getShadowProperty('rotWithShape'))) { + $objWriter->writeAttribute('rotWithShape', $majorGridlines->getShadowProperty('rotWithShape')); + } + $objWriter->startElement("a:{$majorGridlines->getShadowProperty(array('color', 'type'))}"); + $objWriter->writeAttribute('val', $majorGridlines->getShadowProperty(array('color', 'value'))); + + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', $majorGridlines->getShadowProperty(array('color', 'alpha'))); + $objWriter->endElement(); //end alpha + + $objWriter->endElement(); //end color:type + $objWriter->endElement(); //end shadow + } + + if (!is_null($majorGridlines->getSoftEdgesSize())) { + $objWriter->startElement('a:softEdge'); + $objWriter->writeAttribute('rad', $majorGridlines->getSoftEdgesSize()); + $objWriter->endElement(); //end softEdge + } + + $objWriter->endElement(); //end effectLst + $objWriter->endElement(); //end spPr + $objWriter->endElement(); //end majorGridLines + + if ($minorGridlines->getObjectState()) { + $objWriter->startElement('c:minorGridlines'); + $objWriter->startElement('c:spPr'); + + if (!is_null($minorGridlines->getLineColorProperty('value'))) { + $objWriter->startElement('a:ln'); + $objWriter->writeAttribute('w', $minorGridlines->getLineStyleProperty('width')); + $objWriter->startElement('a:solidFill'); + $objWriter->startElement("a:{$minorGridlines->getLineColorProperty('type')}"); + $objWriter->writeAttribute('val', $minorGridlines->getLineColorProperty('value')); + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', $minorGridlines->getLineColorProperty('alpha')); + $objWriter->endElement(); //end alpha + $objWriter->endElement(); //end srgbClr + $objWriter->endElement(); //end solidFill + + $objWriter->startElement('a:prstDash'); + $objWriter->writeAttribute('val', $minorGridlines->getLineStyleProperty('dash')); + $objWriter->endElement(); + + if ($minorGridlines->getLineStyleProperty('join') == 'miter') { + $objWriter->startElement('a:miter'); + $objWriter->writeAttribute('lim', '800000'); + $objWriter->endElement(); + } else { + $objWriter->startElement('a:bevel'); + $objWriter->endElement(); + } + + if (!is_null($minorGridlines->getLineStyleProperty(array('arrow', 'head', 'type')))) { + $objWriter->startElement('a:headEnd'); + $objWriter->writeAttribute('type', $minorGridlines->getLineStyleProperty(array('arrow', 'head', 'type'))); + $objWriter->writeAttribute('w', $minorGridlines->getLineStyleArrowParameters('head', 'w')); + $objWriter->writeAttribute('len', $minorGridlines->getLineStyleArrowParameters('head', 'len')); + $objWriter->endElement(); + } + + if (!is_null($minorGridlines->getLineStyleProperty(array('arrow', 'end', 'type')))) { + $objWriter->startElement('a:tailEnd'); + $objWriter->writeAttribute('type', $minorGridlines->getLineStyleProperty(array('arrow', 'end', 'type'))); + $objWriter->writeAttribute('w', $minorGridlines->getLineStyleArrowParameters('end', 'w')); + $objWriter->writeAttribute('len', $minorGridlines->getLineStyleArrowParameters('end', 'len')); + $objWriter->endElement(); + } + $objWriter->endElement(); //end ln + } + + $objWriter->startElement('a:effectLst'); + + if (!is_null($minorGridlines->getGlowSize())) { + $objWriter->startElement('a:glow'); + $objWriter->writeAttribute('rad', $minorGridlines->getGlowSize()); + $objWriter->startElement("a:{$minorGridlines->getGlowColor('type')}"); + $objWriter->writeAttribute('val', $minorGridlines->getGlowColor('value')); + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', $minorGridlines->getGlowColor('alpha')); + $objWriter->endElement(); //end alpha + $objWriter->endElement(); //end schemeClr + $objWriter->endElement(); //end glow + } + + if (!is_null($minorGridlines->getShadowProperty('presets'))) { + $objWriter->startElement("a:{$minorGridlines->getShadowProperty('effect')}"); + if (!is_null($minorGridlines->getShadowProperty('blur'))) { + $objWriter->writeAttribute('blurRad', $minorGridlines->getShadowProperty('blur')); + } + if (!is_null($minorGridlines->getShadowProperty('distance'))) { + $objWriter->writeAttribute('dist', $minorGridlines->getShadowProperty('distance')); + } + if (!is_null($minorGridlines->getShadowProperty('direction'))) { + $objWriter->writeAttribute('dir', $minorGridlines->getShadowProperty('direction')); + } + if (!is_null($minorGridlines->getShadowProperty('algn'))) { + $objWriter->writeAttribute('algn', $minorGridlines->getShadowProperty('algn')); + } + if (!is_null($minorGridlines->getShadowProperty(array('size', 'sx')))) { + $objWriter->writeAttribute('sx', $minorGridlines->getShadowProperty(array('size', 'sx'))); + } + if (!is_null($minorGridlines->getShadowProperty(array('size', 'sy')))) { + $objWriter->writeAttribute('sy', $minorGridlines->getShadowProperty(array('size', 'sy'))); + } + if (!is_null($minorGridlines->getShadowProperty(array('size', 'kx')))) { + $objWriter->writeAttribute('kx', $minorGridlines->getShadowProperty(array('size', 'kx'))); + } + if (!is_null($minorGridlines->getShadowProperty('rotWithShape'))) { + $objWriter->writeAttribute('rotWithShape', $minorGridlines->getShadowProperty('rotWithShape')); + } + $objWriter->startElement("a:{$minorGridlines->getShadowProperty(array('color', 'type'))}"); + $objWriter->writeAttribute('val', $minorGridlines->getShadowProperty(array('color', 'value'))); + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', $minorGridlines->getShadowProperty(array('color', 'alpha'))); + $objWriter->endElement(); //end alpha + $objWriter->endElement(); //end color:type + $objWriter->endElement(); //end shadow + } + + if (!is_null($minorGridlines->getSoftEdgesSize())) { + $objWriter->startElement('a:softEdge'); + $objWriter->writeAttribute('rad', $minorGridlines->getSoftEdgesSize()); + $objWriter->endElement(); //end softEdge + } + + $objWriter->endElement(); //end effectLst + $objWriter->endElement(); //end spPr + $objWriter->endElement(); //end minorGridLines + } + + if (!is_null($yAxisLabel)) { + + $objWriter->startElement('c:title'); + $objWriter->startElement('c:tx'); + $objWriter->startElement('c:rich'); + + $objWriter->startElement('a:bodyPr'); + $objWriter->endElement(); + + $objWriter->startElement('a:lstStyle'); + $objWriter->endElement(); + + $objWriter->startElement('a:p'); + $objWriter->startElement('a:r'); + + $caption = $yAxisLabel->getCaption(); + if (is_array($caption)) { + $caption = $caption[0]; + } + + $objWriter->startElement('a:t'); + // $objWriter->writeAttribute('xml:space', 'preserve'); + $objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML($caption)); + $objWriter->endElement(); + + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + + if ($groupType !== PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) { + $layout = $yAxisLabel->getLayout(); + $this->_writeLayout($layout, $objWriter); + } + + $objWriter->startElement('c:overlay'); + $objWriter->writeAttribute('val', 0); + $objWriter->endElement(); + + $objWriter->endElement(); + } + + $objWriter->startElement('c:numFmt'); + $objWriter->writeAttribute('formatCode', $xAxis->getAxisNumberFormat()); + $objWriter->writeAttribute('sourceLinked', $xAxis->getAxisNumberSourceLinked()); + $objWriter->endElement(); + + $objWriter->startElement('c:majorTickMark'); + $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('major_tick_mark')); + $objWriter->endElement(); + + $objWriter->startElement('c:minorTickMark'); + $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('minor_tick_mark')); + $objWriter->endElement(); + + $objWriter->startElement('c:tickLblPos'); + $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('axis_labels')); + $objWriter->endElement(); + + $objWriter->startElement('c:spPr'); + + if (!is_null($xAxis->getFillProperty('value'))) { + $objWriter->startElement('a:solidFill'); + $objWriter->startElement("a:" . $xAxis->getFillProperty('type')); + $objWriter->writeAttribute('val', $xAxis->getFillProperty('value')); + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', $xAxis->getFillProperty('alpha')); + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + } + + $objWriter->startElement('a:ln'); + + $objWriter->writeAttribute('w', $xAxis->getLineStyleProperty('width')); + $objWriter->writeAttribute('cap', $xAxis->getLineStyleProperty('cap')); + $objWriter->writeAttribute('cmpd', $xAxis->getLineStyleProperty('compound')); + + if (!is_null($xAxis->getLineProperty('value'))) { + $objWriter->startElement('a:solidFill'); + $objWriter->startElement("a:" . $xAxis->getLineProperty('type')); + $objWriter->writeAttribute('val', $xAxis->getLineProperty('value')); + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', $xAxis->getLineProperty('alpha')); + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + } + + $objWriter->startElement('a:prstDash'); + $objWriter->writeAttribute('val', $xAxis->getLineStyleProperty('dash')); + $objWriter->endElement(); + + if ($xAxis->getLineStyleProperty('join') == 'miter') { + $objWriter->startElement('a:miter'); + $objWriter->writeAttribute('lim', '800000'); + $objWriter->endElement(); + } else { + $objWriter->startElement('a:bevel'); + $objWriter->endElement(); + } + + if (!is_null($xAxis->getLineStyleProperty(array('arrow', 'head', 'type')))) { + $objWriter->startElement('a:headEnd'); + $objWriter->writeAttribute('type', $xAxis->getLineStyleProperty(array('arrow', 'head', 'type'))); + $objWriter->writeAttribute('w', $xAxis->getLineStyleArrowWidth('head')); + $objWriter->writeAttribute('len', $xAxis->getLineStyleArrowLength('head')); + $objWriter->endElement(); + } + + if (!is_null($xAxis->getLineStyleProperty(array('arrow', 'end', 'type')))) { + $objWriter->startElement('a:tailEnd'); + $objWriter->writeAttribute('type', $xAxis->getLineStyleProperty(array('arrow', 'end', 'type'))); + $objWriter->writeAttribute('w', $xAxis->getLineStyleArrowWidth('end')); + $objWriter->writeAttribute('len', $xAxis->getLineStyleArrowLength('end')); + $objWriter->endElement(); + } + + $objWriter->endElement(); + + $objWriter->startElement('a:effectLst'); + + if (!is_null($xAxis->getGlowProperty('size'))) { + $objWriter->startElement('a:glow'); + $objWriter->writeAttribute('rad', $xAxis->getGlowProperty('size')); + $objWriter->startElement("a:{$xAxis->getGlowProperty(array('color','type'))}"); + $objWriter->writeAttribute('val', $xAxis->getGlowProperty(array('color','value'))); + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', $xAxis->getGlowProperty(array('color','alpha'))); + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + } + + if (!is_null($xAxis->getShadowProperty('presets'))) { + $objWriter->startElement("a:{$xAxis->getShadowProperty('effect')}"); + + if (!is_null($xAxis->getShadowProperty('blur'))) { + $objWriter->writeAttribute('blurRad', $xAxis->getShadowProperty('blur')); + } + if (!is_null($xAxis->getShadowProperty('distance'))) { + $objWriter->writeAttribute('dist', $xAxis->getShadowProperty('distance')); + } + if (!is_null($xAxis->getShadowProperty('direction'))) { + $objWriter->writeAttribute('dir', $xAxis->getShadowProperty('direction')); + } + if (!is_null($xAxis->getShadowProperty('algn'))) { + $objWriter->writeAttribute('algn', $xAxis->getShadowProperty('algn')); + } + if (!is_null($xAxis->getShadowProperty(array('size','sx')))) { + $objWriter->writeAttribute('sx', $xAxis->getShadowProperty(array('size','sx'))); + } + if (!is_null($xAxis->getShadowProperty(array('size','sy')))) { + $objWriter->writeAttribute('sy', $xAxis->getShadowProperty(array('size','sy'))); + } + if (!is_null($xAxis->getShadowProperty(array('size','kx')))) { + $objWriter->writeAttribute('kx', $xAxis->getShadowProperty(array('size','kx'))); + } + if (!is_null($xAxis->getShadowProperty('rotWithShape'))) { + $objWriter->writeAttribute('rotWithShape', $xAxis->getShadowProperty('rotWithShape')); + } + + $objWriter->startElement("a:{$xAxis->getShadowProperty(array('color','type'))}"); + $objWriter->writeAttribute('val', $xAxis->getShadowProperty(array('color','value'))); + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', $xAxis->getShadowProperty(array('color','alpha'))); + $objWriter->endElement(); + $objWriter->endElement(); + + $objWriter->endElement(); + } + + if (!is_null($xAxis->getSoftEdgesSize())) { + $objWriter->startElement('a:softEdge'); + $objWriter->writeAttribute('rad', $xAxis->getSoftEdgesSize()); + $objWriter->endElement(); + } + + $objWriter->endElement(); //effectList + $objWriter->endElement(); //end spPr + + if ($id1 > 0) { + $objWriter->startElement('c:crossAx'); + $objWriter->writeAttribute('val', $id2); + $objWriter->endElement(); + + if (!is_null($xAxis->getAxisOptionsProperty('horizontal_crosses_value'))) { + $objWriter->startElement('c:crossesAt'); + $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('horizontal_crosses_value')); + $objWriter->endElement(); + } else { + $objWriter->startElement('c:crosses'); + $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('horizontal_crosses')); + $objWriter->endElement(); + } + + $objWriter->startElement('c:crossBetween'); + $objWriter->writeAttribute('val', "midCat"); + $objWriter->endElement(); + + if (!is_null($xAxis->getAxisOptionsProperty('major_unit'))) { + $objWriter->startElement('c:majorUnit'); + $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('major_unit')); + $objWriter->endElement(); + } + + if (!is_null($xAxis->getAxisOptionsProperty('minor_unit'))) { + $objWriter->startElement('c:minorUnit'); + $objWriter->writeAttribute('val', $xAxis->getAxisOptionsProperty('minor_unit')); + $objWriter->endElement(); + } + + } + + if ($isMultiLevelSeries) { + if ($groupType !== PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) { + $objWriter->startElement('c:noMultiLvlLbl'); + $objWriter->writeAttribute('val', 0); + $objWriter->endElement(); + } + } + + $objWriter->endElement(); + + } + + /** + * Get the data series type(s) for a chart plot series + * + * @param PHPExcel_Chart_PlotArea $plotArea + * + * @return string|array + * @throws PHPExcel_Writer_Exception + */ + private + static function _getChartType($plotArea) { + $groupCount = $plotArea->getPlotGroupCount(); + + if ($groupCount == 1) { + $chartType = array( + $plotArea->getPlotGroupByIndex(0) + ->getPlotType() + ); + } else { + $chartTypes = array(); + for ($i = 0; $i < $groupCount; ++$i) { + $chartTypes[] = $plotArea->getPlotGroupByIndex($i) + ->getPlotType(); + } + $chartType = array_unique($chartTypes); + if (count($chartTypes) == 0) { + throw new PHPExcel_Writer_Exception('Chart is not yet implemented'); + } + } + + return $chartType; + } + + /** + * Write Plot Group (series of related plots) + * + * @param PHPExcel_Chart_DataSeries $plotGroup + * @param string $groupType Type of plot for dataseries + * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer + * @param boolean &$catIsMultiLevelSeries Is category a multi-series category + * @param boolean &$valIsMultiLevelSeries Is value set a multi-series set + * @param string &$plotGroupingType Type of grouping for multi-series values + * @param PHPExcel_Worksheet $pSheet + * + * @throws PHPExcel_Writer_Exception + */ + private function _writePlotGroup($plotGroup, + $groupType, + $objWriter, + &$catIsMultiLevelSeries, + &$valIsMultiLevelSeries, + &$plotGroupingType, + PHPExcel_Worksheet $pSheet + ) { + if (is_null($plotGroup)) { + return; + } + + if (($groupType == PHPExcel_Chart_DataSeries::TYPE_BARCHART) || + ($groupType == PHPExcel_Chart_DataSeries::TYPE_BARCHART_3D) + ) { + $objWriter->startElement('c:barDir'); + $objWriter->writeAttribute('val', $plotGroup->getPlotDirection()); + $objWriter->endElement(); + } + + if (!is_null($plotGroup->getPlotGrouping())) { + $plotGroupingType = $plotGroup->getPlotGrouping(); + $objWriter->startElement('c:grouping'); + $objWriter->writeAttribute('val', $plotGroupingType); + $objWriter->endElement(); + } + + // Get these details before the loop, because we can use the count to check for varyColors + $plotSeriesOrder = $plotGroup->getPlotOrder(); + $plotSeriesCount = count($plotSeriesOrder); + + if (($groupType !== PHPExcel_Chart_DataSeries::TYPE_RADARCHART) && + ($groupType !== PHPExcel_Chart_DataSeries::TYPE_STOCKCHART) + ) { + + if ($groupType !== PHPExcel_Chart_DataSeries::TYPE_LINECHART) { + if (($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART) || + ($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) || + ($groupType == PHPExcel_Chart_DataSeries::TYPE_DONUTCHART) || + ($plotSeriesCount > 1) + ) { + $objWriter->startElement('c:varyColors'); + $objWriter->writeAttribute('val', 1); + $objWriter->endElement(); + } else { + $objWriter->startElement('c:varyColors'); + $objWriter->writeAttribute('val', 0); + $objWriter->endElement(); + } + } + } + + foreach ($plotSeriesOrder as $plotSeriesIdx => $plotSeriesRef) { + $objWriter->startElement('c:ser'); + + $objWriter->startElement('c:idx'); + $objWriter->writeAttribute('val', $this->_seriesIndex + $plotSeriesIdx); + $objWriter->endElement(); + + $objWriter->startElement('c:order'); + $objWriter->writeAttribute('val', $this->_seriesIndex + $plotSeriesRef); + $objWriter->endElement(); + + if (($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART) || + ($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) || + ($groupType == PHPExcel_Chart_DataSeries::TYPE_DONUTCHART) + ) { + + $objWriter->startElement('c:dPt'); + $objWriter->startElement('c:idx'); + $objWriter->writeAttribute('val', 3); + $objWriter->endElement(); + + $objWriter->startElement('c:bubble3D'); + $objWriter->writeAttribute('val', 0); + $objWriter->endElement(); + + $objWriter->startElement('c:spPr'); + $objWriter->startElement('a:solidFill'); + $objWriter->startElement('a:srgbClr'); + $objWriter->writeAttribute('val', 'FF9900'); + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + } + + // Labels + $plotSeriesLabel = $plotGroup->getPlotLabelByIndex($plotSeriesRef); + if ($plotSeriesLabel && ($plotSeriesLabel->getPointCount() > 0)) { + $objWriter->startElement('c:tx'); + $objWriter->startElement('c:strRef'); + $this->_writePlotSeriesLabel($plotSeriesLabel, $objWriter); + $objWriter->endElement(); + $objWriter->endElement(); + } + + // Formatting for the points + if (($groupType == PHPExcel_Chart_DataSeries::TYPE_LINECHART) || + ($groupType == PHPExcel_Chart_DataSeries::TYPE_STOCKCHART) + ) { + $objWriter->startElement('c:spPr'); + $objWriter->startElement('a:ln'); + $objWriter->writeAttribute('w', 12700); + if ($groupType == PHPExcel_Chart_DataSeries::TYPE_STOCKCHART) { + $objWriter->startElement('a:noFill'); + $objWriter->endElement(); + } + $objWriter->endElement(); + $objWriter->endElement(); + } + + $plotSeriesValues = $plotGroup->getPlotValuesByIndex($plotSeriesRef); + if ($plotSeriesValues) { + $plotSeriesMarker = $plotSeriesValues->getPointMarker(); + if ($plotSeriesMarker) { + $objWriter->startElement('c:marker'); + $objWriter->startElement('c:symbol'); + $objWriter->writeAttribute('val', $plotSeriesMarker); + $objWriter->endElement(); + + if ($plotSeriesMarker !== 'none') { + $objWriter->startElement('c:size'); + $objWriter->writeAttribute('val', 3); + $objWriter->endElement(); + } + + $objWriter->endElement(); + } + } + + if (($groupType === PHPExcel_Chart_DataSeries::TYPE_BARCHART) || + ($groupType === PHPExcel_Chart_DataSeries::TYPE_BARCHART_3D) || + ($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) + ) { + + $objWriter->startElement('c:invertIfNegative'); + $objWriter->writeAttribute('val', 0); + $objWriter->endElement(); + } + + // Category Labels + $plotSeriesCategory = $plotGroup->getPlotCategoryByIndex($plotSeriesRef); + if ($plotSeriesCategory && ($plotSeriesCategory->getPointCount() > 0)) { + $catIsMultiLevelSeries = $catIsMultiLevelSeries || $plotSeriesCategory->isMultiLevelSeries(); + + if (($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART) || + ($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) || + ($groupType == PHPExcel_Chart_DataSeries::TYPE_DONUTCHART) + ) { + + if (!is_null($plotGroup->getPlotStyle())) { + $plotStyle = $plotGroup->getPlotStyle(); + if ($plotStyle) { + $objWriter->startElement('c:explosion'); + $objWriter->writeAttribute('val', 25); + $objWriter->endElement(); + } + } + } + + if (($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) || + ($groupType === PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART) + ) { + $objWriter->startElement('c:xVal'); + } else { + $objWriter->startElement('c:cat'); + } + + $this->_writePlotSeriesValues($plotSeriesCategory, $objWriter, $groupType, 'str', $pSheet); + $objWriter->endElement(); + } + + // Values + if ($plotSeriesValues) { + $valIsMultiLevelSeries = $valIsMultiLevelSeries || $plotSeriesValues->isMultiLevelSeries(); + + if (($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) || + ($groupType === PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART) + ) { + $objWriter->startElement('c:yVal'); + } else { + $objWriter->startElement('c:val'); + } + + $this->_writePlotSeriesValues($plotSeriesValues, $objWriter, $groupType, 'num', $pSheet); + $objWriter->endElement(); + } + + if ($groupType === PHPExcel_Chart_DataSeries::TYPE_BUBBLECHART) { + $this->_writeBubbles($plotSeriesValues, $objWriter, $pSheet); + } + + $objWriter->endElement(); + + } + + $this->_seriesIndex += $plotSeriesIdx + 1; + } + + /** + * Write Plot Series Label + * + * @param PHPExcel_Chart_DataSeriesValues $plotSeriesLabel + * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer + * + * @throws PHPExcel_Writer_Exception + */ + private function _writePlotSeriesLabel($plotSeriesLabel, $objWriter) { + if (is_null($plotSeriesLabel)) { + return; + } + + $objWriter->startElement('c:f'); + $objWriter->writeRawData($plotSeriesLabel->getDataSource()); + $objWriter->endElement(); + + $objWriter->startElement('c:strCache'); + $objWriter->startElement('c:ptCount'); + $objWriter->writeAttribute('val', $plotSeriesLabel->getPointCount()); + $objWriter->endElement(); + + foreach ($plotSeriesLabel->getDataValues() as $plotLabelKey => $plotLabelValue) { + $objWriter->startElement('c:pt'); + $objWriter->writeAttribute('idx', $plotLabelKey); + + $objWriter->startElement('c:v'); + $objWriter->writeRawData($plotLabelValue); + $objWriter->endElement(); + $objWriter->endElement(); + } + $objWriter->endElement(); + + } + + /** + * Write Plot Series Values + * + * @param PHPExcel_Chart_DataSeriesValues $plotSeriesValues + * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer + * @param string $groupType Type of plot for dataseries + * @param string $dataType Datatype of series values + * @param PHPExcel_Worksheet $pSheet + * + * @throws PHPExcel_Writer_Exception + */ + private function _writePlotSeriesValues($plotSeriesValues, + $objWriter, + $groupType, + $dataType = 'str', + PHPExcel_Worksheet $pSheet + ) { + if (is_null($plotSeriesValues)) { + return; + } + + if ($plotSeriesValues->isMultiLevelSeries()) { + $levelCount = $plotSeriesValues->multiLevelCount(); + + $objWriter->startElement('c:multiLvlStrRef'); + + $objWriter->startElement('c:f'); + $objWriter->writeRawData($plotSeriesValues->getDataSource()); + $objWriter->endElement(); + + $objWriter->startElement('c:multiLvlStrCache'); + + $objWriter->startElement('c:ptCount'); + $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount()); + $objWriter->endElement(); + + for ($level = 0; $level < $levelCount; ++$level) { + $objWriter->startElement('c:lvl'); + + foreach ($plotSeriesValues->getDataValues() as $plotSeriesKey => $plotSeriesValue) { + if (isset($plotSeriesValue[$level])) { + $objWriter->startElement('c:pt'); + $objWriter->writeAttribute('idx', $plotSeriesKey); + + $objWriter->startElement('c:v'); + $objWriter->writeRawData($plotSeriesValue[$level]); + $objWriter->endElement(); + $objWriter->endElement(); + } + } + + $objWriter->endElement(); + } + + $objWriter->endElement(); + + $objWriter->endElement(); + } else { + $objWriter->startElement('c:' . $dataType . 'Ref'); + + $objWriter->startElement('c:f'); + $objWriter->writeRawData($plotSeriesValues->getDataSource()); + $objWriter->endElement(); + + $objWriter->startElement('c:' . $dataType . 'Cache'); + + if (($groupType != PHPExcel_Chart_DataSeries::TYPE_PIECHART) && + ($groupType != PHPExcel_Chart_DataSeries::TYPE_PIECHART_3D) && + ($groupType != PHPExcel_Chart_DataSeries::TYPE_DONUTCHART) + ) { + + if (($plotSeriesValues->getFormatCode() !== NULL) && + ($plotSeriesValues->getFormatCode() !== '') + ) { + $objWriter->startElement('c:formatCode'); + $objWriter->writeRawData($plotSeriesValues->getFormatCode()); + $objWriter->endElement(); + } + } + + $objWriter->startElement('c:ptCount'); + $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount()); + $objWriter->endElement(); + + $dataValues = $plotSeriesValues->getDataValues(); + if (!empty($dataValues)) { + if (is_array($dataValues)) { + foreach ($dataValues as $plotSeriesKey => $plotSeriesValue) { + $objWriter->startElement('c:pt'); + $objWriter->writeAttribute('idx', $plotSeriesKey); + + $objWriter->startElement('c:v'); + $objWriter->writeRawData($plotSeriesValue); + $objWriter->endElement(); + $objWriter->endElement(); + } + } + } + + $objWriter->endElement(); + + $objWriter->endElement(); + } + } + + /** + * Write Bubble Chart Details + * + * @param PHPExcel_Chart_DataSeriesValues $plotSeriesValues + * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer + * + * @throws PHPExcel_Writer_Exception + */ + private function _writeBubbles($plotSeriesValues, $objWriter, PHPExcel_Worksheet $pSheet) { + if (is_null($plotSeriesValues)) { + return; + } + + $objWriter->startElement('c:bubbleSize'); + $objWriter->startElement('c:numLit'); + + $objWriter->startElement('c:formatCode'); + $objWriter->writeRawData('General'); + $objWriter->endElement(); + + $objWriter->startElement('c:ptCount'); + $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount()); + $objWriter->endElement(); + + $dataValues = $plotSeriesValues->getDataValues(); + if (!empty($dataValues)) { + if (is_array($dataValues)) { + foreach ($dataValues as $plotSeriesKey => $plotSeriesValue) { + $objWriter->startElement('c:pt'); + $objWriter->writeAttribute('idx', $plotSeriesKey); + $objWriter->startElement('c:v'); + $objWriter->writeRawData(1); + $objWriter->endElement(); + $objWriter->endElement(); + } + } + } + + $objWriter->endElement(); + $objWriter->endElement(); + + $objWriter->startElement('c:bubble3D'); + $objWriter->writeAttribute('val', 0); + $objWriter->endElement(); + } + + /** + * Write Layout + * + * @param PHPExcel_Chart_Layout $layout + * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer + * + * @throws PHPExcel_Writer_Exception + */ + private function _writeLayout(PHPExcel_Chart_Layout $layout = NULL, $objWriter) { + $objWriter->startElement('c:layout'); + + if (!is_null($layout)) { + $objWriter->startElement('c:manualLayout'); + + $layoutTarget = $layout->getLayoutTarget(); + if (!is_null($layoutTarget)) { + $objWriter->startElement('c:layoutTarget'); + $objWriter->writeAttribute('val', $layoutTarget); + $objWriter->endElement(); + } + + $xMode = $layout->getXMode(); + if (!is_null($xMode)) { + $objWriter->startElement('c:xMode'); + $objWriter->writeAttribute('val', $xMode); + $objWriter->endElement(); + } + + $yMode = $layout->getYMode(); + if (!is_null($yMode)) { + $objWriter->startElement('c:yMode'); + $objWriter->writeAttribute('val', $yMode); + $objWriter->endElement(); + } + + $x = $layout->getXPosition(); + if (!is_null($x)) { + $objWriter->startElement('c:x'); + $objWriter->writeAttribute('val', $x); + $objWriter->endElement(); + } + + $y = $layout->getYPosition(); + if (!is_null($y)) { + $objWriter->startElement('c:y'); + $objWriter->writeAttribute('val', $y); + $objWriter->endElement(); + } + + $w = $layout->getWidth(); + if (!is_null($w)) { + $objWriter->startElement('c:w'); + $objWriter->writeAttribute('val', $w); + $objWriter->endElement(); + } + + $h = $layout->getHeight(); + if (!is_null($h)) { + $objWriter->startElement('c:h'); + $objWriter->writeAttribute('val', $h); + $objWriter->endElement(); + } + + $objWriter->endElement(); + } + + $objWriter->endElement(); + } + + /** + * Write Alternate Content block + * + * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer + * + * @throws PHPExcel_Writer_Exception + */ + private function _writeAlternateContent($objWriter) { + $objWriter->startElement('mc:AlternateContent'); + $objWriter->writeAttribute('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); + + $objWriter->startElement('mc:Choice'); + $objWriter->writeAttribute('xmlns:c14', 'http://schemas.microsoft.com/office/drawing/2007/8/2/chart'); + $objWriter->writeAttribute('Requires', 'c14'); + + $objWriter->startElement('c14:style'); + $objWriter->writeAttribute('val', '102'); + $objWriter->endElement(); + $objWriter->endElement(); + + $objWriter->startElement('mc:Fallback'); + $objWriter->startElement('c:style'); + $objWriter->writeAttribute('val', '2'); + $objWriter->endElement(); + $objWriter->endElement(); + + $objWriter->endElement(); + } + + /** + * Write Printer Settings + * + * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer + * + * @throws PHPExcel_Writer_Exception + */ + private function _writePrintSettings($objWriter) { + $objWriter->startElement('c:printSettings'); + + $objWriter->startElement('c:headerFooter'); + $objWriter->endElement(); + + $objWriter->startElement('c:pageMargins'); + $objWriter->writeAttribute('footer', 0.3); + $objWriter->writeAttribute('header', 0.3); + $objWriter->writeAttribute('r', 0.7); + $objWriter->writeAttribute('l', 0.7); + $objWriter->writeAttribute('t', 0.75); + $objWriter->writeAttribute('b', 0.75); + $objWriter->endElement(); + + $objWriter->startElement('c:pageSetup'); + $objWriter->writeAttribute('orientation', "portrait"); + $objWriter->endElement(); + + $objWriter->endElement(); + } } diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Style.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Style.php index 9857043b875..d38c6eacc02 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Style.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Style.php @@ -439,6 +439,9 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa if ($pStyle->getAlignment()->getIndent() > 0) { $objWriter->writeAttribute('indent', $pStyle->getAlignment()->getIndent()); } + if ($pStyle->getAlignment()->getReadorder() > 0) { + $objWriter->writeAttribute('readingOrder', $pStyle->getAlignment()->getReadorder()); + } $objWriter->endElement(); // protection diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Worksheet.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Worksheet.php index 760581647ec..5cb803e5261 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Worksheet.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Worksheet.php @@ -326,8 +326,8 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ } // Set Zero Height row - if ((string)$pSheet->getDefaultRowDimension()->getzeroHeight() == '1' || - strtolower((string)$pSheet->getDefaultRowDimension()->getzeroHeight()) == 'true' ) { + if ((string)$pSheet->getDefaultRowDimension()->getZeroHeight() == '1' || + strtolower((string)$pSheet->getDefaultRowDimension()->getZeroHeight()) == 'true' ) { $objWriter->writeAttribute('zeroHeight', '1'); } diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Parser.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Parser.php index 7bdc1c0bcb9..bc6ddb132b6 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Parser.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Parser.php @@ -1430,6 +1430,7 @@ class PHPExcel_Writer_Excel5_Parser { if($this->_lookahead == '%'){ $result = $this->_createTree('ptgPercent', $this->_current_token, ''); + $this->_advance(); // Skip the percentage operator once we've pre-built that tree } else { $result = $this->_createTree($this->_current_token, '', ''); } diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Worksheet.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Worksheet.php index 722ac15bf8a..fb75499b118 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Worksheet.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Worksheet.php @@ -1247,7 +1247,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $grbit |= $level; if ($hidden) { - $grbit |= 0x0020; + $grbit |= 0x0030; } if ($height !== null) { $grbit |= 0x0040; // fUnsynced diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/HTML.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/HTML.php index 72fd81856d4..63c5d47872d 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/HTML.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/HTML.php @@ -412,11 +412,13 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ // ? if ($row == $theadStart) { $html .= ' ' . PHP_EOL; + $cellType = 'th'; } // ? if ($row == $tbodyStart) { $html .= ' ' . PHP_EOL; + $cellType = 'td'; } // Write row if there are HTML table cells in it @@ -433,7 +435,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ $rowData[$column] = ''; } } - $html .= $this->_generateRow($sheet, $rowData, $row - 1); + $html .= $this->_generateRow($sheet, $rowData, $row - 1, $cellType); } // ? @@ -670,7 +672,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ /** * Generate CSS styles * - * @param boolean $generateSurroundingHTML Generate surrounding HTML tags? () + * @param boolean $generateSurroundingHTML Generate surrounding HTML tags? (<style> and </style>) * @return string * @throws PHPExcel_Writer_Exception */ @@ -751,6 +753,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ // .gridlines td { } $css['.gridlines td']['border'] = '1px dotted black'; + $css['.gridlines th']['border'] = '1px dotted black'; // .b {} $css['.b']['text-align'] = 'center'; // BOOL @@ -773,6 +776,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ // Calculate cell style hashes foreach ($this->_phpExcel->getCellXfCollection() as $index => $style) { $css['td.style' . $index] = $this->_createCSSStyle( $style ); + $css['th.style' . $index] = $this->_createCSSStyle( $style ); } // Fetch sheets @@ -1077,7 +1081,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @return string * @throws PHPExcel_Writer_Exception */ - private function _generateRow(PHPExcel_Worksheet $pSheet, $pValues = null, $pRow = 0) { + private function _generateRow(PHPExcel_Worksheet $pSheet, $pValues = null, $pRow = 0, $cellType = 'td') { if (is_array($pValues)) { // Construct HTML $html = ''; @@ -1122,9 +1126,15 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ $cssClass = 'column' . $colNum; } else { $cssClass = array(); - if (isset($this->_cssStyles['table.sheet' . $sheetIndex . ' td.column' . $colNum])) { - $this->_cssStyles['table.sheet' . $sheetIndex . ' td.column' . $colNum]; - } + if ($cellType == 'th') { + if (isset($this->_cssStyles['table.sheet' . $sheetIndex . ' th.column' . $colNum])) { + $this->_cssStyles['table.sheet' . $sheetIndex . ' th.column' . $colNum]; + } + } else { + if (isset($this->_cssStyles['table.sheet' . $sheetIndex . ' td.column' . $colNum])) { + $this->_cssStyles['table.sheet' . $sheetIndex . ' td.column' . $colNum]; + } + } } $colSpan = 1; $rowSpan = 1; @@ -1176,7 +1186,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ array($this, 'formatColor') ); } else { - $cellData = PHPExcel_Style_NumberFormat::ToFormattedString( + $cellData = PHPExcel_Style_NumberFormat::toFormattedString( $cell->getValue(), $pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getNumberFormat()->getFormatCode(), array($this, 'formatColor') @@ -1202,9 +1212,15 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ $cssClass .= ' style' . $cell->getXfIndex(); $cssClass .= ' ' . $cell->getDataType(); } else { - if (isset($this->_cssStyles['td.style' . $cell->getXfIndex()])) { - $cssClass = array_merge($cssClass, $this->_cssStyles['td.style' . $cell->getXfIndex()]); - } + if ($cellType == 'th') { + if (isset($this->_cssStyles['th.style' . $cell->getXfIndex()])) { + $cssClass = array_merge($cssClass, $this->_cssStyles['th.style' . $cell->getXfIndex()]); + } + } else { + if (isset($this->_cssStyles['td.style' . $cell->getXfIndex()])) { + $cssClass = array_merge($cssClass, $this->_cssStyles['td.style' . $cell->getXfIndex()]); + } + } // General horizontal alignment: Actual horizontal alignment depends on dataType $sharedStyle = $pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() ); @@ -1244,7 +1260,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ // Write if ($writeCell) { // Column start - $html .= ' _useInlineCss) { $html .= ' class="' . $cssClass . '"'; } else { @@ -1291,7 +1307,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ $html .= $cellData; // Column end - $html .= '' . PHP_EOL; + $html .= '' . PHP_EOL; } // Next column diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument.php new file mode 100644 index 00000000000..2cbe6f90424 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument.php @@ -0,0 +1,200 @@ + + * @link http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os.html + */ +class PHPExcel_Writer_OpenDocument extends PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter +{ + /** + * Private writer parts + * + * @var PHPExcel_Writer_OpenDocument_WriterPart[] + */ + private $_writerParts = array(); + + /** + * Private PHPExcel + * + * @var PHPExcel + */ + private $_spreadSheet; + + /** + * Create a new PHPExcel_Writer_OpenDocument + * + * @param PHPExcel $pPHPExcel + */ + public function __construct(PHPExcel $pPHPExcel = null) + { + $this->setPHPExcel($pPHPExcel); + + $writerPartsArray = array( + 'content' => 'PHPExcel_Writer_OpenDocument_Content', + 'meta' => 'PHPExcel_Writer_OpenDocument_Meta', + 'meta_inf' => 'PHPExcel_Writer_OpenDocument_MetaInf', + 'mimetype' => 'PHPExcel_Writer_OpenDocument_Mimetype', + 'settings' => 'PHPExcel_Writer_OpenDocument_Settings', + 'styles' => 'PHPExcel_Writer_OpenDocument_Styles', + 'thumbnails' => 'PHPExcel_Writer_OpenDocument_Thumbnails' + ); + + foreach ($writerPartsArray as $writer => $class) { + $this->_writerParts[$writer] = new $class($this); + } + } + + /** + * Get writer part + * + * @param string $pPartName Writer part name + * @return PHPExcel_Writer_Excel2007_WriterPart + */ + public function getWriterPart($pPartName = '') + { + if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) { + return $this->_writerParts[strtolower($pPartName)]; + } else { + return null; + } + } + + /** + * Save PHPExcel to file + * + * @param string $pFilename + * @throws PHPExcel_Writer_Exception + */ + public function save($pFilename = NULL) + { + if (!$this->_spreadSheet) { + throw new PHPExcel_Writer_Exception('PHPExcel object unassigned.'); + } + + // garbage collect + $this->_spreadSheet->garbageCollect(); + + // If $pFilename is php://output or php://stdout, make it a temporary file... + $originalFilename = $pFilename; + if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') { + $pFilename = @tempnam(PHPExcel_Shared_File::sys_get_temp_dir(), 'phpxltmp'); + if ($pFilename == '') { + $pFilename = $originalFilename; + } + } + + $objZip = $this->_createZip($pFilename); + + $objZip->addFromString('META-INF/manifest.xml', $this->getWriterPart('meta_inf')->writeManifest()); + $objZip->addFromString('Thumbnails/thumbnail.png', $this->getWriterPart('thumbnails')->writeThumbnail()); + $objZip->addFromString('content.xml', $this->getWriterPart('content')->write()); + $objZip->addFromString('meta.xml', $this->getWriterPart('meta')->write()); + $objZip->addFromString('mimetype', $this->getWriterPart('mimetype')->write()); + $objZip->addFromString('settings.xml', $this->getWriterPart('settings')->write()); + $objZip->addFromString('styles.xml', $this->getWriterPart('styles')->write()); + + // Close file + if ($objZip->close() === false) { + throw new PHPExcel_Writer_Exception("Could not close zip file $pFilename."); + } + + // If a temporary file was used, copy it to the correct file stream + if ($originalFilename != $pFilename) { + if (copy($pFilename, $originalFilename) === false) { + throw new PHPExcel_Writer_Exception("Could not copy temporary zip file $pFilename to $originalFilename."); + } + @unlink($pFilename); + } + } + + /** + * Create zip object + * + * @param string $pFilename + * @throws PHPExcel_Writer_Exception + * @return ZipArchive + */ + private function _createZip($pFilename) + { + // Create new ZIP file and open it for writing + $zipClass = PHPExcel_Settings::getZipClass(); + $objZip = new $zipClass(); + + // Retrieve OVERWRITE and CREATE constants from the instantiated zip class + // This method of accessing constant values from a dynamic class should work with all appropriate versions of PHP + $ro = new ReflectionObject($objZip); + $zipOverWrite = $ro->getConstant('OVERWRITE'); + $zipCreate = $ro->getConstant('CREATE'); + + if (file_exists($pFilename)) { + unlink($pFilename); + } + // Try opening the ZIP file + if ($objZip->open($pFilename, $zipOverWrite) !== true) { + if ($objZip->open($pFilename, $zipCreate) !== true) { + throw new PHPExcel_Writer_Exception("Could not open $pFilename for writing."); + } + } + + return $objZip; + } + + /** + * Get PHPExcel object + * + * @return PHPExcel + * @throws PHPExcel_Writer_Exception + */ + public function getPHPExcel() + { + if ($this->_spreadSheet !== null) { + return $this->_spreadSheet; + } else { + throw new PHPExcel_Writer_Exception('No PHPExcel assigned.'); + } + } + + /** + * Set PHPExcel object + * + * @param PHPExcel $pPHPExcel PHPExcel object + * @throws PHPExcel_Writer_Exception + * @return PHPExcel_Writer_Excel2007 + */ + public function setPHPExcel(PHPExcel $pPHPExcel = null) + { + $this->_spreadSheet = $pPHPExcel; + return $this; + } +} diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Cell/Comment.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Cell/Comment.php new file mode 100644 index 00000000000..88406ed1ad2 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Cell/Comment.php @@ -0,0 +1,63 @@ + + */ +class PHPExcel_Writer_OpenDocument_Cell_Comment +{ + public static function write(PHPExcel_Shared_XMLWriter $objWriter, PHPExcel_Cell $cell) + { + $comments = $cell->getWorksheet()->getComments(); + if (!isset($comments[$cell->getCoordinate()])) { + return; + } + $comment = $comments[$cell->getCoordinate()]; + + $objWriter->startElement('office:annotation'); + //$objWriter->writeAttribute('draw:style-name', 'gr1'); + //$objWriter->writeAttribute('draw:text-style-name', 'P1'); + $objWriter->writeAttribute('svg:width', $comment->getWidth()); + $objWriter->writeAttribute('svg:height', $comment->getHeight()); + $objWriter->writeAttribute('svg:x', $comment->getMarginLeft()); + $objWriter->writeAttribute('svg:y', $comment->getMarginTop()); + //$objWriter->writeAttribute('draw:caption-point-x', $comment->getMarginLeft()); + //$objWriter->writeAttribute('draw:caption-point-y', $comment->getMarginTop()); + $objWriter->writeElement('dc:creator', $comment->getAuthor()); + // TODO: Not realized in PHPExcel_Comment yet. + //$objWriter->writeElement('dc:date', $comment->getDate()); + $objWriter->writeElement('text:p', $comment->getText()->getPlainText()); + //$objWriter->writeAttribute('draw:text-style-name', 'P1'); + $objWriter->endElement(); + } +} diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Content.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Content.php new file mode 100644 index 00000000000..625b3541747 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Content.php @@ -0,0 +1,272 @@ + + */ +class PHPExcel_Writer_OpenDocument_Content extends PHPExcel_Writer_OpenDocument_WriterPart +{ + const NUMBER_COLS_REPEATED_MAX = 1024; + const NUMBER_ROWS_REPEATED_MAX = 1048576; + + /** + * Write content.xml to XML format + * + * @param PHPExcel $pPHPExcel + * @return string XML Output + * @throws PHPExcel_Writer_Exception + */ + public function write(PHPExcel $pPHPExcel = null) + { + if (!$pPHPExcel) { + $pPHPExcel = $this->getParentWriter()->getPHPExcel(); /* @var $pPHPExcel PHPExcel */ + } + + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0', 'UTF-8'); + + // Content + $objWriter->startElement('office:document-content'); + $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); + $objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0'); + $objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0'); + $objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0'); + $objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'); + $objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'); + $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); + $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); + $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); + $objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0'); + $objWriter->writeAttribute('xmlns:presentation', 'urn:oasis:names:tc:opendocument:xmlns:presentation:1.0'); + $objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'); + $objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0'); + $objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0'); + $objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML'); + $objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0'); + $objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0'); + $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); + $objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer'); + $objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc'); + $objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events'); + $objWriter->writeAttribute('xmlns:xforms', 'http://www.w3.org/2002/xforms'); + $objWriter->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema'); + $objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); + $objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report'); + $objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2'); + $objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); + $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); + $objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table'); + $objWriter->writeAttribute('xmlns:field', 'urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0'); + $objWriter->writeAttribute('xmlns:formx', 'urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0'); + $objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/'); + $objWriter->writeAttribute('office:version', '1.2'); + + $objWriter->writeElement('office:scripts'); + $objWriter->writeElement('office:font-face-decls'); + $objWriter->writeElement('office:automatic-styles'); + + $objWriter->startElement('office:body'); + $objWriter->startElement('office:spreadsheet'); + $objWriter->writeElement('table:calculation-settings'); + $this->_writeSheets($objWriter); + $objWriter->writeElement('table:named-expressions'); + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + + return $objWriter->getData(); + } + + /** + * Write sheets + * + * @param PHPExcel_Shared_XMLWriter $objWriter + */ + private function _writeSheets(PHPExcel_Shared_XMLWriter $objWriter) + { + $pPHPExcel = $this->getParentWriter()->getPHPExcel(); /* @var $pPHPExcel PHPExcel */ + + $sheet_count = $pPHPExcel->getSheetCount(); + for ($i = 0; $i < $sheet_count; $i++) { + //$this->getWriterPart('Worksheet')->writeWorksheet()); + $objWriter->startElement('table:table'); + $objWriter->writeAttribute('table:name', $pPHPExcel->getSheet($i)->getTitle()); + $objWriter->writeElement('office:forms'); + $objWriter->startElement('table:table-column'); + $objWriter->writeAttribute('table:number-columns-repeated', self::NUMBER_COLS_REPEATED_MAX); + $objWriter->endElement(); + $this->_writeRows($objWriter, $pPHPExcel->getSheet($i)); + $objWriter->endElement(); + } + } + + /** + * Write rows of the specified sheet + * + * @param PHPExcel_Shared_XMLWriter $objWriter + * @param PHPExcel_Worksheet $sheet + */ + private function _writeRows(PHPExcel_Shared_XMLWriter $objWriter, PHPExcel_Worksheet $sheet) + { + $number_rows_repeated = self::NUMBER_ROWS_REPEATED_MAX; + $span_row = 0; + $rows = $sheet->getRowIterator(); + while ($rows->valid()) { + $number_rows_repeated--; + $row = $rows->current(); + if ($row->getCellIterator()->valid()) { + if ($span_row) { + $objWriter->startElement('table:table-row'); + if ($span_row > 1) { + $objWriter->writeAttribute('table:number-rows-repeated', $span_row); + } + $objWriter->startElement('table:table-cell'); + $objWriter->writeAttribute('table:number-columns-repeated', self::NUMBER_COLS_REPEATED_MAX); + $objWriter->endElement(); + $objWriter->endElement(); + $span_row = 0; + } + $objWriter->startElement('table:table-row'); + $this->_writeCells($objWriter, $row); + $objWriter->endElement(); + } else { + $span_row++; + } + $rows->next(); + } + } + + /** + * Write cells of the specified row + * + * @param PHPExcel_Shared_XMLWriter $objWriter + * @param PHPExcel_Worksheet_Row $row + * @throws PHPExcel_Writer_Exception + */ + private function _writeCells(PHPExcel_Shared_XMLWriter $objWriter, PHPExcel_Worksheet_Row $row) + { + $number_cols_repeated = self::NUMBER_COLS_REPEATED_MAX; + $prev_column = -1; + $cells = $row->getCellIterator(); + while ($cells->valid()) { + $cell = $cells->current(); + $column = PHPExcel_Cell::columnIndexFromString($cell->getColumn()) - 1; + + $this->_writeCellSpan($objWriter, $column, $prev_column); + $objWriter->startElement('table:table-cell'); + + switch ($cell->getDataType()) { + case PHPExcel_Cell_DataType::TYPE_BOOL: + $objWriter->writeAttribute('office:value-type', 'boolean'); + $objWriter->writeAttribute('office:value', $cell->getValue()); + $objWriter->writeElement('text:p', $cell->getValue()); + break; + + case PHPExcel_Cell_DataType::TYPE_ERROR: + throw new PHPExcel_Writer_Exception('Writing of error not implemented yet.'); + break; + + case PHPExcel_Cell_DataType::TYPE_FORMULA: + try { + $formula_value = $cell->getCalculatedValue(); + } catch (Exception $e) { + $formula_value = $cell->getValue(); + } + $objWriter->writeAttribute('table:formula', 'of:' . $cell->getValue()); + if (is_numeric($formula_value)) { + $objWriter->writeAttribute('office:value-type', 'float'); + } else { + $objWriter->writeAttribute('office:value-type', 'string'); + } + $objWriter->writeAttribute('office:value', $formula_value); + $objWriter->writeElement('text:p', $formula_value); + break; + + case PHPExcel_Cell_DataType::TYPE_INLINE: + throw new PHPExcel_Writer_Exception('Writing of inline not implemented yet.'); + break; + + case PHPExcel_Cell_DataType::TYPE_NUMERIC: + $objWriter->writeAttribute('office:value-type', 'float'); + $objWriter->writeAttribute('office:value', $cell->getValue()); + $objWriter->writeElement('text:p', $cell->getValue()); + break; + + case PHPExcel_Cell_DataType::TYPE_STRING: + $objWriter->writeAttribute('office:value-type', 'string'); + $objWriter->writeElement('text:p', $cell->getValue()); + break; + } + PHPExcel_Writer_OpenDocument_Cell_Comment::write($objWriter, $cell); + $objWriter->endElement(); + $prev_column = $column; + $cells->next(); + } + $number_cols_repeated = $number_cols_repeated - $prev_column - 1; + if ($number_cols_repeated > 0) { + if ($number_cols_repeated > 1) { + $objWriter->startElement('table:table-cell'); + $objWriter->writeAttribute('table:number-columns-repeated', $number_cols_repeated); + $objWriter->endElement(); + } else { + $objWriter->writeElement('table:table-cell'); + } + } + } + + /** + * Write span + * + * @param PHPExcel_Shared_XMLWriter $objWriter + * @param integer $curColumn + * @param integer $prevColumn + */ + private function _writeCellSpan(PHPExcel_Shared_XMLWriter $objWriter, $curColumn, $prevColumn) + { + $diff = $curColumn - $prevColumn - 1; + if (1 === $diff) { + $objWriter->writeElement('table:table-cell'); + } elseif ($diff > 1) { + $objWriter->startElement('table:table-cell'); + $objWriter->writeAttribute('table:number-columns-repeated', $diff); + $objWriter->endElement(); + } + } +} diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Meta.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Meta.php new file mode 100644 index 00000000000..7f39e558924 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Meta.php @@ -0,0 +1,98 @@ + + */ +class PHPExcel_Writer_OpenDocument_Meta extends PHPExcel_Writer_OpenDocument_WriterPart +{ + /** + * Write meta.xml to XML format + * + * @param PHPExcel $pPHPExcel + * @return string XML Output + * @throws PHPExcel_Writer_Exception + */ + public function write(PHPExcel $pPHPExcel = null) + { + if (!$pPHPExcel) { + $pPHPExcel = $this->getParentWriter()->getPHPExcel(); + } + + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0', 'UTF-8'); + + // Meta + $objWriter->startElement('office:document-meta'); + $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); + $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); + $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); + $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); + $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); + $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); + $objWriter->writeAttribute('office:version', '1.2'); + + $objWriter->startElement('office:meta'); + $objWriter->writeElement('meta:initial-creator', $pPHPExcel->getProperties()->getCreator()); + $objWriter->writeElement('dc:creator', $pPHPExcel->getProperties()->getCreator()); + $objWriter->writeElement('meta:creation-date', date(DATE_W3C, $pPHPExcel->getProperties()->getCreated())); + $objWriter->writeElement('dc:date', date(DATE_W3C, $pPHPExcel->getProperties()->getCreated())); + $objWriter->writeElement('dc:title', $pPHPExcel->getProperties()->getTitle()); + $objWriter->writeElement('dc:description', $pPHPExcel->getProperties()->getDescription()); + $objWriter->writeElement('dc:subject', $pPHPExcel->getProperties()->getSubject()); + $keywords = explode(' ', $pPHPExcel->getProperties()->getKeywords()); + foreach ($keywords as $keyword) { + $objWriter->writeElement('meta:keyword', $keyword); + } + // + $objWriter->startElement('meta:user-defined'); + $objWriter->writeAttribute('meta:name', 'Company'); + $objWriter->writeRaw($pPHPExcel->getProperties()->getCompany()); + $objWriter->endElement(); + $objWriter->startElement('meta:user-defined'); + $objWriter->writeAttribute('meta:name', 'category'); + $objWriter->writeRaw($pPHPExcel->getProperties()->getCategory()); + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + + return $objWriter->getData(); + } +} diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/MetaInf.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/MetaInf.php new file mode 100644 index 00000000000..301d39db99f --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/MetaInf.php @@ -0,0 +1,96 @@ + + */ +class PHPExcel_Writer_OpenDocument_MetaInf extends PHPExcel_Writer_OpenDocument_WriterPart +{ + /** + * Write META-INF/manifest.xml to XML format + * + * @param PHPExcel $pPHPExcel + * @return string XML Output + * @throws PHPExcel_Writer_Exception + */ + public function writeManifest(PHPExcel $pPHPExcel = null) + { + if (!$pPHPExcel) { + $pPHPExcel = $this->getParentWriter()->getPHPExcel(); + } + + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0', 'UTF-8'); + + // Manifest + $objWriter->startElement('manifest:manifest'); + $objWriter->writeAttribute('xmlns:manifest', 'urn:oasis:names:tc:opendocument:xmlns:manifest:1.0'); + $objWriter->writeAttribute('manifest:version', '1.2'); + + $objWriter->startElement('manifest:file-entry'); + $objWriter->writeAttribute('manifest:full-path', '/'); + $objWriter->writeAttribute('manifest:version', '1.2'); + $objWriter->writeAttribute('manifest:media-type', 'application/vnd.oasis.opendocument.spreadsheet'); + $objWriter->endElement(); + $objWriter->startElement('manifest:file-entry'); + $objWriter->writeAttribute('manifest:full-path', 'meta.xml'); + $objWriter->writeAttribute('manifest:media-type', 'text/xml'); + $objWriter->endElement(); + $objWriter->startElement('manifest:file-entry'); + $objWriter->writeAttribute('manifest:full-path', 'settings.xml'); + $objWriter->writeAttribute('manifest:media-type', 'text/xml'); + $objWriter->endElement(); + $objWriter->startElement('manifest:file-entry'); + $objWriter->writeAttribute('manifest:full-path', 'content.xml'); + $objWriter->writeAttribute('manifest:media-type', 'text/xml'); + $objWriter->endElement(); + $objWriter->startElement('manifest:file-entry'); + $objWriter->writeAttribute('manifest:full-path', 'Thumbnails/thumbnail.png'); + $objWriter->writeAttribute('manifest:media-type', 'image/png'); + $objWriter->endElement(); + $objWriter->startElement('manifest:file-entry'); + $objWriter->writeAttribute('manifest:full-path', 'styles.xml'); + $objWriter->writeAttribute('manifest:media-type', 'text/xml'); + $objWriter->endElement(); + $objWriter->endElement(); + + return $objWriter->getData(); + } +} diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Mimetype.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Mimetype.php new file mode 100644 index 00000000000..99ff638a9bb --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Mimetype.php @@ -0,0 +1,50 @@ + + */ +class PHPExcel_Writer_OpenDocument_Mimetype extends PHPExcel_Writer_OpenDocument_WriterPart +{ + /** + * Write mimetype to plain text format + * + * @param PHPExcel $pPHPExcel + * @return string XML Output + * @throws PHPExcel_Writer_Exception + */ + public function write(PHPExcel $pPHPExcel = null) + { + return 'application/vnd.oasis.opendocument.spreadsheet'; + } +} diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Settings.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Settings.php new file mode 100644 index 00000000000..557e748d419 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Settings.php @@ -0,0 +1,85 @@ + + */ +class PHPExcel_Writer_OpenDocument_Settings extends PHPExcel_Writer_OpenDocument_WriterPart +{ + /** + * Write settings.xml to XML format + * + * @param PHPExcel $pPHPExcel + * @return string XML Output + * @throws PHPExcel_Writer_Exception + */ + public function write(PHPExcel $pPHPExcel = null) + { + if (!$pPHPExcel) { + $pPHPExcel = $this->getParentWriter()->getPHPExcel(); + } + + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0', 'UTF-8'); + + // Settings + $objWriter->startElement('office:document-settings'); + $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); + $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); + $objWriter->writeAttribute('xmlns:config', 'urn:oasis:names:tc:opendocument:xmlns:config:1.0'); + $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); + $objWriter->writeAttribute('office:version', '1.2'); + + $objWriter->startElement('office:settings'); + $objWriter->startElement('config:config-item-set'); + $objWriter->writeAttribute('config:name', 'ooo:view-settings'); + $objWriter->startElement('config:config-item-map-indexed'); + $objWriter->writeAttribute('config:name', 'Views'); + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->startElement('config:config-item-set'); + $objWriter->writeAttribute('config:name', 'ooo:configuration-settings'); + $objWriter->endElement(); + $objWriter->endElement(); + $objWriter->endElement(); + + return $objWriter->getData(); + } +} diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Styles.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Styles.php new file mode 100644 index 00000000000..d886736328f --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Styles.php @@ -0,0 +1,101 @@ + + */ +class PHPExcel_Writer_OpenDocument_Styles extends PHPExcel_Writer_OpenDocument_WriterPart +{ + /** + * Write styles.xml to XML format + * + * @param PHPExcel $pPHPExcel + * @return string XML Output + * @throws PHPExcel_Writer_Exception + */ + public function write(PHPExcel $pPHPExcel = null) + { + if (!$pPHPExcel) { + $pPHPExcel = $this->getParentWriter()->getPHPExcel(); + } + + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0', 'UTF-8'); + + // Content + $objWriter->startElement('office:document-styles'); + $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); + $objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0'); + $objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0'); + $objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0'); + $objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'); + $objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'); + $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); + $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); + $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); + $objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0'); + $objWriter->writeAttribute('xmlns:presentation', 'urn:oasis:names:tc:opendocument:xmlns:presentation:1.0'); + $objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'); + $objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0'); + $objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0'); + $objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML'); + $objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0'); + $objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0'); + $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); + $objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer'); + $objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc'); + $objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events'); + $objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report'); + $objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2'); + $objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); + $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); + $objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table'); + $objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/'); + $objWriter->writeAttribute('office:version', '1.2'); + + $objWriter->writeElement('office:font-face-decls'); + $objWriter->writeElement('office:styles'); + $objWriter->writeElement('office:automatic-styles'); + $objWriter->writeElement('office:master-styles'); + $objWriter->endElement(); + + return $objWriter->getData(); + } +} diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Thumbnails.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Thumbnails.php new file mode 100644 index 00000000000..a7e85c45604 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/Thumbnails.php @@ -0,0 +1,50 @@ + + */ +class PHPExcel_Writer_OpenDocument_Thumbnails extends PHPExcel_Writer_OpenDocument_WriterPart +{ + /** + * Write Thumbnails/thumbnail.png to PNG format + * + * @param PHPExcel $pPHPExcel + * @return string XML Output + * @throws PHPExcel_Writer_Exception + */ + public function writeThumbnail(PHPExcel $pPHPExcel = null) + { + return ''; + } +} diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/WriterPart.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/WriterPart.php new file mode 100644 index 00000000000..e6e713a1b3a --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument/WriterPart.php @@ -0,0 +1,38 @@ +_renderer, $name), $arguments); } + /** + * {@inheritdoc} + */ + public function save($pFilename = null) + { + $this->_renderer->save($pFilename); + } } diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/PDF/DomPDF.php b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/PDF/DomPDF.php index 9ba97efcf22..01e4e0122a8 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/PDF/DomPDF.php +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Writer/PDF/DomPDF.php @@ -83,6 +83,9 @@ class PHPExcel_Writer_PDF_DomPDF extends PHPExcel_Writer_PDF_Core implements PHP $printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins(); } + + $orientation = ($orientation == 'L') ? 'landscape' : 'portrait'; + // Override Page Orientation if (!is_null($this->getOrientation())) { $orientation = ($this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT) @@ -98,7 +101,6 @@ class PHPExcel_Writer_PDF_DomPDF extends PHPExcel_Writer_PDF_Core implements PHP $paperSize = self::$_paperSizes[$printPaperSize]; } - $orientation = ($orientation == 'L') ? 'landscape' : 'portrait'; // Create PDF $pdf = new DOMPDF(); diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/01simple-download-ods.php b/htdocs/includes/phpoffice/phpexcel/Examples/01simple-download-ods.php new file mode 100644 index 00000000000..574fb0113eb --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Examples/01simple-download-ods.php @@ -0,0 +1,89 @@ +getProperties()->setCreator("Maarten Balliauw") + ->setLastModifiedBy("Maarten Balliauw") + ->setTitle("Office 2007 XLSX Test Document") + ->setSubject("Office 2007 XLSX Test Document") + ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") + ->setKeywords("office 2007 openxml php") + ->setCategory("Test result file"); + + +// Add some data +$objPHPExcel->setActiveSheetIndex(0) + ->setCellValue('A1', 'Hello') + ->setCellValue('B2', 'world!') + ->setCellValue('C1', 'Hello') + ->setCellValue('D2', 'world!'); + +// Miscellaneous glyphs, UTF-8 +$objPHPExcel->setActiveSheetIndex(0) + ->setCellValue('A4', 'Miscellaneous glyphs') + ->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç'); + +// Rename worksheet +$objPHPExcel->getActiveSheet()->setTitle('Simple'); + + +// Set active sheet index to the first sheet, so Excel opens this as the first sheet +$objPHPExcel->setActiveSheetIndex(0); + + +// Redirect output to a client’s web browser (OpenDocument) +header('Content-Type: application/vnd.oasis.opendocument.spreadsheet'); +header('Content-Disposition: attachment;filename="01simple.ods"'); +header('Cache-Control: max-age=0'); +// If you're serving to IE 9, then the following may be needed +header('Cache-Control: max-age=1'); + +// If you're serving to IE over SSL, then the following may be needed +header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past +header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified +header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1 +header ('Pragma: public'); // HTTP/1.0 + +$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'OpenDocument'); +$objWriter->save('php://output'); +exit; diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/05featuredemo.inc.php b/htdocs/includes/phpoffice/phpexcel/Examples/05featuredemo.inc.php index 00a8b8729b3..b543ca46bb7 100644 --- a/htdocs/includes/phpoffice/phpexcel/Examples/05featuredemo.inc.php +++ b/htdocs/includes/phpoffice/phpexcel/Examples/05featuredemo.inc.php @@ -267,12 +267,13 @@ echo date('H:i:s') , " Unprotect a cell" , EOL; $objPHPExcel->getActiveSheet()->getStyle('B1')->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED); // Add a hyperlink to the sheet -echo date('H:i:s') , " Add a hyperlink to the sheet" , EOL; +echo date('H:i:s') , " Add a hyperlink to an external website" , EOL; $objPHPExcel->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net'); $objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('http://www.phpexcel.net'); $objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setTooltip('Navigate to website'); $objPHPExcel->getActiveSheet()->getStyle('E26')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); +echo date('H:i:s') , " Add a hyperlink to another cell on a different worksheet within the workbook" , EOL; $objPHPExcel->getActiveSheet()->setCellValue('E27', 'Terms and conditions'); $objPHPExcel->getActiveSheet()->getCell('E27')->getHyperlink()->setUrl("sheet://'Terms and conditions'!A1"); $objPHPExcel->getActiveSheet()->getCell('E27')->getHyperlink()->setTooltip('Review terms and conditions'); diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/13calculation.php b/htdocs/includes/phpoffice/phpexcel/Examples/13calculation.php index db149489d59..01e63ea7751 100644 --- a/htdocs/includes/phpoffice/phpexcel/Examples/13calculation.php +++ b/htdocs/includes/phpoffice/phpexcel/Examples/13calculation.php @@ -34,6 +34,7 @@ date_default_timezone_set('Europe/London'); define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
'); date_default_timezone_set('Europe/London'); +mt_srand(1234567890); /** Include PHPExcel */ require_once dirname(__FILE__) . '/../Classes/PHPExcel.php'; diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-area.php b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-area.php index 52ee36b96b9..53fe52398d2 100644 --- a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-area.php +++ b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-area.php @@ -59,7 +59,7 @@ $objWorksheet->fromArray( // Number of datapoints in series // Data values // Data Marker -$dataseriesLabels = array( +$dataSeriesLabels = array( new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012 @@ -92,13 +92,13 @@ $series = new PHPExcel_Chart_DataSeries( PHPExcel_Chart_DataSeries::TYPE_AREACHART, // plotType PHPExcel_Chart_DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping range(0, count($dataSeriesValues)-1), // plotOrder - $dataseriesLabels, // plotLabel + $dataSeriesLabels, // plotLabel $xAxisTickValues, // plotCategory $dataSeriesValues // plotValues ); // Set the series in the plot area -$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series)); +$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series)); // Set the chart legend $legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_TOPRIGHT, NULL, false); @@ -111,7 +111,7 @@ $chart = new PHPExcel_Chart( 'chart1', // name $title, // title $legend, // legend - $plotarea, // plotArea + $plotArea, // plotArea true, // plotVisibleOnly 0, // displayBlanksAs NULL, // xAxisLabel diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-bar-stacked.php b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-bar-stacked.php index 755fa78ee87..cac29f29f55 100644 --- a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-bar-stacked.php +++ b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-bar-stacked.php @@ -59,7 +59,7 @@ $objWorksheet->fromArray( // Number of datapoints in series // Data values // Data Marker -$dataseriesLabels = array( +$dataSeriesLabels = array( new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012 @@ -92,7 +92,7 @@ $series = new PHPExcel_Chart_DataSeries( PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType PHPExcel_Chart_DataSeries::GROUPING_STACKED, // plotGrouping range(0, count($dataSeriesValues)-1), // plotOrder - $dataseriesLabels, // plotLabel + $dataSeriesLabels, // plotLabel $xAxisTickValues, // plotCategory $dataSeriesValues // plotValues ); @@ -101,7 +101,7 @@ $series = new PHPExcel_Chart_DataSeries( $series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_BAR); // Set the series in the plot area -$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series)); +$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series)); // Set the chart legend $legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false); @@ -114,7 +114,7 @@ $chart = new PHPExcel_Chart( 'chart1', // name $title, // title $legend, // legend - $plotarea, // plotArea + $plotArea, // plotArea true, // plotVisibleOnly 0, // displayBlanksAs NULL, // xAxisLabel diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-bar.php b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-bar.php index 84f8cf78c43..14fd5d485f9 100644 --- a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-bar.php +++ b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-bar.php @@ -59,7 +59,7 @@ $objWorksheet->fromArray( // Number of datapoints in series // Data values // Data Marker -$dataseriesLabels = array( +$dataSeriesLabels = array( new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012 @@ -92,7 +92,7 @@ $series = new PHPExcel_Chart_DataSeries( PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType PHPExcel_Chart_DataSeries::GROUPING_CLUSTERED, // plotGrouping range(0, count($dataSeriesValues)-1), // plotOrder - $dataseriesLabels, // plotLabel + $dataSeriesLabels, // plotLabel $xAxisTickValues, // plotCategory $dataSeriesValues // plotValues ); @@ -101,7 +101,7 @@ $series = new PHPExcel_Chart_DataSeries( $series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_BAR); // Set the series in the plot area -$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series)); +$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series)); // Set the chart legend $legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false); @@ -114,7 +114,7 @@ $chart = new PHPExcel_Chart( 'chart1', // name $title, // title $legend, // legend - $plotarea, // plotArea + $plotArea, // plotArea true, // plotVisibleOnly 0, // displayBlanksAs NULL, // xAxisLabel diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-column-2.php b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-column-2.php index 1d8d689bcdb..00bf0d71b50 100644 --- a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-column-2.php +++ b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-column-2.php @@ -67,7 +67,7 @@ $objWorksheet->fromArray( // Number of datapoints in series // Data values // Data Marker -$dataseriesLabels = array( +$dataSeriesLabels = array( new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 'Budget' new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 'Forecast' new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$E$1', NULL, 1), // 'Actual' @@ -100,7 +100,7 @@ $series = new PHPExcel_Chart_DataSeries( PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType PHPExcel_Chart_DataSeries::GROUPING_CLUSTERED, // plotGrouping range(0, count($dataSeriesValues)-1), // plotOrder - $dataseriesLabels, // plotLabel + $dataSeriesLabels, // plotLabel $xAxisTickValues, // plotCategory $dataSeriesValues // plotValues ); @@ -109,7 +109,7 @@ $series = new PHPExcel_Chart_DataSeries( $series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL); // Set the series in the plot area -$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series)); +$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series)); // Set the chart legend $legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_BOTTOM, NULL, false); @@ -123,7 +123,7 @@ $chart = new PHPExcel_Chart( 'chart1', // name $title, // title $legend, // legend - $plotarea, // plotArea + $plotArea, // plotArea true, // plotVisibleOnly 0, // displayBlanksAs $xAxisLabel, // xAxisLabel diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-column.php b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-column.php index eb3d7e21119..ae9c6185e26 100644 --- a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-column.php +++ b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-column.php @@ -59,7 +59,7 @@ $objWorksheet->fromArray( // Number of datapoints in series // Data values // Data Marker -$dataseriesLabels = array( +$dataSeriesLabels = array( new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012 @@ -92,7 +92,7 @@ $series = new PHPExcel_Chart_DataSeries( PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping range(0, count($dataSeriesValues)-1), // plotOrder - $dataseriesLabels, // plotLabel + $dataSeriesLabels, // plotLabel $xAxisTickValues, // plotCategory $dataSeriesValues // plotValues ); @@ -101,7 +101,7 @@ $series = new PHPExcel_Chart_DataSeries( $series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL); // Set the series in the plot area -$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series)); +$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series)); // Set the chart legend $legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false); @@ -114,7 +114,7 @@ $chart = new PHPExcel_Chart( 'chart1', // name $title, // title $legend, // legend - $plotarea, // plotArea + $plotArea, // plotArea true, // plotVisibleOnly 0, // displayBlanksAs NULL, // xAxisLabel diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-composite.php b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-composite.php index 0b512f09d4c..8ea72126ccb 100644 --- a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-composite.php +++ b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-composite.php @@ -68,13 +68,13 @@ $objWorksheet->fromArray( // Number of datapoints in series // Data values // Data Marker -$dataseriesLabels1 = array( +$dataSeriesLabels1 = array( new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // Temperature ); -$dataseriesLabels2 = array( +$dataSeriesLabels2 = array( new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // Rainfall ); -$dataseriesLabels3 = array( +$dataSeriesLabels3 = array( new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // Humidity ); @@ -106,7 +106,7 @@ $series1 = new PHPExcel_Chart_DataSeries( PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType PHPExcel_Chart_DataSeries::GROUPING_CLUSTERED, // plotGrouping range(0, count($dataSeriesValues1)-1), // plotOrder - $dataseriesLabels1, // plotLabel + $dataSeriesLabels1, // plotLabel $xAxisTickValues, // plotCategory $dataSeriesValues1 // plotValues ); @@ -131,7 +131,7 @@ $series2 = new PHPExcel_Chart_DataSeries( PHPExcel_Chart_DataSeries::TYPE_LINECHART, // plotType PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping range(0, count($dataSeriesValues2)-1), // plotOrder - $dataseriesLabels2, // plotLabel + $dataSeriesLabels2, // plotLabel NULL, // plotCategory $dataSeriesValues2 // plotValues ); @@ -153,14 +153,14 @@ $series3 = new PHPExcel_Chart_DataSeries( PHPExcel_Chart_DataSeries::TYPE_AREACHART, // plotType PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping range(0, count($dataSeriesValues2)-1), // plotOrder - $dataseriesLabels3, // plotLabel + $dataSeriesLabels3, // plotLabel NULL, // plotCategory $dataSeriesValues3 // plotValues ); // Set the series in the plot area -$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series1, $series2, $series3)); +$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series1, $series2, $series3)); // Set the chart legend $legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false); @@ -172,7 +172,7 @@ $chart = new PHPExcel_Chart( 'chart1', // name $title, // title $legend, // legend - $plotarea, // plotArea + $plotArea, // plotArea true, // plotVisibleOnly 0, // displayBlanksAs NULL, // xAxisLabel diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-line.php b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-line.php index dce75e06bbf..145ae72e8fd 100644 --- a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-line.php +++ b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-line.php @@ -59,7 +59,7 @@ $objWorksheet->fromArray( // Number of datapoints in series // Data values // Data Marker -$dataseriesLabels = array( +$dataSeriesLabels = array( new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012 @@ -92,13 +92,13 @@ $series = new PHPExcel_Chart_DataSeries( PHPExcel_Chart_DataSeries::TYPE_LINECHART, // plotType PHPExcel_Chart_DataSeries::GROUPING_STACKED, // plotGrouping range(0, count($dataSeriesValues)-1), // plotOrder - $dataseriesLabels, // plotLabel + $dataSeriesLabels, // plotLabel $xAxisTickValues, // plotCategory $dataSeriesValues // plotValues ); // Set the series in the plot area -$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series)); +$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series)); // Set the chart legend $legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_TOPRIGHT, NULL, false); @@ -111,7 +111,7 @@ $chart = new PHPExcel_Chart( 'chart1', // name $title, // title $legend, // legend - $plotarea, // plotArea + $plotArea, // plotArea true, // plotVisibleOnly 0, // displayBlanksAs NULL, // xAxisLabel diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-multiple-charts.php b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-multiple-charts.php index 7da2fa289a9..a95c2763323 100644 --- a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-multiple-charts.php +++ b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-multiple-charts.php @@ -60,7 +60,7 @@ $objWorksheet->fromArray( // Number of datapoints in series // Data values // Data Marker -$dataseriesLabels1 = array( +$dataSeriesLabels1 = array( new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012 @@ -93,13 +93,13 @@ $series1 = new PHPExcel_Chart_DataSeries( PHPExcel_Chart_DataSeries::TYPE_AREACHART, // plotType PHPExcel_Chart_DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping range(0, count($dataSeriesValues1)-1), // plotOrder - $dataseriesLabels1, // plotLabel + $dataSeriesLabels1, // plotLabel $xAxisTickValues1, // plotCategory $dataSeriesValues1 // plotValues ); // Set the series in the plot area -$plotarea1 = new PHPExcel_Chart_PlotArea(NULL, array($series1)); +$plotArea1 = new PHPExcel_Chart_PlotArea(NULL, array($series1)); // Set the chart legend $legend1 = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_TOPRIGHT, NULL, false); @@ -112,7 +112,7 @@ $chart1 = new PHPExcel_Chart( 'chart1', // name $title1, // title $legend1, // legend - $plotarea1, // plotArea + $plotArea1, // plotArea true, // plotVisibleOnly 0, // displayBlanksAs NULL, // xAxisLabel @@ -134,7 +134,7 @@ $objWorksheet->addChart($chart1); // Number of datapoints in series // Data values // Data Marker -$dataseriesLabels2 = array( +$dataSeriesLabels2 = array( new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012 @@ -167,7 +167,7 @@ $series2 = new PHPExcel_Chart_DataSeries( PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping range(0, count($dataSeriesValues2)-1), // plotOrder - $dataseriesLabels2, // plotLabel + $dataSeriesLabels2, // plotLabel $xAxisTickValues2, // plotCategory $dataSeriesValues2 // plotValues ); @@ -176,7 +176,7 @@ $series2 = new PHPExcel_Chart_DataSeries( $series2->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL); // Set the series in the plot area -$plotarea2 = new PHPExcel_Chart_PlotArea(NULL, array($series2)); +$plotArea2 = new PHPExcel_Chart_PlotArea(NULL, array($series2)); // Set the chart legend $legend2 = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false); @@ -189,7 +189,7 @@ $chart2 = new PHPExcel_Chart( 'chart2', // name $title2, // title $legend2, // legend - $plotarea2, // plotArea + $plotArea2, // plotArea true, // plotVisibleOnly 0, // displayBlanksAs NULL, // xAxisLabel diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-pie.php b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-pie.php index 1a4f1df4a25..5af02905bfc 100644 --- a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-pie.php +++ b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-pie.php @@ -60,7 +60,7 @@ $objWorksheet->fromArray( // Number of datapoints in series // Data values // Data Marker -$dataseriesLabels1 = array( +$dataSeriesLabels1 = array( new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 ); // Set the X-Axis Labels @@ -87,9 +87,9 @@ $dataSeriesValues1 = array( // Build the dataseries $series1 = new PHPExcel_Chart_DataSeries( PHPExcel_Chart_DataSeries::TYPE_PIECHART, // plotType - PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping + NULL, // plotGrouping (Pie charts don't have any grouping) range(0, count($dataSeriesValues1)-1), // plotOrder - $dataseriesLabels1, // plotLabel + $dataSeriesLabels1, // plotLabel $xAxisTickValues1, // plotCategory $dataSeriesValues1 // plotValues ); @@ -100,7 +100,7 @@ $layout1->setShowVal(TRUE); $layout1->setShowPercent(TRUE); // Set the series in the plot area -$plotarea1 = new PHPExcel_Chart_PlotArea($layout1, array($series1)); +$plotArea1 = new PHPExcel_Chart_PlotArea($layout1, array($series1)); // Set the chart legend $legend1 = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false); @@ -112,7 +112,7 @@ $chart1 = new PHPExcel_Chart( 'chart1', // name $title1, // title $legend1, // legend - $plotarea1, // plotArea + $plotArea1, // plotArea true, // plotVisibleOnly 0, // displayBlanksAs NULL, // xAxisLabel @@ -134,7 +134,7 @@ $objWorksheet->addChart($chart1); // Number of datapoints in series // Data values // Data Marker -$dataseriesLabels2 = array( +$dataSeriesLabels2 = array( new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 ); // Set the X-Axis Labels @@ -161,9 +161,9 @@ $dataSeriesValues2 = array( // Build the dataseries $series2 = new PHPExcel_Chart_DataSeries( PHPExcel_Chart_DataSeries::TYPE_DONUTCHART, // plotType - PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping + NULL, // plotGrouping (Donut charts don't have any grouping) range(0, count($dataSeriesValues2)-1), // plotOrder - $dataseriesLabels2, // plotLabel + $dataSeriesLabels2, // plotLabel $xAxisTickValues2, // plotCategory $dataSeriesValues2 // plotValues ); @@ -174,7 +174,7 @@ $layout2->setShowVal(TRUE); $layout2->setShowCatName(TRUE); // Set the series in the plot area -$plotarea2 = new PHPExcel_Chart_PlotArea($layout2, array($series2)); +$plotArea2 = new PHPExcel_Chart_PlotArea($layout2, array($series2)); $title2 = new PHPExcel_Chart_Title('Test Donut Chart'); @@ -184,7 +184,7 @@ $chart2 = new PHPExcel_Chart( 'chart2', // name $title2, // title NULL, // legend - $plotarea2, // plotArea + $plotArea2, // plotArea true, // plotVisibleOnly 0, // displayBlanksAs NULL, // xAxisLabel diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-radar.php b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-radar.php index 29fb2200ff5..b8b427f3b12 100644 --- a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-radar.php +++ b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-radar.php @@ -68,7 +68,7 @@ $objWorksheet->fromArray( // Number of datapoints in series // Data values // Data Marker -$dataseriesLabels = array( +$dataSeriesLabels = array( new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012 ); @@ -98,9 +98,9 @@ $dataSeriesValues = array( // Build the dataseries $series = new PHPExcel_Chart_DataSeries( PHPExcel_Chart_DataSeries::TYPE_RADARCHART, // plotType - NULL, // plotGrouping + NULL, // plotGrouping (Radar charts don't have any grouping) range(0, count($dataSeriesValues)-1), // plotOrder - $dataseriesLabels, // plotLabel + $dataSeriesLabels, // plotLabel $xAxisTickValues, // plotCategory $dataSeriesValues, // plotValues NULL, // smooth line @@ -111,7 +111,7 @@ $series = new PHPExcel_Chart_DataSeries( $layout = new PHPExcel_Chart_Layout(); // Set the series in the plot area -$plotarea = new PHPExcel_Chart_PlotArea($layout, array($series)); +$plotArea = new PHPExcel_Chart_PlotArea($layout, array($series)); // Set the chart legend $legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false); @@ -123,7 +123,7 @@ $chart = new PHPExcel_Chart( 'chart1', // name $title, // title $legend, // legend - $plotarea, // plotArea + $plotArea, // plotArea true, // plotVisibleOnly 0, // displayBlanksAs NULL, // xAxisLabel diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-scatter.php b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-scatter.php index 53851ad46c0..250c61d7e4c 100644 --- a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-scatter.php +++ b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-scatter.php @@ -59,7 +59,7 @@ $objWorksheet->fromArray( // Number of datapoints in series // Data values // Data Marker -$dataseriesLabels = array( +$dataSeriesLabels = array( new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012 @@ -86,7 +86,7 @@ $series = new PHPExcel_Chart_DataSeries( PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART, // plotType NULL, // plotGrouping (Scatter charts don't have any grouping) range(0, count($dataSeriesValues)-1), // plotOrder - $dataseriesLabels, // plotLabel + $dataSeriesLabels, // plotLabel $xAxisTickValues, // plotCategory $dataSeriesValues, // plotValues NULL, // smooth line @@ -94,7 +94,7 @@ $series = new PHPExcel_Chart_DataSeries( ); // Set the series in the plot area -$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series)); +$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series)); // Set the chart legend $legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_TOPRIGHT, NULL, false); @@ -107,7 +107,7 @@ $chart = new PHPExcel_Chart( 'chart1', // name $title, // title $legend, // legend - $plotarea, // plotArea + $plotArea, // plotArea true, // plotVisibleOnly 0, // displayBlanksAs NULL, // xAxisLabel diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-stock.php b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-stock.php index dfc8d5cdd97..b38fd518153 100644 --- a/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-stock.php +++ b/htdocs/includes/phpoffice/phpexcel/Examples/33chartcreate-stock.php @@ -62,7 +62,7 @@ $objWorksheet->getStyle('B2:E6')->getNumberFormat()->setFormatCode(PHPExcel_Styl // Number of datapoints in series // Data values // Data Marker -$dataseriesLabels = array( +$dataSeriesLabels = array( new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), //Max / Open new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), //Min / Close new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), //Min Threshold / Min @@ -97,13 +97,13 @@ $series = new PHPExcel_Chart_DataSeries( PHPExcel_Chart_DataSeries::TYPE_STOCKCHART, // plotType null, // plotGrouping - if we set this to not null, then xlsx throws error range(0, count($dataSeriesValues)-1), // plotOrder - $dataseriesLabels, // plotLabel + $dataSeriesLabels, // plotLabel $xAxisTickValues, // plotCategory $dataSeriesValues // plotValues ); // Set the series in the plot area -$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series)); +$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series)); // Set the chart legend $legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false); @@ -116,7 +116,7 @@ $chart = new PHPExcel_Chart( 'stock-chart', // name $title, // title $legend, // legend - $plotarea, // plotArea + $plotArea, // plotArea true, // plotVisibleOnly 0, // displayBlanksAs $xAxisLabel, // xAxisLabel diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/34chartupdate.php b/htdocs/includes/phpoffice/phpexcel/Examples/34chartupdate.php index 84f8a922174..cb586a31867 100644 --- a/htdocs/includes/phpoffice/phpexcel/Examples/34chartupdate.php +++ b/htdocs/includes/phpoffice/phpexcel/Examples/34chartupdate.php @@ -37,7 +37,7 @@ date_default_timezone_set('Europe/London'); */ /** PHPExcel */ -include '../Classes/PHPExcel.php'; +require_once dirname(__FILE__) . '/../Classes/PHPExcel.php'; if (!file_exists("33chartcreate-bar.xlsx")) { exit("Please run 33chartcreate-bar.php first." . EOL); diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/35chartrender.php b/htdocs/includes/phpoffice/phpexcel/Examples/35chartrender.php index 710cddb49a5..f0e79636b11 100644 --- a/htdocs/includes/phpoffice/phpexcel/Examples/35chartrender.php +++ b/htdocs/includes/phpoffice/phpexcel/Examples/35chartrender.php @@ -46,7 +46,7 @@ include 'PHPExcel/IOFactory.php'; // Change these values to select the Rendering library that you wish to use // and its directory location on your server $rendererName = PHPExcel_Settings::CHART_RENDERER_JPGRAPH; -$rendererLibrary = 'jpgraph3.5.0b1/src'; +$rendererLibrary = 'jpgraph3.5.0b1/src/'; $rendererLibraryPath = '/php/libraries/Charts/' . $rendererLibrary; diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/39dropdown.php b/htdocs/includes/phpoffice/phpexcel/Examples/39dropdown.php new file mode 100644 index 00000000000..5dadc09922f --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Examples/39dropdown.php @@ -0,0 +1,175 @@ +'); + +/** Include PHPExcel */ +require_once dirname(__FILE__) . '/../Classes/PHPExcel.php'; + + +// Create new PHPExcel object +echo date('H:i:s') , " Create new PHPExcel object" , EOL; +$objPHPExcel = new PHPExcel(); + +// Set document properties +echo date('H:i:s') , " Set document properties" , EOL; +$objPHPExcel->getProperties() + ->setCreator("PHPOffice") + ->setLastModifiedBy("PHPOffice") + ->setTitle("PHPExcel Test Document") + ->setSubject("PHPExcel Test Document") + ->setDescription("Test document for PHPExcel, generated using PHP classes.") + ->setKeywords("Office PHPExcel php") + ->setCategory("Test result file"); + + +function transpose($value) { + return array($value); +} + +// Add some data +$continentColumn = 'D'; +$column = 'F'; + +// Set data for dropdowns +foreach(glob('./data/continents/*') as $key => $filename) { + $continent = pathinfo($filename, PATHINFO_FILENAME); + echo "Loading $continent", EOL; + $continent = str_replace(' ','_',$continent); + $countries = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); + $countryCount = count($countries); + + // Transpose $countries from a row to a column array + $countries = array_map('transpose', $countries); + $objPHPExcel->getActiveSheet() + ->fromArray($countries, null, $column . '1'); + $objPHPExcel->addNamedRange( + new PHPExcel_NamedRange( + $continent, + $objPHPExcel->getActiveSheet(), $column . '1:' . $column . $countryCount + ) + ); + $objPHPExcel->getActiveSheet() + ->getColumnDimension($column) + ->setVisible(false); + + $objPHPExcel->getActiveSheet() + ->setCellValue($continentColumn . ($key+1), $continent); + + ++$column; +} + +// Hide the dropdown data +$objPHPExcel->getActiveSheet() + ->getColumnDimension($continentColumn) + ->setVisible(false); + +$objPHPExcel->addNamedRange( + new PHPExcel_NamedRange( + 'Continents', + $objPHPExcel->getActiveSheet(), $continentColumn . '1:' . $continentColumn . ($key+1) + ) +); + + +// Set selection cells +$objPHPExcel->getActiveSheet() + ->setCellValue('A1', 'Continent:'); +$objPHPExcel->getActiveSheet() + ->setCellValue('B1', 'Select continent'); +$objPHPExcel->getActiveSheet() + ->setCellValue('B3', '=' . $column . 1); +$objPHPExcel->getActiveSheet() + ->setCellValue('B3', 'Select country'); +$objPHPExcel->getActiveSheet() + ->getStyle('A1:A3') + ->getFont()->setBold(true); + +// Set linked validators +$objValidation = $objPHPExcel->getActiveSheet() + ->getCell('B1') + ->getDataValidation(); +$objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_LIST ) + ->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_INFORMATION ) + ->setAllowBlank(false) + ->setShowInputMessage(true) + ->setShowErrorMessage(true) + ->setShowDropDown(true) + ->setErrorTitle('Input error') + ->setError('Continent is not in the list.') + ->setPromptTitle('Pick from the list') + ->setPrompt('Please pick a continent from the drop-down list.') + ->setFormula1('=Continents'); + +$objPHPExcel->getActiveSheet() + ->setCellValue('A3', 'Country:'); +$objPHPExcel->getActiveSheet() + ->getStyle('A3') + ->getFont()->setBold(true); + +$objValidation = $objPHPExcel->getActiveSheet() + ->getCell('B3') + ->getDataValidation(); +$objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_LIST ) + ->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_INFORMATION ) + ->setAllowBlank(false) + ->setShowInputMessage(true) + ->setShowErrorMessage(true) + ->setShowDropDown(true) + ->setErrorTitle('Input error') + ->setError('Country is not in the list.') + ->setPromptTitle('Pick from the list') + ->setPrompt('Please pick a country from the drop-down list.') + ->setFormula1('=INDIRECT($B$1)'); + + +$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(12); +$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(30); + + +// Set active sheet index to the first sheet, so Excel opens this as the first sheet +$objPHPExcel->setActiveSheetIndex(0); + +// Save Excel 2007 file +// This linked validation list method only seems to work for Excel2007, not for Excel5 +echo date('H:i:s') , " Write to Excel2007 format" , EOL; +$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); +$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); +echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; + +// Echo memory peak usage +echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; + +// Echo done +echo date('H:i:s') , " Done writing files" , EOL; +echo 'Files have been created in ' , getcwd() , EOL; diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/41password.php b/htdocs/includes/phpoffice/phpexcel/Examples/41password.php new file mode 100644 index 00000000000..7b03e4f9a1f --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Examples/41password.php @@ -0,0 +1,84 @@ +'); + +date_default_timezone_set('Europe/London'); + +include "05featuredemo.inc.php"; + +/** Include PHPExcel_IOFactory */ +require_once dirname(__FILE__) . '/../Classes/PHPExcel/IOFactory.php'; + + +// Set password against the spreadsheet file +$objPHPExcel->getSecurity()->setLockWindows(true); +$objPHPExcel->getSecurity()->setLockStructure(true); +$objPHPExcel->getSecurity()->setWorkbookPassword('secret'); + + +// Save Excel 2007 file +echo date('H:i:s') , " Write to Excel2007 format" , EOL; +$callStartTime = microtime(true); + +$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); +$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); +$callEndTime = microtime(true); +$callTime = $callEndTime - $callStartTime; + +echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; +echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; +// Echo memory usage +echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; + + +// Save Excel 95 file +echo date('H:i:s') , " Write to Excel5 format" , EOL; +$callStartTime = microtime(true); + +$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); +$objWriter->save(str_replace('.php', '.xls', __FILE__)); +$callEndTime = microtime(true); +$callTime = $callEndTime - $callStartTime; + +echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; +echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; +// Echo memory usage +echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; + + +// Echo memory peak usage +echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; + +// Echo done +echo date('H:i:s') , " Done writing files" , EOL; +echo 'Files have been created in ' , getcwd() , EOL; diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/42richText.php b/htdocs/includes/phpoffice/phpexcel/Examples/42richText.php new file mode 100644 index 00000000000..4e99b853544 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Examples/42richText.php @@ -0,0 +1,159 @@ +'); + +/** Include PHPExcel */ +require_once dirname(__FILE__) . '/../Classes/PHPExcel.php'; + + +// Create new PHPExcel object +echo date('H:i:s') , " Create new PHPExcel object" , EOL; +$objPHPExcel = new PHPExcel(); + +// Set document properties +echo date('H:i:s') , " Set document properties" , EOL; +$objPHPExcel->getProperties()->setCreator("Maarten Balliauw") + ->setLastModifiedBy("Maarten Balliauw") + ->setTitle("PHPExcel Test Document") + ->setSubject("PHPExcel Test Document") + ->setDescription("Test document for PHPExcel, generated using PHP classes.") + ->setKeywords("office PHPExcel php") + ->setCategory("Test result file"); + + +// Add some data +echo date('H:i:s') , " Add some data" , EOL; + +$html1=' +

My very first example of rich text
generated from html markup

+

+ +This block contains an italicized word; +while this block uses an underline. + +

+

+I want to eat healthy foodpizza. + +'; + +$html2='

+ + 100°C is a hot temperature + +
+ + 10°F is cold + +

'; + +$html3='23 equals 8'; + +$html4='H2SO4 is the chemical formula for Sulphuric acid'; + + +$wizard = new PHPExcel_Helper_HTML; +$richText = $wizard->toRichTextObject($html1); + +$objPHPExcel->setActiveSheetIndex(0) + ->setCellValue('A1', $richText); + +$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(48); +$objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(-1); +$objPHPExcel->getActiveSheet()->getStyle('A1') + ->getAlignment() + ->setWrapText(true); + +$richText = $wizard->toRichTextObject($html2); + +$objPHPExcel->setActiveSheetIndex(0) + ->setCellValue('A2', $richText); + +$objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(-1); +$objPHPExcel->getActiveSheet()->getStyle('A2') + ->getAlignment() + ->setWrapText(true); + +$objPHPExcel->setActiveSheetIndex(0) + ->setCellValue('A3', $wizard->toRichTextObject($html3)); + +$objPHPExcel->setActiveSheetIndex(0) + ->setCellValue('A4', $wizard->toRichTextObject($html4)); + + +// Rename worksheet +echo date('H:i:s') , " Rename worksheet" , EOL; +$objPHPExcel->getActiveSheet()->setTitle('Simple'); + + +// Set active sheet index to the first sheet, so Excel opens this as the first sheet +$objPHPExcel->setActiveSheetIndex(0); + + +// Save Excel 2007 file +echo date('H:i:s') , " Write to Excel2007 format" , EOL; +$callStartTime = microtime(true); + +$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); +$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); +$callEndTime = microtime(true); +$callTime = $callEndTime - $callStartTime; + +echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; +echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; +// Echo memory usage +echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; + + +// Save Excel 95 file +echo date('H:i:s') , " Write to Excel5 format" , EOL; +$callStartTime = microtime(true); + +$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); +$objWriter->save(str_replace('.php', '.xls', __FILE__)); +$callEndTime = microtime(true); +$callTime = $callEndTime - $callStartTime; + +echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; +echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL; +// Echo memory usage +echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL; + + +// Echo memory peak usage +echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; + +// Echo done +echo date('H:i:s') , " Done writing files" , EOL; +echo 'Files have been created in ' , getcwd() , EOL; diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/data/continents/Africa.txt b/htdocs/includes/phpoffice/phpexcel/Examples/data/continents/Africa.txt new file mode 100644 index 00000000000..407fa769aa3 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Examples/data/continents/Africa.txt @@ -0,0 +1,54 @@ +Algeria +Angola +Benin +Botswana +Burkina +Burundi +Cameroon +Cape Verde +Central African Republic +Chad +Comoros +Congo +Congo, Democratic Republic of +Djibouti +Egypt +Equatorial Guinea +Eritrea +Ethiopia +Gabon +Gambia +Ghana +Guinea +Guinea-Bissau +Ivory Coast +Kenya +Lesotho +Liberia +Libya +Madagascar +Malawi +Mali +Mauritania +Mauritius +Morocco +Mozambique +Namibia +Niger +Nigeria +Rwanda +Sao Tome and Principe +Senegal +Seychelles +Sierra Leone +Somalia +South Africa +South Sudan +Sudan +Swaziland +Tanzania +Togo +Tunisia +Uganda +Zambia +Zimbabwe diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/data/continents/Asia.txt b/htdocs/includes/phpoffice/phpexcel/Examples/data/continents/Asia.txt new file mode 100644 index 00000000000..9ce006c53c8 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Examples/data/continents/Asia.txt @@ -0,0 +1,44 @@ +Afghanistan +Bahrain +Bangladesh +Bhutan +Brunei +Burma (Myanmar) +Cambodia +China +East Timor +India +Indonesia +Iran +Iraq +Israel +Japan +Jordan +Kazakhstan +Korea, North +Korea, South +Kuwait +Kyrgyzstan +Laos +Lebanon +Malaysia +Maldives +Mongolia +Nepal +Oman +Pakistan +Philippines +Qatar +Russian Federation +Saudi Arabia +Singapore +Sri Lanka +Syria +Tajikistan +Thailand +Turkey +Turkmenistan +United Arab Emirates +Uzbekistan +Vietnam +Yemen diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/data/continents/Europe.txt b/htdocs/includes/phpoffice/phpexcel/Examples/data/continents/Europe.txt new file mode 100644 index 00000000000..70c11607ab9 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Examples/data/continents/Europe.txt @@ -0,0 +1,47 @@ +Albania +Andorra +Armenia +Austria +Azerbaijan +Belarus +Belgium +Bosnia and Herzegovina +Bulgaria +Croatia +Cyprus +Czech Republic +Denmark +Estonia +Finland +France +Georgia +Germany +Greece +Hungary +Iceland +Ireland +Italy +Latvia +Liechtenstein +Lithuania +Luxembourg +Macedonia +Malta +Moldova +Monaco +Montenegro +Netherlands +Norway +Poland +Portugal +Romania +San Marino +Serbia +Slovakia +Slovenia +Spain +Sweden +Switzerland +Ukraine +United Kingdom +Vatican City diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/data/continents/North America.txt b/htdocs/includes/phpoffice/phpexcel/Examples/data/continents/North America.txt new file mode 100644 index 00000000000..5881ae132ab --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Examples/data/continents/North America.txt @@ -0,0 +1,23 @@ +Antigua and Barbuda +Bahamas +Barbados +Belize +Canada +Costa Rica +Cuba +Dominica +Dominican Republic +El Salvador +Grenada +Guatemala +Haiti +Honduras +Jamaica +Mexico +Nicaragua +Panama +Saint Kitts and Nevis +Saint Lucia +Saint Vincent and the Grenadines +Trinidad and Tobago +United States diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/data/continents/Oceania.txt b/htdocs/includes/phpoffice/phpexcel/Examples/data/continents/Oceania.txt new file mode 100644 index 00000000000..cbdc896c1ca --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Examples/data/continents/Oceania.txt @@ -0,0 +1,14 @@ +Australia +Fiji +Kiribati +Marshall Islands +Micronesia +Nauru +New Zealand +Palau +Papua New Guinea +Samoa +Solomon Islands +Tonga +Tuvalu +Vanuatu diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/data/continents/South America.txt b/htdocs/includes/phpoffice/phpexcel/Examples/data/continents/South America.txt new file mode 100644 index 00000000000..777ffbfb94b --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/Examples/data/continents/South America.txt @@ -0,0 +1,12 @@ +Argentina +Bolivia +Brazil +Chile +Colombia +Ecuador +Guyana +Paraguay +Peru +Suriname +Uruguay +Venezuela diff --git a/htdocs/includes/phpoffice/phpexcel/Examples/runall.php b/htdocs/includes/phpoffice/phpexcel/Examples/runall.php index 395e83e248b..b2af1ccd0be 100644 --- a/htdocs/includes/phpoffice/phpexcel/Examples/runall.php +++ b/htdocs/includes/phpoffice/phpexcel/Examples/runall.php @@ -59,6 +59,7 @@ $aTests = array( , '11documentsecurity-xls.php' , '12cellProtection.php' , '13calculation.php' + , '13calculationCyclicFormulae.php' , '14excel5.php' , '15datavalidation.php' , '15datavalidation-xls.php' @@ -97,7 +98,10 @@ $aTests = array( , '36chartreadwritePDF.php' , '37page_layout_view.php' , '38cloneWorksheet.php' + , '39dropdown.php' , '40duplicateStyle.php' + , '41password.php' + , '42richText.php' , 'OOCalcReader.php' , 'OOCalcReaderPCLZip.php' , 'SylkReader.php' @@ -106,7 +110,7 @@ $aTests = array( , 'GnumericReader.php' ); -// First, clear all results +// First, clear all previous run results foreach ($aTests as $sTest) { @unlink( str_replace('.php', '.xls', $sTest) ); @unlink( str_replace('.php', '.xlsx', $sTest) ); diff --git a/htdocs/includes/phpoffice/phpexcel/changelog.txt b/htdocs/includes/phpoffice/phpexcel/changelog.txt index 3177106f5ea..29377308d80 100644 --- a/htdocs/includes/phpoffice/phpexcel/changelog.txt +++ b/htdocs/includes/phpoffice/phpexcel/changelog.txt @@ -19,11 +19,49 @@ * * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL -* @version ##VERSION##, ##DATE## +* @version 1.8.1, 2015-04-30 ************************************************************************************** +2015-04-30 (v1.8.1): +- Bugfix: (goncons) Work Item GH-397 - Fix for Writing an Open Document cell with non-numeric formula +- Bugfix: (sarciszewski) Work Item GH-329 - Avoid potential divide by zero in basedrawing +- Bugfix: (ymaerschalck) Work Item GH-405 - XML External Entity (XXE) Processing, different behaviour between simplexml_load_string() and simplexml_load_file(). +- Bugfix: (MBaker) - Fix to ensure that current cell is maintained when executing formula calculations +- Bugfix: (MBaker) Work Item GH-350 - Keep/set the value on Reader _loadSheetsOnly as NULL, courtesy of Restless-ET +- Bugfix: (MBaker) Work Item CP18105 - Loading an Excel 2007 spreadsheet throws an "Autofilter must be set on a range of cells" exception +- Bugfix: (MBaker) Work Item GH-388 - Fix to autoloader registration for backward compatibility with PHP 5.2.0 not accepting the prepend flag +- Bugfix: (MBaker) Work Item GH-384 - DOM loadHTMLFile() failing with options flags when using PHP < 5.4.0 +- Bugfix: (MBaker) - Fix for percentage operator in formulae for BIFF Writer +- Bugfix: (MBaker) - Fix to getStyle() call for cell object +- Bugfix: (MBaker) - Discard Autofilters in Excel2007 Reader when filter range isn't a valid range +- Bugfix: (frozenstupidity) Work Item GH-423 - Fix invalid NA return in VLOOKUP +- Bugfix: (wiseloren) Work Item CP21454 - "No Impact" conditional formatting fix for NumberFormat +- Bugfix: (bobwitlox) Work Item GH-467 - Bug in Excel2003XML reader, parsing merged cells +- Bugfix: (MBaker) Work Item GH-302 - Fix for CEIL() and FLOOR() when number argument is zero +- Bugfix: (MBaker) - Remove cells cleanly when calling RemoveRow() or RemoveColumn() +- General: (MBaker) - Small performance improvement for autosize columns +- General: (frost-nzcr4) Work Item GH-379 - Change the getter/setter for zeroHeight to camel case +- General: (MBaker) Work Item GH-394 - DefaultValueBinder is too much aggressive when converting string to numeric +- General: (MBaker) - Default precalculate formulas to false for writers +- General: (MBaker) - Set default Cyclic Reference behaviour to 1 to eliminate exception when using a single cyclic iteration in formulae +- General: (MBaker) Work Item GH-396 - Some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE +- Feature: (WiktrzGE) Work Item GH-404 - Methods to manage most of the existing options for Chart Axis, Major Grid-lines and Minor Grid-lines +- Feature: (frost-nzcr4) Work Item GH-403 - ODS read/write comments in the cell +- Feature: (CQD) Work Item GH-389 - Additional Mac CJK codepage definitions +- Feature: (bolovincev) Work Item GH-269 - Update Worksheet.php getStyleByColumnAndRow() to allow a range of cells rather than just a single cell +- Feature: (MBaker) - New methods added for testing cell status within merge groups +- Feature: (cifren/MBaker) Work Item GH-205 - Handling merge cells in HTML Reader +- Feature: (MBaker) - Helper to convert basic HTML markup to a Rich Text object +- Feature: (MBaker) - Improved Iterators + New Column Iterator + Support for row and column ranges + Improved handling for next/prev +- Security: (MBaker) - XML filescan in XML-based Readers to prevent XML Entity Expansion (XEE) + (see http://projects.webappsec.org/w/page/13247002/XML%20Entity%20Expansion for an explanation of XEE injection) attacks + Reference CVE-2015-3542 - Identification of problem courtesy of Dawid Golunski (Pentest Ltd.) -2014-03-02 (v1.8.0): + + 2014-03-02 (v1.8.0): - Bugfix: (MBaker) Work item CP19830 - Undefined variable: fileHandle in CSV Reader - Bugfix: (MBaker) Work item CP19968 - Out of memory in style/supervisor.php - Bugfix: (MBaker) - Style error with merged cells in PDF Writer diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/DateTimeTest.php b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/DateTimeTest.php index 57692a34167..d4bdc5abff2 100644 --- a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/DateTimeTest.php +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/DateTimeTest.php @@ -13,6 +13,8 @@ class DateTimeTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + + PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL); } /** diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/EngineeringTest.php b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/EngineeringTest.php index 647da09f40c..1f511ffacc0 100644 --- a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/EngineeringTest.php +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/EngineeringTest.php @@ -17,6 +17,8 @@ class EngineeringTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + + PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL); } /** diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/FinancialTest.php b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/FinancialTest.php index b27a6a7dfa7..f5689c95048 100644 --- a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/FinancialTest.php +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/FinancialTest.php @@ -13,6 +13,8 @@ class FinancialTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + + PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL); } /** diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/FunctionsTest.php b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/FunctionsTest.php index 5e6ef962a42..013332940ff 100644 --- a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/FunctionsTest.php +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/FunctionsTest.php @@ -13,6 +13,8 @@ class FunctionsTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + + PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL); } public function testDUMMY() diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/LogicalTest.php b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/LogicalTest.php index 46749d12c51..cc8f8b33383 100644 --- a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/LogicalTest.php +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/LogicalTest.php @@ -13,6 +13,8 @@ class LogicalTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + + PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL); } public function testTRUE() diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/LookupRefTest.php b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/LookupRefTest.php index 454422a1534..6450b082244 100644 --- a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/LookupRefTest.php +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/LookupRefTest.php @@ -13,6 +13,8 @@ class LookupRefTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + + PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL); } /** diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/MathTrigTest.php b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/MathTrigTest.php index e3d8c9d985b..0059ed08e6c 100644 --- a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/MathTrigTest.php +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/MathTrigTest.php @@ -13,6 +13,8 @@ class MathTrigTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + + PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL); } /** diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/TextDataTest.php b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/TextDataTest.php index 717e8fefbd0..4b1caf5179d 100644 --- a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/TextDataTest.php +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/TextDataTest.php @@ -13,6 +13,8 @@ class TextDataTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + + PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL); } /** @@ -340,4 +342,24 @@ class TextDataTest extends PHPUnit_Framework_TestCase return new testDataFileIterator('rawTestData/Calculation/TextData/TEXT.data'); } + /** + * @dataProvider providerVALUE + */ + public function testVALUE() + { + call_user_func(array('PHPExcel_Shared_String','setDecimalSeparator'),'.'); + call_user_func(array('PHPExcel_Shared_String','setThousandsSeparator'),' '); + call_user_func(array('PHPExcel_Shared_String','setCurrencyCode'),'$'); + + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Calculation_TextData','VALUE'),$args); + $this->assertEquals($expectedResult, $result, NULL, 1E-8); + } + + public function providerVALUE() + { + return new testDataFileIterator('rawTestData/Calculation/TextData/VALUE.data'); + } + } diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/CalculationTest.php b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/CalculationTest.php index 8f8ce7e0a77..1de827ca815 100644 --- a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/CalculationTest.php +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/CalculationTest.php @@ -11,6 +11,8 @@ class CalculationTest extends PHPUnit_Framework_TestCase define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); } require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + + PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL); } /** diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Cell/DefaultValueBinderTest.php b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Cell/DefaultValueBinderTest.php new file mode 100644 index 00000000000..1c74d96f6f8 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Cell/DefaultValueBinderTest.php @@ -0,0 +1,85 @@ +cellStub = $this->getMockBuilder('PHPExcel_Cell') + ->disableOriginalConstructor() + ->getMock(); + // Configure the stub. + $this->cellStub->expects($this->any()) + ->method('setValueExplicit') + ->will($this->returnValue(true)); + + } + + /** + * @dataProvider binderProvider + */ + public function testBindValue($value) + { + $this->createCellStub(); + $binder = new PHPExcel_Cell_DefaultValueBinder(); + $result = $binder->bindValue($this->cellStub, $value); + $this->assertTrue($result); + } + + public function binderProvider() + { + return array( + array(null), + array(''), + array('ABC'), + array('=SUM(A1:B2)'), + array(true), + array(false), + array(123), + array(-123.456), + array('123'), + array('-123.456'), + array('#REF!'), + array(new DateTime()), + ); + } + + /** + * @dataProvider providerDataTypeForValue + */ + public function testDataTypeForValue() + { + $args = func_get_args(); + $expectedResult = array_pop($args); + $result = call_user_func_array(array('PHPExcel_Cell_DefaultValueBinder','dataTypeForValue'), $args); + $this->assertEquals($expectedResult, $result); + } + + public function providerDataTypeForValue() + { + return new testDataFileIterator('rawTestData/Cell/DefaultValueBinder.data'); + } + + public function testDataTypeForRichTextObject() + { + $objRichText = new PHPExcel_RichText(); + $objRichText->createText('Hello World'); + + $expectedResult = PHPExcel_Cell_DataType::TYPE_INLINE; + $result = call_user_func(array('PHPExcel_Cell_DefaultValueBinder','dataTypeForValue'), $objRichText); + $this->assertEquals($expectedResult, $result); + } +} diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Reader/XEEValidatorTest.php b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Reader/XEEValidatorTest.php new file mode 100644 index 00000000000..f635dbb8764 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Reader/XEEValidatorTest.php @@ -0,0 +1,55 @@ +getMockForAbstractClass('PHPExcel_Reader_Abstract'); + $expectedResult = 'FAILURE: Should throw an Exception rather than return a value'; + $result = $reader->securityScanFile($filename); + $this->assertEquals($expectedResult, $result); + } + + public function providerInvalidXML() + { + $tests = []; + foreach(glob('rawTestData/Reader/XEETestInvalid*.xml') as $file) { + $tests[] = [realpath($file), true]; + } + return $tests; + } + + /** + * @dataProvider providerValidXML + */ + public function testValidXML($filename, $expectedResult) + { + $reader = $this->getMockForAbstractClass('PHPExcel_Reader_Abstract'); + $result = $reader->securityScanFile($filename); + $this->assertEquals($expectedResult, $result); + } + + public function providerValidXML() + { + $tests = []; + foreach(glob('rawTestData/Reader/XEETestValid*.xml') as $file) { + $tests[] = [realpath($file), file_get_contents($file)]; + } + return $tests; + } + +} diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/AutoFilter/ColumnTest.php b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/AutoFilter/ColumnTest.php index c8411f5e369..3c1821bad9b 100644 --- a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/AutoFilter/ColumnTest.php +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/AutoFilter/ColumnTest.php @@ -1,7 +1,7 @@ mockCell = $this->getMockBuilder('PHPExcel_Cell') + ->disableOriginalConstructor() + ->getMock(); + + $this->mockWorksheet = $this->getMockBuilder('PHPExcel_Worksheet') + ->disableOriginalConstructor() + ->getMock(); + + $this->mockWorksheet->expects($this->any()) + ->method('getHighestRow') + ->will($this->returnValue(5)); + $this->mockWorksheet->expects($this->any()) + ->method('getCellByColumnAndRow') + ->will($this->returnValue($this->mockCell)); + } + + + public function testIteratorFullRange() + { + $iterator = new PHPExcel_Worksheet_ColumnCellIterator($this->mockWorksheet, 'A'); + $ColumnCellIndexResult = 1; + $this->assertEquals($ColumnCellIndexResult, $iterator->key()); + + foreach($iterator as $key => $ColumnCell) { + $this->assertEquals($ColumnCellIndexResult++, $key); + $this->assertInstanceOf('PHPExcel_Cell', $ColumnCell); + } + } + + public function testIteratorStartEndRange() + { + $iterator = new PHPExcel_Worksheet_ColumnCellIterator($this->mockWorksheet, 'A', 2, 4); + $ColumnCellIndexResult = 2; + $this->assertEquals($ColumnCellIndexResult, $iterator->key()); + + foreach($iterator as $key => $ColumnCell) { + $this->assertEquals($ColumnCellIndexResult++, $key); + $this->assertInstanceOf('PHPExcel_Cell', $ColumnCell); + } + } + + public function testIteratorSeekAndPrev() + { + $iterator = new PHPExcel_Worksheet_ColumnCellIterator($this->mockWorksheet, 'A', 2, 4); + $columnIndexResult = 4; + $iterator->seek(4); + $this->assertEquals($columnIndexResult, $iterator->key()); + + for($i = 1; $i < $columnIndexResult-1; $i++) { + $iterator->prev(); + $this->assertEquals($columnIndexResult - $i, $iterator->key()); + } + } + + /** + * @expectedException PHPExcel_Exception + */ + public function testSeekOutOfRange() + { + $iterator = new PHPExcel_Worksheet_ColumnCellIterator($this->mockWorksheet, 'A', 2, 4); + $iterator->seek(1); + } + + /** + * @expectedException PHPExcel_Exception + */ + public function testPrevOutOfRange() + { + $iterator = new PHPExcel_Worksheet_ColumnCellIterator($this->mockWorksheet, 'A', 2, 4); + $iterator->prev(); + } + +} diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/ColumnIteratorTest.php b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/ColumnIteratorTest.php new file mode 100644 index 00000000000..7d78b61791d --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/ColumnIteratorTest.php @@ -0,0 +1,89 @@ +mockColumn = $this->getMockBuilder('PHPExcel_Worksheet_Column') + ->disableOriginalConstructor() + ->getMock(); + + $this->mockWorksheet = $this->getMockBuilder('PHPExcel_Worksheet') + ->disableOriginalConstructor() + ->getMock(); + + $this->mockWorksheet->expects($this->any()) + ->method('getHighestColumn') + ->will($this->returnValue('E')); + $this->mockWorksheet->expects($this->any()) + ->method('current') + ->will($this->returnValue($this->mockColumn)); + } + + + public function testIteratorFullRange() + { + $iterator = new PHPExcel_Worksheet_ColumnIterator($this->mockWorksheet); + $columnIndexResult = 'A'; + $this->assertEquals($columnIndexResult, $iterator->key()); + + foreach($iterator as $key => $column) { + $this->assertEquals($columnIndexResult++, $key); + $this->assertInstanceOf('PHPExcel_Worksheet_Column', $column); + } + } + + public function testIteratorStartEndRange() + { + $iterator = new PHPExcel_Worksheet_ColumnIterator($this->mockWorksheet, 'B', 'D'); + $columnIndexResult = 'B'; + $this->assertEquals($columnIndexResult, $iterator->key()); + + foreach($iterator as $key => $column) { + $this->assertEquals($columnIndexResult++, $key); + $this->assertInstanceOf('PHPExcel_Worksheet_Column', $column); + } + } + + public function testIteratorSeekAndPrev() + { + $ranges = range('A','E'); + $iterator = new PHPExcel_Worksheet_ColumnIterator($this->mockWorksheet, 'B', 'D'); + $columnIndexResult = 'D'; + $iterator->seek('D'); + $this->assertEquals($columnIndexResult, $iterator->key()); + + for($i = 1; $i < array_search($columnIndexResult, $ranges); $i++) { + $iterator->prev(); + $expectedResult = $ranges[array_search($columnIndexResult, $ranges) - $i]; + $this->assertEquals($expectedResult, $iterator->key()); + } + } + + /** + * @expectedException PHPExcel_Exception + */ + public function testSeekOutOfRange() + { + $iterator = new PHPExcel_Worksheet_ColumnIterator($this->mockWorksheet, 'B', 'D'); + $iterator->seek('A'); + } + + /** + * @expectedException PHPExcel_Exception + */ + public function testPrevOutOfRange() + { + $iterator = new PHPExcel_Worksheet_ColumnIterator($this->mockWorksheet, 'B', 'D'); + $iterator->prev(); + } + +} diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/RowCellIteratorTest.php b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/RowCellIteratorTest.php new file mode 100644 index 00000000000..cdd3c84d4bd --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/RowCellIteratorTest.php @@ -0,0 +1,89 @@ +mockCell = $this->getMockBuilder('PHPExcel_Cell') + ->disableOriginalConstructor() + ->getMock(); + + $this->mockWorksheet = $this->getMockBuilder('PHPExcel_Worksheet') + ->disableOriginalConstructor() + ->getMock(); + + $this->mockWorksheet->expects($this->any()) + ->method('getHighestColumn') + ->will($this->returnValue('E')); + $this->mockWorksheet->expects($this->any()) + ->method('getCellByColumnAndRow') + ->will($this->returnValue($this->mockCell)); + } + + + public function testIteratorFullRange() + { + $iterator = new PHPExcel_Worksheet_RowCellIterator($this->mockWorksheet); + $RowCellIndexResult = 'A'; + $this->assertEquals($RowCellIndexResult, $iterator->key()); + + foreach($iterator as $key => $RowCell) { + $this->assertEquals($RowCellIndexResult++, $key); + $this->assertInstanceOf('PHPExcel_Cell', $RowCell); + } + } + + public function testIteratorStartEndRange() + { + $iterator = new PHPExcel_Worksheet_RowCellIterator($this->mockWorksheet, 2, 'B', 'D'); + $RowCellIndexResult = 'B'; + $this->assertEquals($RowCellIndexResult, $iterator->key()); + + foreach($iterator as $key => $RowCell) { + $this->assertEquals($RowCellIndexResult++, $key); + $this->assertInstanceOf('PHPExcel_Cell', $RowCell); + } + } + + public function testIteratorSeekAndPrev() + { + $ranges = range('A','E'); + $iterator = new PHPExcel_Worksheet_RowCellIterator($this->mockWorksheet, 2, 'B', 'D'); + $RowCellIndexResult = 'D'; + $iterator->seek('D'); + $this->assertEquals($RowCellIndexResult, $iterator->key()); + + for($i = 1; $i < array_search($RowCellIndexResult, $ranges); $i++) { + $iterator->prev(); + $expectedResult = $ranges[array_search($RowCellIndexResult, $ranges) - $i]; + $this->assertEquals($expectedResult, $iterator->key()); + } + } + + /** + * @expectedException PHPExcel_Exception + */ + public function testSeekOutOfRange() + { + $iterator = new PHPExcel_Worksheet_RowCellIterator($this->mockWorksheet, 2, 'B', 'D'); + $iterator->seek(1); + } + + /** + * @expectedException PHPExcel_Exception + */ + public function testPrevOutOfRange() + { + $iterator = new PHPExcel_Worksheet_RowCellIterator($this->mockWorksheet, 2, 'B', 'D'); + $iterator->prev(); + } + +} diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/RowIteratorTest.php b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/RowIteratorTest.php new file mode 100644 index 00000000000..48d8b6bb1cf --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/RowIteratorTest.php @@ -0,0 +1,87 @@ +mockRow = $this->getMockBuilder('PHPExcel_Worksheet_Row') + ->disableOriginalConstructor() + ->getMock(); + + $this->mockWorksheet = $this->getMockBuilder('PHPExcel_Worksheet') + ->disableOriginalConstructor() + ->getMock(); + + $this->mockWorksheet->expects($this->any()) + ->method('getHighestRow') + ->will($this->returnValue(5)); + $this->mockWorksheet->expects($this->any()) + ->method('current') + ->will($this->returnValue($this->mockRow)); + } + + + public function testIteratorFullRange() + { + $iterator = new PHPExcel_Worksheet_RowIterator($this->mockWorksheet); + $rowIndexResult = 1; + $this->assertEquals($rowIndexResult, $iterator->key()); + + foreach($iterator as $key => $row) { + $this->assertEquals($rowIndexResult++, $key); + $this->assertInstanceOf('PHPExcel_Worksheet_Row', $row); + } + } + + public function testIteratorStartEndRange() + { + $iterator = new PHPExcel_Worksheet_RowIterator($this->mockWorksheet, 2, 4); + $rowIndexResult = 2; + $this->assertEquals($rowIndexResult, $iterator->key()); + + foreach($iterator as $key => $row) { + $this->assertEquals($rowIndexResult++, $key); + $this->assertInstanceOf('PHPExcel_Worksheet_Row', $row); + } + } + + public function testIteratorSeekAndPrev() + { + $iterator = new PHPExcel_Worksheet_RowIterator($this->mockWorksheet, 2, 4); + $columnIndexResult = 4; + $iterator->seek(4); + $this->assertEquals($columnIndexResult, $iterator->key()); + + for($i = 1; $i < $columnIndexResult-1; $i++) { + $iterator->prev(); + $this->assertEquals($columnIndexResult - $i, $iterator->key()); + } + } + + /** + * @expectedException PHPExcel_Exception + */ + public function testSeekOutOfRange() + { + $iterator = new PHPExcel_Worksheet_RowIterator($this->mockWorksheet, 2, 4); + $iterator->seek(1); + } + + /** + * @expectedException PHPExcel_Exception + */ + public function testPrevOutOfRange() + { + $iterator = new PHPExcel_Worksheet_RowIterator($this->mockWorksheet, 2, 4); + $iterator->prev(); + } + +} diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/WorksheetColumnTest.php b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/WorksheetColumnTest.php new file mode 100644 index 00000000000..c70c38d364f --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/WorksheetColumnTest.php @@ -0,0 +1,46 @@ +mockWorksheet = $this->getMockBuilder('PHPExcel_Worksheet') + ->disableOriginalConstructor() + ->getMock(); + $this->mockWorksheet->expects($this->any()) + ->method('getHighestRow') + ->will($this->returnValue(5)); + } + + + public function testInstantiateColumnDefault() + { + $column = new PHPExcel_Worksheet_Column($this->mockWorksheet); + $this->assertInstanceOf('PHPExcel_Worksheet_Column', $column); + $columnIndex = $column->getColumnIndex(); + $this->assertEquals('A', $columnIndex); + } + + public function testInstantiateColumnSpecified() + { + $column = new PHPExcel_Worksheet_Column($this->mockWorksheet, 'E'); + $this->assertInstanceOf('PHPExcel_Worksheet_Column', $column); + $columnIndex = $column->getColumnIndex(); + $this->assertEquals('E', $columnIndex); + } + + public function testGetCellIterator() + { + $column = new PHPExcel_Worksheet_Column($this->mockWorksheet); + $cellIterator = $column->getCellIterator(); + $this->assertInstanceOf('PHPExcel_Worksheet_ColumnCellIterator', $cellIterator); + } +} diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/WorksheetRowTest.php b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/WorksheetRowTest.php new file mode 100644 index 00000000000..2761b52be61 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Worksheet/WorksheetRowTest.php @@ -0,0 +1,46 @@ +mockWorksheet = $this->getMockBuilder('PHPExcel_Worksheet') + ->disableOriginalConstructor() + ->getMock(); + $this->mockWorksheet->expects($this->any()) + ->method('getHighestColumn') + ->will($this->returnValue('E')); + } + + + public function testInstantiateRowDefault() + { + $row = new PHPExcel_Worksheet_Row($this->mockWorksheet); + $this->assertInstanceOf('PHPExcel_Worksheet_Row', $row); + $rowIndex = $row->getRowIndex(); + $this->assertEquals(1, $rowIndex); + } + + public function testInstantiateRowSpecified() + { + $row = new PHPExcel_Worksheet_Row($this->mockWorksheet, 5); + $this->assertInstanceOf('PHPExcel_Worksheet_Row', $row); + $rowIndex = $row->getRowIndex(); + $this->assertEquals(5, $rowIndex); + } + + public function testGetCellIterator() + { + $row = new PHPExcel_Worksheet_Row($this->mockWorksheet); + $cellIterator = $row->getCellIterator(); + $this->assertInstanceOf('PHPExcel_Worksheet_RowCellIterator', $cellIterator); + } +} diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/phpunit.xml b/htdocs/includes/phpoffice/phpexcel/unitTests/phpunit.xml index e8fa17e387d..2c2ff360ae0 100644 --- a/htdocs/includes/phpoffice/phpexcel/unitTests/phpunit.xml +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/phpunit.xml @@ -13,6 +13,9 @@ stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false"> + + + ./Classes diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Calculation/MathTrig/MINVERSE.data b/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Calculation/MathTrig/MINVERSE.data index 2f8fd637696..8c9a962fa6d 100644 --- a/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Calculation/MathTrig/MINVERSE.data +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Calculation/MathTrig/MINVERSE.data @@ -1,4 +1,4 @@ -{1|2|3;4|5|6;7|8|9}, {-4.50359962737050E+15|9.00719925474099E+15|-4.50359962737050E+15;9.00719925474100E+15|-1.80143985094820E+16|9.00719925474099E+15;-4.50359962737050E+15|9.00719925474099E+15|-4.50359962737050E+15} +{1|2|3;4|5|6;7|8|9}, {-4.50359962737050E+15|9.00719925474099E+15|-4.50359962737050E+15;9.00719925474100E+15|-1.80143985094820E+16|9.00719925474099E+15;-4.50359962737050E+15|9.00719925474099E+15|-4.50359962737050E+15} {10|20|30;40|50|60;70|80|90}, {7.03687441776639E+13|-1.40737488355328E+14|7.03687441776640E+13;-1.40737488355328E+14|2.81474976710656E+14|-1.40737488355328E+14;7.03687441776641E+13|-1.40737488355328E+14|7.03687441776640E+13} {8|1|6;3|5|7;4|9|2}, {1.47222222222222E-01|-1.44444444444444E-01|6.38888888888889E-02;-6.11111111111111E-02|2.22222222222222E-02|1.05555555555556E-01;-1.94444444444444E-02|1.88888888888889E-01|-1.02777777777778E-01} {4|-1;2|0}, {0|0.5;-1|2} @@ -8,3 +8,8 @@ {0.2|1|-0.9;0.35|10.8|4;-3.15|5}, "#VALUE!" {1|2;3|4}, {-2|1;1.5|-0.5} {1|2|1;3|4|2;1|1|2}, {-2|1|0;1.33333333333333|-0.33333333333333|-0.33333333333333;0.33333333333333|-0.33333333333333|0.66666666666667} +{2|3;4|5}, {-2.5|1.5;2|-1} +{5|8;7|9}, {-0.818181818181818|0.727272727272727;0.636363636363636|-0.454545454545455} +{45|78;17|50}, {0.054112554112554|-0.084415584415584;-0.018398268398268|0.048701298701299} +{2|2;2|1}, {-0.5|1.0;1|-1} +{1|4|6;7|4|10;15|16|20}, {-0.2941176470588230|0.0588235294117647|0.0588235294117647;0.0367647058823529|-0.2573529411764710|0.1176470588235290;0.1911764705882350|0.1617647058823530|-0.0882352941176471} \ No newline at end of file diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Calculation/MathTrig/MMULT.data b/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Calculation/MathTrig/MMULT.data index dec3d890b47..86c9bfdb416 100644 --- a/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Calculation/MathTrig/MMULT.data +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Calculation/MathTrig/MMULT.data @@ -1,11 +1,12 @@ {1|2;3|4}, {1|2;3|4}, {7|10;15|22} {1|2|3;4|5|6;7|8|9}, {1|2|3;4|5|6;7|8|9}, {30|36|42;66|81|96;102|126|150} -{1|2;3|4}, 2, {2|4;6|8} -{1|2;3|4}, {2}, {2|4;6|8} -2, {1|2;3|4}, {2|4;6|8} -{2}, {1|2;3|4}, {2|4;6|8} -{1|2;3|4}, {2|4}, {2|4;6|8} -{1|2;3|4}, {2;4}, {2|4;6|8} -{2|4}, {1|2;3|4}, {2|4;6|8} -{2;4}, {1|2;3|4}, {2|4;6|8} -{1|2;3|4;5|6}, {1|2|3;4|5|6}, {1|2|3;4|5|6;7|8|9} +{1|2;3|4}, 2, "#VALUE!" // Mismatched dimensions +{1|2;3|4}, {2}, "#VALUE!" // Mismatched dimensions +{1.2;2.4}, {3.6|4.5}, {14.43|14.43;14.43|14.43} +2, {1|2;3|4}, "#VALUE!" // Mismatched dimensions +{2}, {1|2;3|4}, "#VALUE!" // Mismatched dimensions +{1|2;3|4}, {2|4}, "#VALUE!" +{1|2;3|4}, {2;4}, {{10};{22}} +{2|4}, {1|2;3|4}, {14|20} +{2;4}, {1|2;3|4}, "#VALUE!" // Mismatched dimensions +{1|2;3|4;5|6}, {1|2|3;4|5|6}, {9|12|15;19|26|33;29|40|51} diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Calculation/TextData/TRIM.data b/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Calculation/TextData/TRIM.data index ea1bd0503bd..ea800963ce9 100644 --- a/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Calculation/TextData/TRIM.data +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Calculation/TextData/TRIM.data @@ -1,6 +1,6 @@ "HELLO ", "HELLO" " HELLO", "HELLO" -" HELLO ", "HELLO" +" HELLO ", "HELLO" " HELLO", " HELLO" "HELLO WORLD", "HELLO WORLD" TRUE, "TRUE" diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Calculation/TextData/VALUE.data b/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Calculation/TextData/VALUE.data new file mode 100644 index 00000000000..505c2915b97 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Calculation/TextData/VALUE.data @@ -0,0 +1,10 @@ +"1000", "1000" +"1 000", "1000" +"$1 000", "1000" +"£1 000", "#VALUE!" +"1.1", "1.1" +"1 000.1", "1000.1" +"13 Monkeys", "#VALUE!" +"1-Jan-2014", "41640" +"12:34:56", "0.524259259259259" +"2:46 AM", "0.11527777777778" diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Cell/DefaultValueBinder.data b/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Cell/DefaultValueBinder.data new file mode 100644 index 00000000000..446ded6cdb4 --- /dev/null +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Cell/DefaultValueBinder.data @@ -0,0 +1,19 @@ +NULL, "null" +, "null" +"#NULL!", "e" +FALSE, "b" +TRUE, "b" +"FALSE", "s" +"TRUE", "s" +"", "s" +"ABC", "s" +"123", "n" +123, "n" +0.123, "n" +"-123", "n" +"1.23E4", "n" +"-1.23E4", "n" +"1.23E-4", "n" +"000123", "s" +"=123", "f" +"#DIV/0!", "e" diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Reader/XEETestInvalidUTF-16.xml b/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Reader/XEETestInvalidUTF-16.xml new file mode 100644 index 0000000000000000000000000000000000000000..94eaedfc2aec6c1eb2e723c914acf0afcdbbfd65 GIT binary patch literal 276 zcmX|*O%K697=)iIiT|*A5Dut|gO57+NL-NMAmSj}h@{#?MfmfW?v`w_?`G$jnfLu+ zz=$VTVhj%=Ze(0YNf_eMp@pw$q$Hg5A4*L)TXoBZ8BI}L%VgX+N)2_#HY2j!OYTg> zh=2-Zbyk_MWGw%V6;tKk#HaEb_Lebvxs%gV7Gmd?H`>>i<|!j(t?5z^#dHn7Jg1eE VobPa_Cug0S&FIr8_G$n7gD--qCxrk2 literal 0 HcmV?d00001 diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Reader/XEETestInvalidUTF-16BE.xml b/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Reader/XEETestInvalidUTF-16BE.xml new file mode 100644 index 0000000000000000000000000000000000000000..1d186ff443435bec745501c2d7bfc81271e4c3c5 GIT binary patch literal 278 zcmX|*!4APd6h+UL#6JuRVS(CMP;G)rY>;3fVjOWMPaI@)wJxh9`M$8B-myvT35$cYuC$j8EhD?Ny zM}s;pO%`mJ%W-6@Zll?$POjI+J3Go+a-{53OY6C+<%FNF%xW?h UJLHVj*`aM66S~ztga3T*3-^U44*&oF literal 0 HcmV?d00001 diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Reader/XEETestInvalidUTF-16LE.xml b/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Reader/XEETestInvalidUTF-16LE.xml new file mode 100644 index 0000000000000000000000000000000000000000..c3913f71bb84e44fb3659848c69c0434945a2642 GIT binary patch literal 278 zcmX|*!4APd6h+UL#6JuRVS(CMQ0;f@4L_Ep3laer{#gIOZs!@_~)qkio;bzkVdlvLWjaU&_E+gk6BGesQPh{DT44DWY zj|O#In#|cSljF!%-A1!hom{VzWsF|sDd>Q;*rnx-c6OAt + +]> + + + test: (&x0;) + \ No newline at end of file diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Reader/XEETestValidUTF-16.xml b/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Reader/XEETestValidUTF-16.xml new file mode 100644 index 0000000000000000000000000000000000000000..6473fe6b6382c7f6993f3c9f0187bd0636613a98 GIT binary patch literal 176 zcmYL?I}Ug^iD-dB + + test: Valid + \ No newline at end of file diff --git a/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Style/NumberFormat.data b/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Style/NumberFormat.data index 3f5901a59a5..49acaccfc7d 100644 --- a/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Style/NumberFormat.data +++ b/htdocs/includes/phpoffice/phpexcel/unitTests/rawTestData/Style/NumberFormat.data @@ -32,3 +32,6 @@ 123456789, '(000) 0-0000-000', "(001) 2-3456-789" 123456789, '0 (+00) 0000 00 00 00', "0 (+00) 0123 45 67 89" 123456789, '0000:00:00', "12345:67:89" +-123456789, '0000:00:00', "-12345:67:89" +1234567.89, '0000:00.00', "12345:67.89" +-1234567.89,'0000:00.00', "-12345:67.89"