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 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 fdfbdd4..849e195 100644 --- a/composer.json +++ b/composer.json @@ -17,9 +17,9 @@ "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/phpexcel": "~1.8.1" + "phpoffice/phpspreadsheet": "^1.2" }, "require-dev": { "phpunit/phpunit": "~4.6", @@ -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": "^3.4" }, "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 @@ +