Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change abandoned package phpoffice/phpexcel to phpoffice/phpspreadsheet #134

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ cache:
- $HOME/.composer/cache

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
Expand Down
43 changes: 43 additions & 0 deletions Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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;
}
}
}
3 changes: 2 additions & 1 deletion Tests/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": [
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be added to autoload-devsection, is not it?

"polyfill"
]
},
"autoload-dev": {
"psr-4": {
Expand Down
31 changes: 31 additions & 0 deletions polyfill/IReader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace PhpOffice\PhpSpreadsheet\Reader;

interface IReader extends \PHPExcel_Reader_IReader
{
/**
* IReader constructor.
*/
public function __construct();

/**
* Can the current IReader read the file?
*
* @param string $pFilename
*
* @return bool
*/
public function canRead($pFilename);

/**
* Loads PhpSpreadsheet from file.
*
* @param string $pFilename
*
* @throws Exception
*
* @return \PhpOffice\PhpSpreadsheet\Spreadsheet
*/
public function load($pFilename);
}
24 changes: 24 additions & 0 deletions polyfill/IWriter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace PhpOffice\PhpSpreadsheet\Writer;

use PhpOffice\PhpSpreadsheet\Spreadsheet;

interface IWriter extends \PHPExcel_Writer_IWriter
{
/**
* IWriter constructor.
*
* @param Spreadsheet $spreadsheet
*/
public function __construct(Spreadsheet $spreadsheet);

/**
* Save PhpSpreadsheet to file.
*
* @param string $pFilename Name of the file to save
*
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function save($pFilename);
}
11 changes: 11 additions & 0 deletions polyfill/PHPExcel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
@trigger_error('\PHPExcel is deprecated use \PhpOffice\PhpSpreadsheet\Spreadsheet instead', E_DEPRECATED);

/**
* Class PHPExcel
*
* @deprecated
*/
class PHPExcel extends \PhpOffice\PhpSpreadsheet\Spreadsheet
{
}
11 changes: 11 additions & 0 deletions polyfill/PHPExcel_Helper_HTML.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
@trigger_error('\PHPExcel_Helper_HTML is deprecated use \PhpOffice\PhpSpreadsheet\Helper\Html instead', E_DEPRECATED);

/**
* Class PHPExcel_Helper_HTML
*
* @deprecated
*/
class PHPExcel_Helper_HTML extends \PhpOffice\PhpSpreadsheet\Helper\Html
{
}
11 changes: 11 additions & 0 deletions polyfill/PHPExcel_IOFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
@trigger_error('\PHPExcel_IOFactory is deprecated use \PhpOffice\PhpSpreadsheet\IOFactory instead', E_DEPRECATED);

/**
* Class PHPExcel_IOFactory
*
* @deprecated
*/
class PHPExcel_IOFactory extends \PhpOffice\PhpSpreadsheet\IOFactory
{
}
10 changes: 10 additions & 0 deletions polyfill/PHPExcel_Reader_IReader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
@trigger_error('\PHPExcel_Reader_IReader is deprecated use \PhpOffice\PhpSpreadsheet\Reader\IReader instead', E_DEPRECATED);
/**
* Interface PHPExcel_Reader_IReader
*
* @deprecated
*/
interface PHPExcel_Reader_IReader
{
}
10 changes: 10 additions & 0 deletions polyfill/PHPExcel_Worksheet_Drawing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
@trigger_error('\PHPExcel_Worksheet_Drawing is deprecated use \PhpOffice\PhpSpreadsheet\Worksheet\Drawing instead', E_DEPRECATED);
/**
* Class PHPExcel_Worksheet_Drawing
*
* @deprecated
*/
class PHPExcel_Worksheet_Drawing extends \PhpOffice\PhpSpreadsheet\Worksheet\Drawing
{
}
18 changes: 18 additions & 0 deletions polyfill/PHPExcel_Writer_IWriter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
@trigger_error('\PHPExcel_Writer_IWriter is deprecated use \PhpOffice\PhpSpreadsheet\Writer\IWriter instead', E_DEPRECATED);
/**
* Interface PHPExcel_Writer_IWriter
*
* @deprecated
*/
interface PHPExcel_Writer_IWriter
{
/**
* Save PhpSpreadsheet to file.
*
* @param string $pFilename Name of the file to save
*
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public function save($pFilename);
}