From 76045221e5fe334f1956275b686bd95b57d8fa2b Mon Sep 17 00:00:00 2001 From: sharoff45 Date: Tue, 13 Mar 2018 08:32:59 +0300 Subject: [PATCH 1/6] Changed abandoned package phpoffice/phpexcel to phpoffice/phpspreadsheet --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fdfbdd4..155e804 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require": { "php": ">=5.3.2", "symfony/framework-bundle": "~2.6|~3.0", - "phpoffice/phpexcel": "~1.8.1" + "phpoffice/phpspreadsheet": "^1.2" }, "require-dev": { "phpunit/phpunit": "~4.6", From 114c145270c521353803f14cb42664c8a3f2c710 Mon Sep 17 00:00:00 2001 From: sharoff45 Date: Tue, 13 Mar 2018 08:39:35 +0300 Subject: [PATCH 2/6] changed minimal php version to 5.6 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 155e804..f544485 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "homepage": "http://www.welcometothebundle.com", "license": "MIT", "require": { - "php": ">=5.3.2", + "php": "^5.6|^7.0", "symfony/framework-bundle": "~2.6|~3.0", "phpoffice/phpspreadsheet": "^1.2" }, From 51011f97f3da507d6b7849b8b50dfb97e6110dbb Mon Sep 17 00:00:00 2001 From: sharoff45 Date: Tue, 13 Mar 2018 09:15:10 +0300 Subject: [PATCH 3/6] compatibility with phpoffice/phpexcel --- Factory.php | 43 +++++++++++++++++++++++++ Tests/FactoryTest.php | 3 +- composer.json | 8 +++-- polyfill/IReader.php | 31 ++++++++++++++++++ polyfill/IWriter.php | 24 ++++++++++++++ polyfill/PHPExcel.php | 11 +++++++ polyfill/PHPExcel_Helper_HTML.php | 11 +++++++ polyfill/PHPExcel_IOFactory.php | 11 +++++++ polyfill/PHPExcel_Reader_IReader.php | 10 ++++++ polyfill/PHPExcel_Worksheet_Drawing.php | 10 ++++++ polyfill/PHPExcel_Writer_IWriter.php | 18 +++++++++++ 11 files changed, 177 insertions(+), 3 deletions(-) create mode 100644 polyfill/IReader.php create mode 100644 polyfill/IWriter.php create mode 100644 polyfill/PHPExcel.php create mode 100644 polyfill/PHPExcel_Helper_HTML.php create mode 100644 polyfill/PHPExcel_IOFactory.php create mode 100644 polyfill/PHPExcel_Reader_IReader.php create mode 100644 polyfill/PHPExcel_Worksheet_Drawing.php create mode 100644 polyfill/PHPExcel_Writer_IWriter.php diff --git a/Factory.php b/Factory.php index bf5daa0..e6c1628 100644 --- a/Factory.php +++ b/Factory.php @@ -49,6 +49,7 @@ public function createPHPExcelWorksheetDrawing() */ public function createReader($type = 'Excel5') { + $type = $this->convertType($type); return call_user_func(array($this->phpExcelIO, 'createReader'), $type); } @@ -64,6 +65,7 @@ public function createReader($type = 'Excel5') */ public function createWriter(\PHPExcel $phpExcelObject, $type = 'Excel5') { + $type = $this->convertType($type); return call_user_func(array($this->phpExcelIO, 'createWriter'), $phpExcelObject, $type); } @@ -96,4 +98,45 @@ public function createHelperHTML() { return new \PHPExcel_Helper_HTML(); } + + /** + * Documentation link: https://phpspreadsheet.readthedocs.io/en/develop/topics/migration-from-PHPExcel/#renamed-readers-and-writers + * + * @param string $type + * + * @return string + */ + private function convertType($type) + { + switch ($type) { + case 'CSV': + return 'Csv'; + break; + case 'Excel2003XML': + return 'Xml'; + break; + case 'Excel2007': + return 'Xlsx'; + break; + case 'Excel5': + return 'Xls'; + break; + case 'HTML': + return 'Html'; + break; + case 'OOCalc': + case 'OpenDocument': + return 'Ods'; + break; + case 'PDF': + return 'Pdf'; + break; + case 'SYLK': + return 'Slk'; + break; + default: + return $type; + break; + } + } } diff --git a/Tests/FactoryTest.php b/Tests/FactoryTest.php index 3a54b01..bbb91e5 100644 --- a/Tests/FactoryTest.php +++ b/Tests/FactoryTest.php @@ -3,8 +3,9 @@ namespace Liuggio\ExcelBundle\Tests; use Liuggio\ExcelBundle\Factory; +use PHPUnit\Framework\TestCase; -class FactoryTest extends \PHPUnit_Framework_TestCase +class FactoryTest extends TestCase { public function testCreate() { diff --git a/composer.json b/composer.json index f544485..130fef3 100644 --- a/composer.json +++ b/composer.json @@ -28,13 +28,17 @@ "symfony/class-loader": "~2.6|~3.0", "symfony/validator": "~2.6|~3.0", "symfony/browser-kit": "~2.6|~3.0", - "sensio/framework-extra-bundle": "~2.3|~3.0" + "sensio/framework-extra-bundle": "~2.3|~3.0", + "symfony/var-dumper": "^4.0" }, "autoload": { "exclude-from-classmap": ["/Tests/"], "psr-4": { "Liuggio\\ExcelBundle\\": "" - } + }, + "classmap": [ + "polyfill" + ] }, "autoload-dev": { "psr-4": { diff --git a/polyfill/IReader.php b/polyfill/IReader.php new file mode 100644 index 0000000..b70314b --- /dev/null +++ b/polyfill/IReader.php @@ -0,0 +1,31 @@ + Date: Tue, 13 Mar 2018 09:18:03 +0300 Subject: [PATCH 4/6] muted trigger error --- polyfill/PHPExcel.php | 2 +- polyfill/PHPExcel_Helper_HTML.php | 2 +- polyfill/PHPExcel_IOFactory.php | 2 +- polyfill/PHPExcel_Reader_IReader.php | 2 +- polyfill/PHPExcel_Worksheet_Drawing.php | 2 +- polyfill/PHPExcel_Writer_IWriter.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/polyfill/PHPExcel.php b/polyfill/PHPExcel.php index b2a0a0a..2821d3f 100644 --- a/polyfill/PHPExcel.php +++ b/polyfill/PHPExcel.php @@ -1,5 +1,5 @@ Date: Tue, 13 Mar 2018 09:21:33 +0300 Subject: [PATCH 5/6] removed php 5.3, 5.4 and 5.5 from travis --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 243624e..7b4459b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,9 +7,6 @@ cache: - $HOME/.composer/cache php: - - 5.3 - - 5.4 - - 5.5 - 5.6 - 7.0 - 7.1 From b5bf6f638eda903c7f38afa690978b34d0808321 Mon Sep 17 00:00:00 2001 From: sharoff45 Date: Tue, 13 Mar 2018 09:26:13 +0300 Subject: [PATCH 6/6] changed symfony/var-dumper to compatibility with php 5.6 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 130fef3..849e195 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "symfony/validator": "~2.6|~3.0", "symfony/browser-kit": "~2.6|~3.0", "sensio/framework-extra-bundle": "~2.3|~3.0", - "symfony/var-dumper": "^4.0" + "symfony/var-dumper": "^3.4" }, "autoload": { "exclude-from-classmap": ["/Tests/"],