diff --git a/CHANGELOG.md b/CHANGELOG.md index cfeee18c..93d25269 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,26 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - c:max and c:min elements shall NOT be inside c:orientation elements - @vitalyrepin [#869](https://github.com/PHPOffice/PHPExcel/pull/869) - Implement actual timezone adjustment into PHPExcel_Shared_Date::PHPToExcel - @sim642 [#489](https://github.com/PHPOffice/PHPExcel/pull/489) +### BREAKING CHANGE + +- Introduction of namespaces for all classes, eg: `PHPExcel_Calculation_Function` becomes `PhpOffice\PhpSpreadsheet\Calculation\Functions` +- Some classes were renamed for clarity and/or consistency: + +| Before | After | +|---------------------------------|-------------------------------------------| +| `PHPExcel` | `PhpOffice\PhpSpreadsheet\Spreadsheet` | +| `PHPExcel_Reader_Excel2007` | `PhpOffice\PhpSpreadsheet\Reader\Xlsx` | +| `PHPExcel_Writer_Excel2007` | `PhpOffice\PhpSpreadsheet\Writer\Xlsx` | + +- Some methods were renamed for clarity and/or consistency: + +| Before | After | +|--------------------------------------------------|------------------------------------------------------------| +| `PHPExcel_Calculation_DateTime::DAYOFWEEK()` | `PhpOffice\PhpSpreadsheet\Calculation\DateTime::WEEKDAY()` | +| `PHPExcel_Calculation_DateTime::WEEKOFYEAR()` | `PhpOffice\PhpSpreadsheet\Calculation\DateTime::WEEKNUM()` | +| `PHPExcel_Calculation_DateTime::MINUTEOFHOUR()` | `PhpOffice\PhpSpreadsheet\Calculation\DateTime::MINUTE()` | +| `PHPExcel_Calculation_DateTime::SECONDOFMINUTE()`| `PhpOffice\PhpSpreadsheet\Calculation\DateTime::SECOND()` | + ## [1.8.1] - 2015-04-30 diff --git a/Documentation/Examples/Reader/exampleReader03.php b/Documentation/Examples/Reader/exampleReader03.php index 1c571d3c..4ec4d55e 100644 --- a/Documentation/Examples/Reader/exampleReader03.php +++ b/Documentation/Examples/Reader/exampleReader03.php @@ -27,7 +27,7 @@ include 'PHPExcel/IOFactory.php'; $inputFileType = 'Excel5'; -// $inputFileType = 'Excel2007'; +// $inputFileType = 'Xlsx'; // $inputFileType = 'Excel2003XML'; // $inputFileType = 'OOCalc'; // $inputFileType = 'SYLK'; diff --git a/Documentation/Examples/Reader/exampleReader05.php b/Documentation/Examples/Reader/exampleReader05.php index 9bee5b47..a5c473f0 100644 --- a/Documentation/Examples/Reader/exampleReader05.php +++ b/Documentation/Examples/Reader/exampleReader05.php @@ -27,7 +27,7 @@ include 'PHPExcel/IOFactory.php'; $inputFileType = 'Excel5'; -// $inputFileType = 'Excel2007'; +// $inputFileType = 'Xlsx'; // $inputFileType = 'Excel2003XML'; // $inputFileType = 'OOCalc'; // $inputFileType = 'Gnumeric'; diff --git a/Documentation/Examples/Reader/exampleReader06.php b/Documentation/Examples/Reader/exampleReader06.php index 6997a38b..6bbb8e0d 100644 --- a/Documentation/Examples/Reader/exampleReader06.php +++ b/Documentation/Examples/Reader/exampleReader06.php @@ -27,7 +27,7 @@ include 'PHPExcel/IOFactory.php'; $inputFileType = 'Excel5'; -// $inputFileType = 'Excel2007'; +// $inputFileType = 'Xlsx'; // $inputFileType = 'Excel2003XML'; // $inputFileType = 'OOCalc'; // $inputFileType = 'Gnumeric'; diff --git a/Documentation/Examples/Reader/exampleReader07.php b/Documentation/Examples/Reader/exampleReader07.php index 0d86ea74..cf9b981f 100644 --- a/Documentation/Examples/Reader/exampleReader07.php +++ b/Documentation/Examples/Reader/exampleReader07.php @@ -27,7 +27,7 @@ include 'PHPExcel/IOFactory.php'; $inputFileType = 'Excel5'; -// $inputFileType = 'Excel2007'; +// $inputFileType = 'Xlsx'; // $inputFileType = 'Excel2003XML'; // $inputFileType = 'OOCalc'; // $inputFileType = 'Gnumeric'; diff --git a/Documentation/Examples/Reader/exampleReader08.php b/Documentation/Examples/Reader/exampleReader08.php index c6a44601..76440eb3 100644 --- a/Documentation/Examples/Reader/exampleReader08.php +++ b/Documentation/Examples/Reader/exampleReader08.php @@ -27,7 +27,7 @@ include 'PHPExcel/IOFactory.php'; $inputFileType = 'Excel5'; -// $inputFileType = 'Excel2007'; +// $inputFileType = 'Xlsx'; // $inputFileType = 'Excel2003XML'; // $inputFileType = 'OOCalc'; // $inputFileType = 'Gnumeric'; diff --git a/Documentation/Examples/Reader/exampleReader09.php b/Documentation/Examples/Reader/exampleReader09.php index a6cd1442..a4a87edc 100644 --- a/Documentation/Examples/Reader/exampleReader09.php +++ b/Documentation/Examples/Reader/exampleReader09.php @@ -27,7 +27,7 @@ include 'PHPExcel/IOFactory.php'; $inputFileType = 'Excel5'; -// $inputFileType = 'Excel2007'; +// $inputFileType = 'Xlsx'; // $inputFileType = 'Excel2003XML'; // $inputFileType = 'OOCalc'; // $inputFileType = 'Gnumeric'; diff --git a/Documentation/Examples/Reader/exampleReader10.php b/Documentation/Examples/Reader/exampleReader10.php index d608c646..6f7fc38c 100644 --- a/Documentation/Examples/Reader/exampleReader10.php +++ b/Documentation/Examples/Reader/exampleReader10.php @@ -27,7 +27,7 @@ include 'PHPExcel/IOFactory.php'; $inputFileType = 'Excel5'; -// $inputFileType = 'Excel2007'; +// $inputFileType = 'Xlsx'; // $inputFileType = 'Excel2003XML'; // $inputFileType = 'OOCalc'; // $inputFileType = 'Gnumeric'; diff --git a/Documentation/Examples/Reader/exampleReader11.php b/Documentation/Examples/Reader/exampleReader11.php index becdb63b..3f053df4 100644 --- a/Documentation/Examples/Reader/exampleReader11.php +++ b/Documentation/Examples/Reader/exampleReader11.php @@ -27,7 +27,7 @@ include 'PHPExcel/IOFactory.php'; $inputFileType = 'Excel5'; -// $inputFileType = 'Excel2007'; +// $inputFileType = 'Xlsx'; // $inputFileType = 'Excel2003XML'; // $inputFileType = 'OOCalc'; // $inputFileType = 'Gnumeric'; diff --git a/Documentation/Examples/Reader/exampleReader12.php b/Documentation/Examples/Reader/exampleReader12.php index 1df90cd3..4551b5e7 100644 --- a/Documentation/Examples/Reader/exampleReader12.php +++ b/Documentation/Examples/Reader/exampleReader12.php @@ -27,7 +27,7 @@ include 'PHPExcel/IOFactory.php'; $inputFileType = 'Excel5'; -// $inputFileType = 'Excel2007'; +// $inputFileType = 'Xlsx'; // $inputFileType = 'Excel2003XML'; // $inputFileType = 'OOCalc'; // $inputFileType = 'Gnumeric'; diff --git a/Documentation/Examples/Reader/exampleReader17.php b/Documentation/Examples/Reader/exampleReader17.php index 1f77c561..331fbcc7 100644 --- a/Documentation/Examples/Reader/exampleReader17.php +++ b/Documentation/Examples/Reader/exampleReader17.php @@ -27,7 +27,7 @@ include 'PHPExcel/IOFactory.php'; $inputFileType = 'Excel5'; -// $inputFileType = 'Excel2007'; +// $inputFileType = 'Xlsx'; // $inputFileType = 'Excel2003XML'; // $inputFileType = 'OOCalc'; // $inputFileType = 'Gnumeric'; diff --git a/Documentation/Examples/Reader/exampleReader18.php b/Documentation/Examples/Reader/exampleReader18.php index 438d8869..b4bb9a5c 100644 --- a/Documentation/Examples/Reader/exampleReader18.php +++ b/Documentation/Examples/Reader/exampleReader18.php @@ -27,7 +27,7 @@ include 'PHPExcel/IOFactory.php'; $inputFileType = 'Excel5'; -// $inputFileType = 'Excel2007'; +// $inputFileType = 'Xlsx'; // $inputFileType = 'Excel2003XML'; // $inputFileType = 'OOCalc'; // $inputFileType = 'Gnumeric'; diff --git a/Documentation/Examples/Reader/exampleReader19.php b/Documentation/Examples/Reader/exampleReader19.php index 2f3eaaf2..6d49ac95 100644 --- a/Documentation/Examples/Reader/exampleReader19.php +++ b/Documentation/Examples/Reader/exampleReader19.php @@ -27,7 +27,7 @@ include 'PHPExcel/IOFactory.php'; $inputFileType = 'Excel5'; -// $inputFileType = 'Excel2007'; +// $inputFileType = 'Xlsx'; // $inputFileType = 'Excel2003XML'; // $inputFileType = 'OOCalc'; // $inputFileType = 'Gnumeric'; diff --git a/Documentation/Examples/Reading WorkBook Data/exampleWorkBookReader02.php b/Documentation/Examples/Reading WorkBook Data/exampleWorkBookReader02.php index b8c359d3..9c56f1ff 100644 --- a/Documentation/Examples/Reading WorkBook Data/exampleWorkBookReader02.php +++ b/Documentation/Examples/Reading WorkBook Data/exampleWorkBookReader02.php @@ -26,7 +26,7 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/'); include 'PHPExcel/IOFactory.php'; -$inputFileType = 'Excel2007'; +$inputFileType = 'Xlsx'; $inputFileName = './sampleData/example1.xlsx'; /** Create a new Reader of the type defined in $inputFileType **/ diff --git a/Documentation/Examples/Reading WorkBook Data/exampleWorkBookReader03.php b/Documentation/Examples/Reading WorkBook Data/exampleWorkBookReader03.php index 8fb350d4..08a78894 100644 --- a/Documentation/Examples/Reading WorkBook Data/exampleWorkBookReader03.php +++ b/Documentation/Examples/Reading WorkBook Data/exampleWorkBookReader03.php @@ -26,7 +26,7 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/'); include 'PHPExcel/IOFactory.php'; -$inputFileType = 'Excel2007'; +$inputFileType = 'Xlsx'; $inputFileName = './sampleData/example1.xlsx'; /** Create a new Reader of the type defined in $inputFileType **/ diff --git a/Documentation/markdown/CalculationEngine/FunctionReference/01-Introduction.md b/Documentation/markdown/CalculationEngine/FunctionReference/01-Introduction.md index 2ea3a505..32d11fd0 100644 --- a/Documentation/markdown/CalculationEngine/FunctionReference/01-Introduction.md +++ b/Documentation/markdown/CalculationEngine/FunctionReference/01-Introduction.md @@ -6,6 +6,6 @@ The up-to-date F.A.Q. page for PHPExcel can be found on [http://www.codeplex.com ### Formulas don’t seem to be calculated in Excel2003 using compatibility pack? -This is normal behaviour of the compatibility pack, Excel2007 displays this correctly. Use PHPExcel_Writer_Excel5 if you really need calculated values, or force recalculation in Excel2003. +This is normal behaviour of the compatibility pack, Xlsx displays this correctly. Use PHPExcel_Writer_Excel5 if you really need calculated values, or force recalculation in Excel2003. [1]: http://www.codeplex.com/PHPExcel/Wiki/View.aspx?title=FAQ&referringTitle=Requirements diff --git a/Documentation/markdown/CalculationEngine/FunctionReference/03-03-Date-and-Time-Functions.md b/Documentation/markdown/CalculationEngine/FunctionReference/03-03-Date-and-Time-Functions.md index 68c9e357..ab1c4c90 100644 --- a/Documentation/markdown/CalculationEngine/FunctionReference/03-03-Date-and-Time-Functions.md +++ b/Documentation/markdown/CalculationEngine/FunctionReference/03-03-Date-and-Time-Functions.md @@ -299,7 +299,7 @@ DATEVALUE uses the php date/time object implementation of strtotime() (which can __WARNING:-__ PHPExcel accepts a wider range of date formats than MS Excel, so it is entirely possible that Excel will return a #VALUE! error when passed a date string that it can’t interpret, while PHPExcel is able to translate that same string into a correct date value. -Care should be taken in workbooks that use string formatted dates in calculations when writing to Excel5 or Excel2007. +Care should be taken in workbooks that use string formatted dates in calculations when writing to Excel5 or Xlsx. #### DAY diff --git a/Documentation/markdown/Features/Autofilters/03-Autofilter-Expressions.md b/Documentation/markdown/Features/Autofilters/03-Autofilter-Expressions.md index fd659017..e03f622d 100644 --- a/Documentation/markdown/Features/Autofilters/03-Autofilter-Expressions.md +++ b/Documentation/markdown/Features/Autofilters/03-Autofilter-Expressions.md @@ -3,7 +3,7 @@ ## Autofilter Expressions -PHPEXcel 1.7.8 introduced the ability to actually create, read and write filter expressions; initially only for Excel2007 files, but later releases will extend this to other formats. +PHPEXcel 1.7.8 introduced the ability to actually create, read and write filter expressions; initially only for Xlsx files, but later releases will extend this to other formats. To apply a filter expression to an autoFilter range, you first need to identify which column you're going to be applying this filter to. diff --git a/Documentation/markdown/Overview/01-Getting-Started.md b/Documentation/markdown/Overview/01-Getting-Started.md index a6eb77d1..be5780c2 100644 --- a/Documentation/markdown/Overview/01-Getting-Started.md +++ b/Documentation/markdown/Overview/01-Getting-Started.md @@ -73,19 +73,19 @@ It is necessary to use UTF-8 encoding for all texts in PHPExcel. If the script u Make sure you meet all requirements, especially php_zip extension should be enabled. -The ZipArchive class is only required when reading or writing formats that use Zip compression (Excel2007 and OOCalc). Since version 1.7.6 the PCLZip library has been bundled with PHPExcel as an alternative to the ZipArchive class. +The ZipArchive class is only required when reading or writing formats that use Zip compression (Xlsx and OOCalc). Since version 1.7.6 the PCLZip library has been bundled with PHPExcel as an alternative to the ZipArchive class. This can be enabled by calling: ```php PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP); ``` -*before* calling the save method of the Excel2007 Writer. +*before* calling the save method of the Xlsx Writer. You can revert to using ZipArchive by calling: ```php PHPExcel_Settings::setZipClass(PHPExcel_Settings::ZIPARCHIVE); ``` -At present, this only allows you to write Excel2007 files without the need for ZipArchive (not to read Excel2007 or OOCalc) +At present, this only allows you to write Xlsx files without the need for ZipArchive (not to read Xlsx or OOCalc) ##### Excel 2007 cannot open the file generated by PHPExcel_Writer_2007 on Windows @@ -95,7 +95,7 @@ Some older versions of the 5.2.x php_zip extension on Windows contain an error w Alternatively, upgrading to at least PHP 5.2.9 should solve the problem. -If you can't locate a clean copy of ZipArchive, then you can use the PCLZip library as an alternative when writing Excel2007 files, as described above. +If you can't locate a clean copy of ZipArchive, then you can use the PCLZip library as an alternative when writing Xlsx files, as described above. ##### Fatal error: Allowed memory size of xxx bytes exhausted (tried to allocate yyy bytes) in zzz on line aaa @@ -122,7 +122,7 @@ We are slowly building up a list of features, together with the different reader ##### Formulas don't seem to be calculated in Excel2003 using compatibility pack? -This is normal behaviour of the compatibility pack, Excel2007 displays this correctly. Use PHPExcel_Writer_Excel5 if you really need calculated values, or force recalculation in Excel2003. +This is normal behaviour of the compatibility pack, Xlsx displays this correctly. Use PHPExcel_Writer_Excel5 if you really need calculated values, or force recalculation in Excel2003. ##### Setting column width is not 100% accurate @@ -177,5 +177,5 @@ Thanks to peterrlynch for the following advice on resolving issues between the [ [21]: http://journal.mycom.co.jp/articles/2009/03/06/phpexcel/index.html -[^phpzip_footnote]: __php_zip__ is only needed by __PHPExcel_Reader_Excel2007__, __PHPExcel_Writer_Excel2007__ and __PHPExcel_Reader_OOCalc__. In other words, if you need PHPExcel to handle .xlsx or .ods files you will need the zip extension, but otherwise not.
You can remove this dependency for writing Excel2007 files (though not yet for reading) by using the PCLZip library that is bundled with PHPExcel. See the FAQ section of this document for details about this. PCLZip does have a dependency on PHP's zlib extension being enabled. +[^phpzip_footnote]: __php_zip__ is only needed by __PHPExcel_Reader_Excel2007__, __PHPExcel_Writer_Excel2007__ and __PHPExcel_Reader_OOCalc__. In other words, if you need PHPExcel to handle .xlsx or .ods files you will need the zip extension, but otherwise not.
You can remove this dependency for writing Xlsx files (though not yet for reading) by using the PCLZip library that is bundled with PHPExcel. See the FAQ section of this document for details about this. PCLZip does have a dependency on PHP's zlib extension being enabled. diff --git a/Documentation/markdown/Overview/07-Accessing-Cells.md b/Documentation/markdown/Overview/07-Accessing-Cells.md index e63b45b2..8493021f 100644 --- a/Documentation/markdown/Overview/07-Accessing-Cells.md +++ b/Documentation/markdown/Overview/07-Accessing-Cells.md @@ -127,7 +127,7 @@ $objPHPExcel->getActiveSheet()->getStyle('A10') ![07-simple-example-1.png](./images/07-simple-example-1.png "") -**Note** that not all complex format masks such as this one will work when retrieving a formatted value to display "on screen", or for certain writers such as HTML or PDF, but it will work with the true spreadsheet writers (Excel2007 and Excel5). +**Note** that not all complex format masks such as this one will work when retrieving a formatted value to display "on screen", or for certain writers such as HTML or PDF, but it will work with the true spreadsheet writers (Xlsx and Excel5). ### Setting a range of cells from an array @@ -266,7 +266,7 @@ The easiest way to loop cells is by using iterators. Using iterators, one can us Below is an example where we read all the values in a worksheet and display them in a table. ```php -$objReader = PHPExcel_IOFactory::createReader('Excel2007'); +$objReader = PHPExcel_IOFactory::createReader('Xlsx'); $objReader->setReadDataOnly(TRUE); $objPHPExcel = $objReader->load("test.xlsx"); @@ -304,7 +304,7 @@ Note: In PHPExcel column index is 0-based while row index is 1-based. That means Below is an example where we read all the values in a worksheet and display them in a table. ```php -$objReader = PHPExcel_IOFactory::createReader('Excel2007'); +$objReader = PHPExcel_IOFactory::createReader('Xlsx'); $objReader->setReadDataOnly(TRUE); $objPHPExcel = $objReader->load("test.xlsx"); @@ -331,7 +331,7 @@ echo '' . PHP_EOL; Alternatively, you can take advantage of PHP's "Perl-style" character incrementors to loop through the cells by coordinate: ```php -$objReader = PHPExcel_IOFactory::createReader('Excel2007'); +$objReader = PHPExcel_IOFactory::createReader('Xlsx'); $objReader->setReadDataOnly(TRUE); $objPHPExcel = $objReader->load("test.xlsx"); diff --git a/Documentation/markdown/Overview/08-Recipes.md b/Documentation/markdown/Overview/08-Recipes.md index 0ea32d63..9156eb7d 100644 --- a/Documentation/markdown/Overview/08-Recipes.md +++ b/Documentation/markdown/Overview/08-Recipes.md @@ -328,7 +328,7 @@ The first occurrence of the following codes turns the formatting ON, the second Superscript and subscript cannot both be ON at same time. Whichever comes first wins and the other is ignored, while the first is ON. -The following codes are supported by Excel2007: +The following codes are supported by Xlsx: Code | Meaning -----------------------|----------- @@ -545,10 +545,10 @@ $objPHPExcel->getActiveSheet()->getStyle('A1')->getNumberFormat() __Tip__ The rules for composing a number format code in Excel can be rather complicated. Sometimes you know how to create some number format in Microsoft Office Excel, but don't know what the underlying number format code looks like. How do you find it? -The readers shipped with PHPExcel come to the rescue. Load your template workbook using e.g. Excel2007 reader to reveal the number format code. Example how read a number format code for cell A1: +The readers shipped with PHPExcel come to the rescue. Load your template workbook using e.g. Xlsx reader to reveal the number format code. Example how read a number format code for cell A1: ```php -$objReader = PHPExcel_IOFactory::createReader('Excel2007'); +$objReader = PHPExcel_IOFactory::createReader('Xlsx'); $objPHPExcel = $objReader->load('template.xlsx'); var_dump($objPHPExcel->getActiveSheet()->getStyle('A1')->getNumberFormat()->getFormatCode()); ``` @@ -745,7 +745,7 @@ $objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); ### Setting data validation on a cell -Data validation is a powerful feature of Excel2007. It allows to specify an input filter on the data that can be inserted in a specific cell. This filter can be a range (i.e. value must be between 0 and 10), a list (i.e. value must be picked from a list), ... +Data validation is a powerful feature of Xlsx. It allows to specify an input filter on the data that can be inserted in a specific cell. This filter can be a range (i.e. value must be between 0 and 10), a list (i.e. value must be picked from a list), ... The following piece of code only allows numbers between 10 and 20 to be entered in cell B3: @@ -1078,7 +1078,7 @@ header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetm header('Content-Disposition: attachment;filename="myfile.xlsx"'); header('Cache-Control: max-age=0'); -$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); +$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Xlsx'); $objWriter->save('php://output'); ``` diff --git a/Documentation/markdown/Overview/10-Reading-and-Writing.md b/Documentation/markdown/Overview/10-Reading-and-Writing.md index 1468abc7..312f4c69 100644 --- a/Documentation/markdown/Overview/10-Reading-and-Writing.md +++ b/Documentation/markdown/Overview/10-Reading-and-Writing.md @@ -35,7 +35,7 @@ $objReader->load("05featuredemo.xlsx"); You can create a PHPExcel_Reader_IReader instance using PHPExcel_IOFactory in explicit mode using the following code sample: ```php -$objReader = PHPExcel_IOFactory::createReader("Excel2007"); +$objReader = PHPExcel_IOFactory::createReader("Xlsx"); $objPHPExcel = $objReader->load("05featuredemo.xlsx"); ``` @@ -46,13 +46,13 @@ Note that automatic type resolving mode is slightly slower than explicit mode. You can create a PHPExcel_Writer_Iwriter instance using PHPExcel_IOFactory: ```php -$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, "Excel2007"); +$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, "Xlsx"); $objWriter->save("05featuredemo.xlsx"); ``` ### Excel 2007 (SpreadsheetML) file format -Excel2007 file format is the main file format of PHPExcel. It allows outputting the in-memory spreadsheet to a .xlsx file. +Xlsx file format is the main file format of PHPExcel. It allows outputting the in-memory spreadsheet to a .xlsx file. #### PHPExcel_Reader_Excel2007 @@ -131,7 +131,7 @@ $objWriter->save("05featuredemo.xlsx"); ##### Office 2003 compatibility pack -Because of a bug in the Office2003 compatibility pack, there can be some small issues when opening Excel2007 spreadsheets (mostly related to formula calculation). You can enable Office2003 compatibility with the following code: +Because of a bug in the Office2003 compatibility pack, there can be some small issues when opening Xlsx spreadsheets (mostly related to formula calculation). You can enable Office2003 compatibility with the following code: ``` $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel); diff --git a/Documentation/markdown/ReadingSpreadsheetFiles/01-File-Formats.md b/Documentation/markdown/ReadingSpreadsheetFiles/01-File-Formats.md index d8916643..8ada4818 100644 --- a/Documentation/markdown/ReadingSpreadsheetFiles/01-File-Formats.md +++ b/Documentation/markdown/ReadingSpreadsheetFiles/01-File-Formats.md @@ -15,7 +15,7 @@ The Microsoft Excel™ Binary file format (BIFF5 and BIFF8) is a binary file for Microsoft Excel™ 2003 included options for a file format called SpreadsheetML. This file is a zipped XML document. It is not very common, but its core features are supported. Documentation for the format can be found at [http://msdn.microsoft.com/en-us/library/aa140066%28office.10%29.aspx][3] though it’s sadly rather sparse in its detail. -### Excel2007 +### Xlsx Microsoft Excel™ 2007 shipped with a new file format, namely Microsoft Office Open XML SpreadsheetML, and Excel 2010 extended this still further with its new features such as sparklines. These files typically have an extension of .xlsx. This format is based around a zipped collection of eXtensible Markup Language (XML) files. Microsoft Office Open XML SpreadsheetML is mostly standardized in ECMA 376 ([http://www.ecma-international.org/news/TC45_current_work/TC45_available_docs.htm][4]) and ISO 29500. diff --git a/Documentation/markdown/ReadingSpreadsheetFiles/04-Loading-with-a-Reader.md b/Documentation/markdown/ReadingSpreadsheetFiles/04-Loading-with-a-Reader.md index 94d07aaa..5f8c3079 100644 --- a/Documentation/markdown/ReadingSpreadsheetFiles/04-Loading-with-a-Reader.md +++ b/Documentation/markdown/ReadingSpreadsheetFiles/04-Loading-with-a-Reader.md @@ -25,7 +25,7 @@ Alternatively, you can use the IO Factory's createReader() method to instantiate ```php $inputFileType = 'Excel5'; -// $inputFileType = 'Excel2007'; +// $inputFileType = 'Xlsx'; // $inputFileType = 'Excel2003XML'; // $inputFileType = 'OOCalc'; // $inputFileType = 'SYLK'; diff --git a/Documentation/markdown/ReadingSpreadsheetFiles/05-Reader-Options.md b/Documentation/markdown/ReadingSpreadsheetFiles/05-Reader-Options.md index 137fd1e8..d355fe3d 100644 --- a/Documentation/markdown/ReadingSpreadsheetFiles/05-Reader-Options.md +++ b/Documentation/markdown/ReadingSpreadsheetFiles/05-Reader-Options.md @@ -27,10 +27,10 @@ The Gnumeric loader has been written to read the format masks for date values ev Reading Only Data from a Spreadsheet File applies to Readers: -Reader | Y/N |Reader | Y/N |Reader | Y/N | -----------|:---:|--------|:---:|--------------|:---:| -Excel2007 | YES | Excel5 | YES | Excel2003XML | YES | -OOCalc | YES | SYLK | NO | Gnumeric | YES | +Reader | Y/N |Reader | Y/N |Reader | Y/N | +----------|:---:|--------|:---:|--------------|:---:| +Xlsx | YES | Excel5 | YES | Excel2003XML | YES | +OOCalc | YES | SYLK | NO | Gnumeric | YES | CSV | NO | HTML | NO ### Reading Only Named WorkSheets from a File @@ -40,31 +40,31 @@ If your workbook contains a number of worksheets, but you are only interested in To read a single sheet, you can pass that sheet name as a parameter to the setLoadSheetsOnly() method. ```php -$inputFileType = 'Excel5'; -$inputFileName = './sampleData/example1.xls'; -$sheetname = 'Data Sheet #2'; +$inputFileType = 'Excel5'; +$inputFileName = './sampleData/example1.xls'; +$sheetname = 'Data Sheet #2'; -/** Create a new Reader of the type defined in $inputFileType **/ -$objReader = PHPExcel_IOFactory::createReader($inputFileType); -/** Advise the Reader of which WorkSheets we want to load **/ -$objReader->setLoadSheetsOnly($sheetname); -/** Load $inputFileName to a PHPExcel Object **/ -$objPHPExcel = $objReader->load($inputFileName); +/** Create a new Reader of the type defined in $inputFileType **/ +$objReader = PHPExcel_IOFactory::createReader($inputFileType); +/** Advise the Reader of which WorkSheets we want to load **/ +$objReader->setLoadSheetsOnly($sheetname); +/** Load $inputFileName to a PHPExcel Object **/ +$objPHPExcel = $objReader->load($inputFileName); ``` > See Examples/Reader/exampleReader07.php for a working example of this code. If you want to read more than just a single sheet, you can pass a list of sheet names as an array parameter to the setLoadSheetsOnly() method. ```php -$inputFileType = 'Excel5'; -$inputFileName = './sampleData/example1.xls'; -$sheetnames = array('Data Sheet #1','Data Sheet #3'); +$inputFileType = 'Excel5'; +$inputFileName = './sampleData/example1.xls'; +$sheetnames = array('Data Sheet #1','Data Sheet #3'); -/** Create a new Reader of the type defined in $inputFileType **/ -$objReader = PHPExcel_IOFactory::createReader($inputFileType); -/** Advise the Reader of which WorkSheets we want to load **/ -$objReader->setLoadSheetsOnly($sheetnames); -/** Load $inputFileName to a PHPExcel Object **/ +/** Create a new Reader of the type defined in $inputFileType **/ +$objReader = PHPExcel_IOFactory::createReader($inputFileType); +/** Advise the Reader of which WorkSheets we want to load **/ +$objReader->setLoadSheetsOnly($sheetnames); +/** Load $inputFileName to a PHPExcel Object **/ $objPHPExcel = $objReader->load($inputFileName); ``` > See Examples/Reader/exampleReader08.php for a working example of this code. @@ -86,10 +86,10 @@ $objPHPExcel = $objReader->load($inputFileName); Reading Only Named WorkSheets from a File applies to Readers: -Reader | Y/N |Reader | Y/N |Reader | Y/N | -----------|:---:|--------|:---:|--------------|:---:| -Excel2007 | YES | Excel5 | YES | Excel2003XML | YES | -OOCalc | YES | SYLK | NO | Gnumeric | YES | +Reader | Y/N |Reader | Y/N |Reader | Y/N | +----------|:---:|--------|:---:|--------------|:---:| +Xlsx | YES | Excel5 | YES | Excel2003XML | YES | +OOCalc | YES | SYLK | NO | Gnumeric | YES | CSV | NO | HTML | NO ### Reading Only Specific Columns and Rows from a File (Read Filters) @@ -97,66 +97,66 @@ CSV | NO | HTML | NO If you are only interested in reading part of a worksheet, then you can write a filter class that identifies whether or not individual cells should be read by the loader. A read filter must implement the PHPExcel_Reader_IReadFilter interface, and contain a readCell() method that accepts arguments of $column, $row and $worksheetName, and return a boolean true or false that indicates whether a workbook cell identified by those arguments should be read or not. ```php -$inputFileType = 'Excel5'; -$inputFileName = './sampleData/example1.xls'; -$sheetname = 'Data Sheet #3'; +$inputFileType = 'Excel5'; +$inputFileName = './sampleData/example1.xls'; +$sheetname = 'Data Sheet #3'; -/** Define a Read Filter class implementing PHPExcel_Reader_IReadFilter */ -class MyReadFilter implements PHPExcel_Reader_IReadFilter -{ - public function readCell($column, $row, $worksheetName = '') { - // Read rows 1 to 7 and columns A to E only - if ($row >= 1 && $row <= 7) { - if (in_array($column,range('A','E'))) { - return true; - } - } - return false; - } -} +/** Define a Read Filter class implementing PHPExcel_Reader_IReadFilter */ +class MyReadFilter implements PHPExcel_Reader_IReadFilter +{ + public function readCell($column, $row, $worksheetName = '') { + // Read rows 1 to 7 and columns A to E only + if ($row >= 1 && $row <= 7) { + if (in_array($column,range('A','E'))) { + return true; + } + } + return false; + } +} -/** Create an Instance of our Read Filter **/ -$filterSubset = new MyReadFilter(); +/** Create an Instance of our Read Filter **/ +$filterSubset = new MyReadFilter(); -/** Create a new Reader of the type defined in $inputFileType **/ -$objReader = PHPExcel_IOFactory::createReader($inputFileType); -/** Tell the Reader that we want to use the Read Filter **/ -$objReader->setReadFilter($filterSubset); -/** Load only the rows and columns that match our filter to PHPExcel **/ -$objPHPExcel = $objReader->load($inputFileName); +/** Create a new Reader of the type defined in $inputFileType **/ +$objReader = PHPExcel_IOFactory::createReader($inputFileType); +/** Tell the Reader that we want to use the Read Filter **/ +$objReader->setReadFilter($filterSubset); +/** Load only the rows and columns that match our filter to PHPExcel **/ +$objPHPExcel = $objReader->load($inputFileName); ``` > See Examples/Reader/exampleReader09.php for a working example of this code. This example is not particularly useful, because it can only be used in a very specific circumstance (when you only want cells in the range A1:E7 from your worksheet. A generic Read Filter would probably be more useful: ```php -/** Define a Read Filter class implementing PHPExcel_Reader_IReadFilter */ -class MyReadFilter implements PHPExcel_Reader_IReadFilter -{ - private $_startRow = 0; - private $_endRow = 0; - private $_columns = array(); +/** Define a Read Filter class implementing PHPExcel_Reader_IReadFilter */ +class MyReadFilter implements PHPExcel_Reader_IReadFilter +{ + private $_startRow = 0; + private $_endRow = 0; + private $_columns = array(); - /** Get the list of rows and columns to read */ - public function __construct($startRow, $endRow, $columns) { - $this->_startRow = $startRow; - $this->_endRow = $endRow; - $this->_columns = $columns; - } + /** Get the list of rows and columns to read */ + public function __construct($startRow, $endRow, $columns) { + $this->_startRow = $startRow; + $this->_endRow = $endRow; + $this->_columns = $columns; + } - public function readCell($column, $row, $worksheetName = '') { - // Only read the rows and columns that were configured - if ($row >= $this->_startRow && $row <= $this->_endRow) { - if (in_array($column,$this->_columns)) { - return true; - } - } - return false; - } -} + public function readCell($column, $row, $worksheetName = '') { + // Only read the rows and columns that were configured + if ($row >= $this->_startRow && $row <= $this->_endRow) { + if (in_array($column,$this->_columns)) { + return true; + } + } + return false; + } +} -/** Create an Instance of our Read Filter, passing in the cell range **/ +/** Create an Instance of our Read Filter, passing in the cell range **/ $filterSubset = new MyReadFilter(9,15,range('G','K')); ``` > See Examples/Reader/exampleReader10.php for a working example of this code. @@ -164,61 +164,61 @@ $filterSubset = new MyReadFilter(9,15,range('G','K')); This can be particularly useful for conserving memory, by allowing you to read and process a large workbook in “chunks”: an example of this usage might be when transferring data from an Excel worksheet to a database. ```php -$inputFileType = 'Excel5'; -$inputFileName = './sampleData/example2.xls'; +$inputFileType = 'Excel5'; +$inputFileName = './sampleData/example2.xls'; -/** Define a Read Filter class implementing PHPExcel_Reader_IReadFilter */ -class chunkReadFilter implements PHPExcel_Reader_IReadFilter -{ - private $_startRow = 0; - private $_endRow = 0; +/** Define a Read Filter class implementing PHPExcel_Reader_IReadFilter */ +class chunkReadFilter implements PHPExcel_Reader_IReadFilter +{ + private $_startRow = 0; + private $_endRow = 0; - /** Set the list of rows that we want to read */ - public function setRows($startRow, $chunkSize) { - $this->_startRow = $startRow; - $this->_endRow = $startRow + $chunkSize; - } + /** Set the list of rows that we want to read */ + public function setRows($startRow, $chunkSize) { + $this->_startRow = $startRow; + $this->_endRow = $startRow + $chunkSize; + } - public function readCell($column, $row, $worksheetName = '') { - // Only read the heading row, and the configured rows - if (($row == 1) || ($row >= $this->_startRow && $row < $this->_endRow)) { - return true; - } - return false; - } -} + public function readCell($column, $row, $worksheetName = '') { + // Only read the heading row, and the configured rows + if (($row == 1) || ($row >= $this->_startRow && $row < $this->_endRow)) { + return true; + } + return false; + } +} -/** Create a new Reader of the type defined in $inputFileType **/ -$objReader = PHPExcel_IOFactory::createReader($inputFileType); +/** Create a new Reader of the type defined in $inputFileType **/ +$objReader = PHPExcel_IOFactory::createReader($inputFileType); -/** Define how many rows we want to read for each "chunk" **/ -$chunkSize = 2048; -/** Create a new Instance of our Read Filter **/ -$chunkFilter = new chunkReadFilter(); +/** Define how many rows we want to read for each "chunk" **/ +$chunkSize = 2048; +/** Create a new Instance of our Read Filter **/ +$chunkFilter = new chunkReadFilter(); -/** Tell the Reader that we want to use the Read Filter **/ -$objReader->setReadFilter($chunkFilter); +/** Tell the Reader that we want to use the Read Filter **/ +$objReader->setReadFilter($chunkFilter); -/** Loop to read our worksheet in "chunk size" blocks **/ -for ($startRow = 2; $startRow <= 65536; $startRow += $chunkSize) { - /** Tell the Read Filter which rows we want this iteration **/ - $chunkFilter->setRows($startRow,$chunkSize); - /** Load only the rows that match our filter **/ - $objPHPExcel = $objReader->load($inputFileName); - // Do some processing here -} +/** Loop to read our worksheet in "chunk size" blocks **/ +for ($startRow = 2; $startRow <= 65536; $startRow += $chunkSize) { + /** Tell the Read Filter which rows we want this iteration **/ + $chunkFilter->setRows($startRow,$chunkSize); + /** Load only the rows that match our filter **/ + $objPHPExcel = $objReader->load($inputFileName); + // Do some processing here +} ``` > See Examples/Reader/exampleReader12.php for a working example of this code. Using Read Filters applies to: -Reader | Y/N |Reader | Y/N |Reader | Y/N | -----------|:---:|--------|:---:|--------------|:---:| -Excel2007 | YES | Excel5 | YES | Excel2003XML | YES | -OOCalc | YES | SYLK | NO | Gnumeric | YES | +Reader | Y/N |Reader | Y/N |Reader | Y/N | +----------|:---:|--------|:---:|--------------|:---:| +Xlsx | YES | Excel5 | YES | Excel2003XML | YES | +OOCalc | YES | SYLK | NO | Gnumeric | YES | CSV | YES | HTML | NO ### Combining Multiple Files into a Single PHPExcel Object @@ -226,35 +226,35 @@ CSV | YES | HTML | NO While you can limit the number of worksheets that are read from a workbook file using the setLoadSheetsOnly() method, certain readers also allow you to combine several individual "sheets" from different files into a single PHPExcel object, where each individual file is a single worksheet within that workbook. For each file that you read, you need to indicate which worksheet index it should be loaded into using the setSheetIndex() method of the $objReader, then use the loadIntoExisting() method rather than the load() method to actually read the file into that worksheet. ```php -$inputFileType = 'CSV'; +$inputFileType = 'CSV'; $inputFileNames = array('./sampleData/example1.csv', './sampleData/example2.csv' './sampleData/example3.csv' -); +); -/** Create a new Reader of the type defined in $inputFileType **/ -$objReader = PHPExcel_IOFactory::createReader($inputFileType); +/** Create a new Reader of the type defined in $inputFileType **/ +$objReader = PHPExcel_IOFactory::createReader($inputFileType); -/** Extract the first named file from the array list **/ -$inputFileName = array_shift($inputFileNames); -/** Load the initial file to the first worksheet in a PHPExcel Object **/ -$objPHPExcel = $objReader->load($inputFileName); -/** Set the worksheet title (to the filename that we've loaded) **/ +/** Extract the first named file from the array list **/ +$inputFileName = array_shift($inputFileNames); +/** Load the initial file to the first worksheet in a PHPExcel Object **/ +$objPHPExcel = $objReader->load($inputFileName); +/** Set the worksheet title (to the filename that we've loaded) **/ $objPHPExcel->getActiveSheet() - ->setTitle(pathinfo($inputFileName,PATHINFO_BASENAME)); + ->setTitle(pathinfo($inputFileName,PATHINFO_BASENAME)); -/** Loop through all the remaining files in the list **/ -foreach($inputFileNames as $sheet => $inputFileName) { - /** Increment the worksheet index pointer for the Reader **/ - $objReader->setSheetIndex($sheet+1); - /** Load the current file into a new worksheet in PHPExcel **/ - $objReader->loadIntoExisting($inputFileName,$objPHPExcel); - /** Set the worksheet title (to the filename that we've loaded) **/ +/** Loop through all the remaining files in the list **/ +foreach($inputFileNames as $sheet => $inputFileName) { + /** Increment the worksheet index pointer for the Reader **/ + $objReader->setSheetIndex($sheet+1); + /** Load the current file into a new worksheet in PHPExcel **/ + $objReader->loadIntoExisting($inputFileName,$objPHPExcel); + /** Set the worksheet title (to the filename that we've loaded) **/ $objPHPExcel->getActiveSheet() - ->setTitle(pathinfo($inputFileName,PATHINFO_BASENAME)); -} + ->setTitle(pathinfo($inputFileName,PATHINFO_BASENAME)); +} ``` > See Examples/Reader/exampleReader13.php for a working example of this code. @@ -262,56 +262,56 @@ Note that using the same sheet index for multiple sheets won't append files into Combining Multiple Files into a Single PHPExcel Object applies to: -Reader | Y/N |Reader | Y/N |Reader | Y/N | -----------|:---:|--------|:---:|--------------|:---:| -Excel2007 | NO | Excel5 | NO | Excel2003XML | NO | -OOCalc | NO | SYLK | YES | Gnumeric | NO | +Reader | Y/N |Reader | Y/N |Reader | Y/N | +----------|:---:|--------|:---:|--------------|:---:| +Xlsx | NO | Excel5 | NO | Excel2003XML | NO | +OOCalc | NO | SYLK | YES | Gnumeric | NO | CSV | YES | HTML | NO ### Combining Read Filters with the setSheetIndex() method to split a large CSV file across multiple Worksheets -An Excel5 BIFF .xls file is limited to 65536 rows in a worksheet, while the Excel2007 Microsoft Office Open XML SpreadsheetML .xlsx file is limited to 1,048,576 rows in a worksheet; but a CSV file is not limited other than by available disk space. This means that we wouldn’t ordinarily be able to read all the rows from a very large CSV file that exceeded those limits, and save it as an Excel5 or Excel2007 file. However, by using Read Filters to read the CSV file in “chunks” (using the chunkReadFilter Class that we defined in section REF _Ref275604563 \r \p 5.3 above), and the setSheetIndex() method of the $objReader, we can split the CSV file across several individual worksheets. +An Excel5 BIFF .xls file is limited to 65536 rows in a worksheet, while the Xlsx Microsoft Office Open XML SpreadsheetML .xlsx file is limited to 1,048,576 rows in a worksheet; but a CSV file is not limited other than by available disk space. This means that we wouldn’t ordinarily be able to read all the rows from a very large CSV file that exceeded those limits, and save it as an Excel5 or Xlsx file. However, by using Read Filters to read the CSV file in “chunks” (using the chunkReadFilter Class that we defined in section REF _Ref275604563 \r \p 5.3 above), and the setSheetIndex() method of the $objReader, we can split the CSV file across several individual worksheets. ```php -$inputFileType = 'CSV'; -$inputFileName = './sampleData/example2.csv'; +$inputFileType = 'CSV'; +$inputFileName = './sampleData/example2.csv'; -echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'
'; -/** Create a new Reader of the type defined in $inputFileType **/ -$objReader = PHPExcel_IOFactory::createReader($inputFileType); +echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'
'; +/** Create a new Reader of the type defined in $inputFileType **/ +$objReader = PHPExcel_IOFactory::createReader($inputFileType); -/** Define how many rows we want to read for each "chunk" **/ -$chunkSize = 65530; -/** Create a new Instance of our Read Filter **/ -$chunkFilter = new chunkReadFilter(); +/** Define how many rows we want to read for each "chunk" **/ +$chunkSize = 65530; +/** Create a new Instance of our Read Filter **/ +$chunkFilter = new chunkReadFilter(); -/** Tell the Reader that we want to use the Read Filter **/ +/** Tell the Reader that we want to use the Read Filter **/ /** and that we want to store it in contiguous rows/columns **/ $objReader->setReadFilter($chunkFilter) ->setContiguous(true); -/** Instantiate a new PHPExcel object manually **/ -$objPHPExcel = new PHPExcel(); +/** Instantiate a new PHPExcel object manually **/ +$objPHPExcel = new PHPExcel(); -/** Set a sheet index **/ -$sheet = 0; -/** Loop to read our worksheet in "chunk size" blocks **/ -/** $startRow is set to 2 initially because we always read the headings in row #1 **/ -for ($startRow = 2; $startRow <= 1000000; $startRow += $chunkSize) { - /** Tell the Read Filter which rows we want to read this loop **/ - $chunkFilter->setRows($startRow,$chunkSize); +/** Set a sheet index **/ +$sheet = 0; +/** Loop to read our worksheet in "chunk size" blocks **/ +/** $startRow is set to 2 initially because we always read the headings in row #1 **/ +for ($startRow = 2; $startRow <= 1000000; $startRow += $chunkSize) { + /** Tell the Read Filter which rows we want to read this loop **/ + $chunkFilter->setRows($startRow,$chunkSize); - /** Increment the worksheet index pointer for the Reader **/ - $objReader->setSheetIndex($sheet); - /** Load only the rows that match our filter into a new worksheet **/ - $objReader->loadIntoExisting($inputFileName,$objPHPExcel); + /** Increment the worksheet index pointer for the Reader **/ + $objReader->setSheetIndex($sheet); + /** Load only the rows that match our filter into a new worksheet **/ + $objReader->loadIntoExisting($inputFileName,$objPHPExcel); /** Set the worksheet title for the sheet that we've justloaded) **/ - /** and increment the sheet index as well **/ - $objPHPExcel->getActiveSheet()->setTitle('Country Data #'.(++$sheet)); -} + /** and increment the sheet index as well **/ + $objPHPExcel->getActiveSheet()->setTitle('Country Data #'.(++$sheet)); +} ``` > See Examples/Reader/exampleReader14.php for a working example of this code. @@ -323,10 +323,10 @@ For example, if the filter returned true for cells in the range B2:C3, then with Splitting a single loaded file across multiple worksheets applies to: -Reader | Y/N |Reader | Y/N |Reader | Y/N | -----------|:---:|--------|:---:|--------------|:---:| -Excel2007 | NO | Excel5 | NO | Excel2003XML | NO | -OOCalc | NO | SYLK | NO | Gnumeric | NO | +Reader | Y/N |Reader | Y/N |Reader | Y/N | +----------|:---:|--------|:---:|--------------|:---:| +Xlsx | NO | Excel5 | NO | Excel2003XML | NO | +OOCalc | NO | SYLK | NO | Gnumeric | NO | CSV | YES | HTML | NO ### Pipe or Tab Separated Value Files @@ -334,31 +334,31 @@ CSV | YES | HTML | NO The CSV loader defaults to loading a file where comma is used as the separator, but you can modify this to load tab- or pipe-separated value files using the setDelimiter() method. ```php -$inputFileType = 'CSV'; -$inputFileName = './sampleData/example1.tsv'; +$inputFileType = 'CSV'; +$inputFileName = './sampleData/example1.tsv'; -/** Create a new Reader of the type defined in $inputFileType **/ $objReader = PHPExcel_IOFactory::createReader($inputFileType); -/** Set the delimiter to a TAB character **/ -$objReader->setDelimiter("\t"); +/** Create a new Reader of the type defined in $inputFileType **/ $objReader = PHPExcel_IOFactory::createReader($inputFileType); +/** Set the delimiter to a TAB character **/ +$objReader->setDelimiter("\t"); // $objReader->setDelimiter('|'); -/** Load the file to a PHPExcel Object **/ +/** Load the file to a PHPExcel Object **/ $objPHPExcel = $objReader->load($inputFileName); ``` > See Examples/Reader/exampleReader15.php for a working example of this code. In addition to the delimiter, you can also use the following methods to set other attributes for the data load: -setEnclosure() | default is " -setLineEnding() | default is PHP_EOL -setInputEncoding() | default is UTF-8 +setEnclosure() | default is " +setLineEnding() | default is PHP_EOL +setInputEncoding() | default is UTF-8 Setting CSV delimiter applies to: -Reader | Y/N |Reader | Y/N |Reader | Y/N | -----------|:---:|--------|:---:|--------------|:---:| -Excel2007 | NO | Excel5 | NO | Excel2003XML | NO | -OOCalc | NO | SYLK | NO | Gnumeric | NO | +Reader | Y/N |Reader | Y/N |Reader | Y/N | +----------|:---:|--------|:---:|--------------|:---:| +Xlsx | NO | Excel5 | NO | Excel2003XML | NO | +OOCalc | NO | SYLK | NO | Gnumeric | NO | CSV | YES | HTML | NO ### A Brief Word about the Advanced Value Binder @@ -370,23 +370,23 @@ A Value Binder is a class that implement the PHPExcel_Cell_IValueBinder interfac So using a Value Binder allows a great deal more flexibility in the loader logic when reading unformatted text files. ```php -/** Tell PHPExcel that we want to use the Advanced Value Binder **/ -PHPExcel_Cell::setValueBinder( new PHPExcel_Cell_AdvancedValueBinder() ); +/** Tell PHPExcel that we want to use the Advanced Value Binder **/ +PHPExcel_Cell::setValueBinder( new PHPExcel_Cell_AdvancedValueBinder() ); -$inputFileType = 'CSV'; -$inputFileName = './sampleData/example1.tsv'; +$inputFileType = 'CSV'; +$inputFileName = './sampleData/example1.tsv'; -$objReader = PHPExcel_IOFactory::createReader($inputFileType); -$objReader->setDelimiter("\t"); +$objReader = PHPExcel_IOFactory::createReader($inputFileType); +$objReader->setDelimiter("\t"); $objPHPExcel = $objReader->load($inputFileName); ``` > See Examples/Reader/exampleReader15.php for a working example of this code. Loading using a Value Binder applies to: -Reader | Y/N |Reader | Y/N |Reader | Y/N | -----------|:---:|--------|:---:|--------------|:---:| -Excel2007 | NO | Excel5 | NO | Excel2003XML | NO | -OOCalc | NO | SYLK | NO | Gnumeric | NO | +Reader | Y/N |Reader | Y/N |Reader | Y/N | +----------|:---:|--------|:---:|--------------|:---:| +Xlsx | NO | Excel5 | NO | Excel2003XML | NO | +OOCalc | NO | SYLK | NO | Gnumeric | NO | CSV | YES | HTML | YES diff --git a/samples/01_Simple_PCLZip.php b/samples/01_Simple_PCLZip.php index f6796b39..a00c4cb4 100644 --- a/samples/01_Simple_PCLZip.php +++ b/samples/01_Simple_PCLZip.php @@ -41,10 +41,10 @@ $spreadsheet->getActiveSheet()->setTitle('Simple'); $spreadsheet->setActiveSheetIndex(0); // Save Excel 2007 file -$helper->log('Write to Excel2007 format'); +$helper->log('Write to Xlsx format'); -// Use PCLZip rather than ZipArchive to create the Excel2007 OfficeOpenXML file +// Use PCLZip rather than ZipArchive to create the Xlsx OfficeOpenXML file \PhpOffice\PhpSpreadsheet\Settings::setZipClass(\PhpOffice\PhpSpreadsheet\Settings::PCLZIP); // Save -$helper->write($spreadsheet, __FILE__, ['Excel2007' => 'xlsx']); +$helper->write($spreadsheet, __FILE__, ['Xlsx' => 'xlsx']); diff --git a/samples/01_Simple_download_xlsx.php b/samples/01_Simple_download_xlsx.php index 185ec096..3881d4cc 100644 --- a/samples/01_Simple_download_xlsx.php +++ b/samples/01_Simple_download_xlsx.php @@ -38,7 +38,7 @@ $spreadsheet->getActiveSheet()->setTitle('Simple'); // Set active sheet index to the first sheet, so Excel opens this as the first sheet $spreadsheet->setActiveSheetIndex(0); -// Redirect output to a client’s web browser (Excel2007) +// Redirect output to a client’s web browser (Xlsx) header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="01simple.xlsx"'); header('Cache-Control: max-age=0'); @@ -51,6 +51,6 @@ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modifie header('Cache-Control: cache, must-revalidate'); // HTTP/1.1 header('Pragma: public'); // HTTP/1.0 -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Excel2007'); +$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->save('php://output'); exit; diff --git a/samples/03_Formulas.php b/samples/03_Formulas.php index 3f0e9c8d..8896253c 100644 --- a/samples/03_Formulas.php +++ b/samples/03_Formulas.php @@ -71,7 +71,7 @@ $spreadsheet->getActiveSheet() // If we set Pre Calculated Formulas to true then PhpSpreadsheet will calculate all formulae in the // workbook before saving. This adds time and memory overhead, and can cause some problems with formulae // using functions or features (such as array formulae) that aren't yet supported by the calculation engine -// If the value is false (the default) for the Excel2007 Writer, then MS Excel (or the application used to +// If the value is false (the default) for the Xlsx Writer, then MS Excel (or the application used to // open the file) will need to recalculate values itself to guarantee that the correct results are available. // //$writer->setPreCalculateFormulas(true); diff --git a/samples/07_Reader.php b/samples/07_Reader.php index 1faa2d6c..2e7b9610 100644 --- a/samples/07_Reader.php +++ b/samples/07_Reader.php @@ -5,12 +5,12 @@ require __DIR__ . '/Header.php'; // Create temporary file that will be read $sampleSpreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php'; $filename = $helper->getTemporaryFilename(); -$writer = new \PhpOffice\PhpSpreadsheet\Writer\Excel2007($sampleSpreadsheet); +$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($sampleSpreadsheet); $writer->save($filename); $callStartTime = microtime(true); $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename); -$helper->logRead('Excel2007', $filename, $callStartTime); +$helper->logRead('Xlsx', $filename, $callStartTime); // Save $helper->write($spreadsheet, __FILE__); diff --git a/samples/07_Reader_PCLZip.php b/samples/07_Reader_PCLZip.php index 7fc40ecb..e9ce8f05 100644 --- a/samples/07_Reader_PCLZip.php +++ b/samples/07_Reader_PCLZip.php @@ -5,15 +5,15 @@ require __DIR__ . '/Header.php'; // Create temporary file that will be read $sampleSpreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php'; $filename = $helper->getTemporaryFilename(); -$writer = new \PhpOffice\PhpSpreadsheet\Writer\Excel2007($sampleSpreadsheet); +$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($sampleSpreadsheet); $writer->save($filename); -// Use PCLZip rather than ZipArchive to read the Excel2007 OfficeOpenXML file +// Use PCLZip rather than ZipArchive to read the Xlsx OfficeOpenXML file \PhpSpreadsheet\Settings::setZipClass(\PhpOffice\PhpSpreadsheet\Settings::PCLZIP); $callStartTime = microtime(true); $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename); -$helper->logRead('Excel2007', $filename, $callStartTime); +$helper->logRead('Xlsx', $filename, $callStartTime); $callEndTime = microtime(true); // Save diff --git a/samples/13_Calculation.php b/samples/13_Calculation.php index d87f5104..2d087b41 100644 --- a/samples/13_Calculation.php +++ b/samples/13_Calculation.php @@ -166,7 +166,7 @@ for ($col = 'B'; $col != 'G'; ++$col) { // If we set Pre Calculated Formulas to true then PhpSpreadsheet will calculate all formulae in the // workbook before saving. This adds time and memory overhead, and can cause some problems with formulae // using functions or features (such as array formulae) that aren't yet supported by the calculation engine -// If the value is false (the default) for the Excel2007 Writer, then MS Excel (or the application used to +// If the value is false (the default) for the Xlsx Writer, then MS Excel (or the application used to // open the file) will need to recalculate values itself to guarantee that the correct results are available. // //$writer->setPreCalculateFormulas(true); diff --git a/samples/16_Csv.php b/samples/16_Csv.php index 1c8eec96..1eb8a1d9 100644 --- a/samples/16_Csv.php +++ b/samples/16_Csv.php @@ -23,8 +23,8 @@ $callStartTime = microtime(true); $spreadsheetFromCSV = $reader->load($filename); $helper->logRead('CSV', $filename, $callStartTime); -// Write Excel2007 -$helper->write($spreadsheetFromCSV, __FILE__, ['Excel2007' => 'xlsx']); +// Write Xlsx +$helper->write($spreadsheetFromCSV, __FILE__, ['Xlsx' => 'xlsx']); // Write CSV $filenameCSV = $helper->getFilename(__FILE__, 'csv'); diff --git a/samples/20_Read_OOCalc_with_PCLZip.php b/samples/20_Read_OOCalc_with_PCLZip.php index 9c42e872..80d50299 100644 --- a/samples/20_Read_OOCalc_with_PCLZip.php +++ b/samples/20_Read_OOCalc_with_PCLZip.php @@ -2,7 +2,7 @@ require __DIR__ . '/Header.php'; -// Use PCLZip rather than ZipArchive to read the Excel2007 OfficeOpenXML file +// Use PCLZip rather than ZipArchive to read the Xlsx OfficeOpenXML file \PhpOffice\PhpSpreadsheet\Settings::setZipClass(\PhpOffice\PhpSpreadsheet\Settings::PCLZIP); $filename = __DIR__ . '/templates/OOCalcTest.ods'; diff --git a/samples/24_Readfilter.php b/samples/24_Readfilter.php index 50c68809..17912705 100644 --- a/samples/24_Readfilter.php +++ b/samples/24_Readfilter.php @@ -6,7 +6,7 @@ require __DIR__ . '/Header.php'; // Write temporary file $largeSpreadsheet = require __DIR__ . '/templates/largeSpreadsheet.php'; -$writer = new \PhpOffice\PhpSpreadsheet\Writer\Excel2007($largeSpreadsheet); +$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($largeSpreadsheet); $filename = $helper->getTemporaryFilename(); $callStartTime = microtime(true); $writer->save($filename); @@ -25,12 +25,12 @@ class MyReadFilter implements \PhpOffice\PhpSpreadsheet\Reader\IReadFilter } } -$helper->log('Load from Excel2007 file'); -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Excel2007'); +$helper->log('Load from Xlsx file'); +$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx'); $reader->setReadFilter(new MyReadFilter()); $callStartTime = microtime(true); $spreadsheet = $reader->load($filename); -$helper->logRead('Excel2007', $filename, $callStartTime); +$helper->logRead('Xlsx', $filename, $callStartTime); $helper->log('Remove unnecessary rows'); $spreadsheet->getActiveSheet()->removeRow(2, 18); diff --git a/samples/25_In_memory_image.php b/samples/25_In_memory_image.php index 877f2f1b..87746271 100644 --- a/samples/25_In_memory_image.php +++ b/samples/25_In_memory_image.php @@ -34,4 +34,4 @@ $drawing->setHeight(36); $drawing->setWorksheet($spreadsheet->getActiveSheet()); // Save -$helper->write($spreadsheet, __FILE__, ['Excel2007' => 'xlsx', 'HTML' => 'html']); +$helper->write($spreadsheet, __FILE__, ['Xlsx' => 'xlsx', 'HTML' => 'html']); diff --git a/samples/26_Utf8.php b/samples/26_Utf8.php index 5039efe7..5c634b26 100644 --- a/samples/26_Utf8.php +++ b/samples/26_Utf8.php @@ -12,13 +12,13 @@ $rendererName = \PhpOffice\PhpSpreadsheet\Settings::PDF_RENDERER_DOMPDF; $rendererLibrary = 'domPDF0.6.0beta3'; $rendererLibraryPath = '/php/libraries/PDF/' . $rendererLibrary; -// Read from Excel2007 (.xlsx) template -$helper->log('Load Excel2007 template file'); -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Excel2007'); +// Read from Xlsx (.xlsx) template +$helper->log('Load Xlsx template file'); +$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx'); $spreadsheet = $reader->load(__DIR__ . '/templates/26template.xlsx'); /* at this point, we could do some manipulations with the template, but we skip this step */ -$helper->write($spreadsheet, __FILE__, ['Excel2007' => 'xlsx', 'Excel5' => 'xls', 'HTML' => 'html']); +$helper->write($spreadsheet, __FILE__, ['Xlsx' => 'xlsx', 'Excel5' => 'xls', 'HTML' => 'html']); // Export to PDF (.pdf) $helper->log('Write to PDF format'); diff --git a/samples/27_Images_excel5.php b/samples/27_Images_excel5.php index 11e32311..9a6a8007 100644 --- a/samples/27_Images_excel5.php +++ b/samples/27_Images_excel5.php @@ -3,7 +3,7 @@ require __DIR__ . '/Header.php'; // Read from Excel5 (.xls) template -$helper->log('Load Excel2007 template file'); +$helper->log('Load Xlsx template file'); $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Excel5'); $spreadsheet = $reader->load(__DIR__ . '/templates/27template.xls'); diff --git a/samples/28_Iterator.php b/samples/28_Iterator.php index 0128ea9b..95bed125 100644 --- a/samples/28_Iterator.php +++ b/samples/28_Iterator.php @@ -4,15 +4,15 @@ require __DIR__ . '/Header.php'; $sampleSpreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php'; $filename = $helper->getTemporaryFilename(); -$writer = new \PhpOffice\PhpSpreadsheet\Writer\Excel2007($sampleSpreadsheet); +$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($sampleSpreadsheet); $callStartTime = microtime(true); $writer->save($filename); $helper->logWrite($writer, $filename, $callStartTime); $callStartTime = microtime(true); -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Excel2007'); +$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx'); $spreadsheet = $reader->load($filename); -$helper->logRead('Excel2007', $filename, $callStartTime); +$helper->logRead('Xlsx', $filename, $callStartTime); $helper->log('Iterate worksheets'); foreach ($spreadsheet->getWorksheetIterator() as $worksheet) { $helper->log('Worksheet - ' . $worksheet->getTitle()); diff --git a/samples/31_Document_properties_write.php b/samples/31_Document_properties_write.php index 20bfac27..76aeaa62 100644 --- a/samples/31_Document_properties_write.php +++ b/samples/31_Document_properties_write.php @@ -2,7 +2,7 @@ require __DIR__ . '/Header.php'; -$inputFileType = 'Excel2007'; +$inputFileType = 'Xlsx'; $inputFileName = __DIR__ . '/templates/31docproperties.xlsx'; $spreadsheetReader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType); @@ -18,7 +18,7 @@ $spreadsheet->getProperties()->setTitle('Office 2007 XLSX Test Document') // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Excel2007'); +$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); $callStartTime = microtime(true); $writer->save($filename); $helper->logWrite($writer, $filename, $callStartTime); @@ -27,7 +27,7 @@ $helper->logWrite($writer, $filename, $callStartTime); $helper->logEndingNotes(); // Reread File -$helper->log('Reread Excel2007 file'); +$helper->log('Reread Xlsx file'); $spreadsheetRead = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename); // Set properties diff --git a/samples/32_Chart_read_write.php b/samples/32_Chart_read_write.php index cbd11d61..2ae0b8ae 100644 --- a/samples/32_Chart_read_write.php +++ b/samples/32_Chart_read_write.php @@ -2,7 +2,7 @@ require __DIR__ . '/Header.php'; -$inputFileType = 'Excel2007'; +$inputFileType = 'Xlsx'; $inputFileNames = __DIR__ . '/templates/32readwrite*[0-9].xlsx'; if ((isset($argc)) && ($argc > 1)) { @@ -69,7 +69,7 @@ foreach ($inputFileNames as $inputFileName) { } $outputFileName = $helper->getFilename($inputFileName); - $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Excel2007'); + $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($outputFileName); diff --git a/samples/32_Chart_read_write_HTML.php b/samples/32_Chart_read_write_HTML.php index 859cd38f..540e8985 100644 --- a/samples/32_Chart_read_write_HTML.php +++ b/samples/32_Chart_read_write_HTML.php @@ -14,7 +14,7 @@ if (!\PhpOffice\PhpSpreadsheet\Settings::setChartRenderer($rendererName, $render return; } -$inputFileType = 'Excel2007'; +$inputFileType = 'Xlsx'; $inputFileNames = __DIR__ . '/templates/36write*.xlsx'; if ((isset($argc)) && ($argc > 1)) { diff --git a/samples/32_Chart_read_write_PDF.php b/samples/32_Chart_read_write_PDF.php index 613f032c..5f55899d 100644 --- a/samples/32_Chart_read_write_PDF.php +++ b/samples/32_Chart_read_write_PDF.php @@ -30,7 +30,7 @@ if (!\PhpOffice\PhpSpreadsheet\Settings::setChartRenderer($rendererName, $render return; } -$inputFileType = 'Excel2007'; +$inputFileType = 'Xlsx'; $inputFileNames = __DIR__ . '/templates/36write*.xlsx'; if ((isset($argc)) && ($argc > 1)) { diff --git a/samples/33_Chart_create_area.php b/samples/33_Chart_create_area.php index b19cf496..550f8133 100644 --- a/samples/33_Chart_create_area.php +++ b/samples/33_Chart_create_area.php @@ -89,7 +89,7 @@ $worksheet->addChart($chart); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Excel2007'); +$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_bar.php b/samples/33_Chart_create_bar.php index 76c10aa2..6889956b 100644 --- a/samples/33_Chart_create_bar.php +++ b/samples/33_Chart_create_bar.php @@ -7,7 +7,7 @@ $spreadsheet = require __DIR__ . '/templates/chartSpreadsheet.php'; // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Excel2007'); +$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_bar_stacked.php b/samples/33_Chart_create_bar_stacked.php index 6f84a483..f4bb87bc 100644 --- a/samples/33_Chart_create_bar_stacked.php +++ b/samples/33_Chart_create_bar_stacked.php @@ -92,7 +92,7 @@ $worksheet->addChart($chart); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Excel2007'); +$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_column.php b/samples/33_Chart_create_column.php index 57b00db0..1d4023cf 100644 --- a/samples/33_Chart_create_column.php +++ b/samples/33_Chart_create_column.php @@ -92,7 +92,7 @@ $worksheet->addChart($chart); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Excel2007'); +$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_column_2.php b/samples/33_Chart_create_column_2.php index 5df2fb30..d459dd5b 100644 --- a/samples/33_Chart_create_column_2.php +++ b/samples/33_Chart_create_column_2.php @@ -101,7 +101,7 @@ $worksheet->addChart($chart); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Excel2007'); +$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_composite.php b/samples/33_Chart_create_composite.php index af801d8d..57abd991 100644 --- a/samples/33_Chart_create_composite.php +++ b/samples/33_Chart_create_composite.php @@ -145,7 +145,7 @@ $worksheet->addChart($chart); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Excel2007'); +$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_line.php b/samples/33_Chart_create_line.php index 5b2fc06c..556f9530 100644 --- a/samples/33_Chart_create_line.php +++ b/samples/33_Chart_create_line.php @@ -89,7 +89,7 @@ $worksheet->addChart($chart); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Excel2007'); +$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_multiple_charts.php b/samples/33_Chart_create_multiple_charts.php index fd6ed83c..d8ce1a20 100644 --- a/samples/33_Chart_create_multiple_charts.php +++ b/samples/33_Chart_create_multiple_charts.php @@ -164,7 +164,7 @@ $worksheet->addChart($chart2); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Excel2007'); +$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_pie.php b/samples/33_Chart_create_pie.php index 6ee0aa1e..c8a23909 100644 --- a/samples/33_Chart_create_pie.php +++ b/samples/33_Chart_create_pie.php @@ -159,7 +159,7 @@ $worksheet->addChart($chart2); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Excel2007'); +$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_radar.php b/samples/33_Chart_create_radar.php index b2d792f2..2a978792 100644 --- a/samples/33_Chart_create_radar.php +++ b/samples/33_Chart_create_radar.php @@ -101,7 +101,7 @@ $worksheet->addChart($chart); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Excel2007'); +$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_scatter.php b/samples/33_Chart_create_scatter.php index 937b0fff..205113ab 100644 --- a/samples/33_Chart_create_scatter.php +++ b/samples/33_Chart_create_scatter.php @@ -86,7 +86,7 @@ $worksheet->addChart($chart); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Excel2007'); +$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/33_Chart_create_stock.php b/samples/33_Chart_create_stock.php index e6605bf9..eea2a430 100644 --- a/samples/33_Chart_create_stock.php +++ b/samples/33_Chart_create_stock.php @@ -97,7 +97,7 @@ $worksheet->addChart($chart); // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Excel2007'); +$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/34_Chart_update.php b/samples/34_Chart_update.php index 1357fa0f..0a3c6e5a 100644 --- a/samples/34_Chart_update.php +++ b/samples/34_Chart_update.php @@ -6,11 +6,11 @@ require __DIR__ . '/Header.php'; // Create temporary file that will be read $sampleSpreadsheet = require __DIR__ . '/templates/chartSpreadsheet.php'; $filename = $helper->getTemporaryFilename(); -$writer = new \PhpOffice\PhpSpreadsheet\Writer\Excel2007($sampleSpreadsheet); +$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($sampleSpreadsheet); $writer->save($filename); -$helper->log('Load from Excel2007 file'); -$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Excel2007'); +$helper->log('Load from Xlsx file'); +$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx'); $reader->setIncludeCharts(true); $spreadsheet = $reader->load($filename); @@ -29,7 +29,7 @@ $worksheet->fromArray( // Save Excel 2007 file $filename = $helper->getFilename(__FILE__); -$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Excel2007'); +$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->setIncludeCharts(true); $callStartTime = microtime(true); $writer->save($filename); diff --git a/samples/35_Chart_render.php b/samples/35_Chart_render.php index cb06eff4..b472f206 100644 --- a/samples/35_Chart_render.php +++ b/samples/35_Chart_render.php @@ -14,7 +14,7 @@ if (!\PhpOffice\PhpSpreadsheet\Settings::setChartRenderer($rendererName, $render return; } -$inputFileType = 'Excel2007'; +$inputFileType = 'Xlsx'; $inputFileNames = __DIR__ . '/templates/32readwrite*[0-9].xlsx'; if ((isset($argc)) && ($argc > 1)) { diff --git a/samples/43_Merge_workbooks.php b/samples/43_Merge_workbooks.php index 7e76d1b8..6173a2d5 100644 --- a/samples/43_Merge_workbooks.php +++ b/samples/43_Merge_workbooks.php @@ -2,17 +2,17 @@ require __DIR__ . '/Header.php'; -$helper->log('Load MergeBook1 from Excel2007 file'); +$helper->log('Load MergeBook1 from Xlsx file'); $filename1 = __DIR__ . '/templates/43mergeBook1.xlsx'; $callStartTime = microtime(true); $spreadsheet1 = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename1); -$helper->logRead('Excel2007', $filename1, $callStartTime); +$helper->logRead('Xlsx', $filename1, $callStartTime); -$helper->log('Load MergeBook2 from Excel2007 file'); +$helper->log('Load MergeBook2 from Xlsx file'); $filename2 = __DIR__ . '/templates/43mergeBook2.xlsx'; $callStartTime = microtime(true); $spreadsheet2 = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename2); -$helper->logRead('Excel2007', $filename2, $callStartTime); +$helper->logRead('Xlsx', $filename2, $callStartTime); foreach ($spreadsheet2->getSheetNames() as $sheetName) { $sheet = $spreadsheet2->getSheetByName($sheetName); diff --git a/samples/44_Worksheet_info.php b/samples/44_Worksheet_info.php index 7265a483..71849ca4 100644 --- a/samples/44_Worksheet_info.php +++ b/samples/44_Worksheet_info.php @@ -5,7 +5,7 @@ require __DIR__ . '/Header.php'; // Create temporary file that will be read $sampleSpreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php'; $filename = $helper->getTemporaryFilename(); -$writer = new \PhpOffice\PhpSpreadsheet\Writer\Excel2007($sampleSpreadsheet); +$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($sampleSpreadsheet); $writer->save($filename); $inputFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($filename); diff --git a/src/PhpSpreadsheet/Helper/Sample.php b/src/PhpSpreadsheet/Helper/Sample.php index fc262f40..f9e6451f 100644 --- a/src/PhpSpreadsheet/Helper/Sample.php +++ b/src/PhpSpreadsheet/Helper/Sample.php @@ -78,7 +78,7 @@ class Sample * @param string $filename * @param array $writers */ - public function write(Spreadsheet $spreadsheet, $filename, array $writers = ['Excel2007' => 'xlsx', 'Excel5' => 'xls']) + public function write(Spreadsheet $spreadsheet, $filename, array $writers = ['Xlsx' => 'xlsx', 'Excel5' => 'xls']) { // Set active sheet index to the first sheet, so Excel opens this as the first sheet $spreadsheet->setActiveSheetIndex(0); diff --git a/src/PhpSpreadsheet/IOFactory.php b/src/PhpSpreadsheet/IOFactory.php index 804c06cc..39844fd7 100644 --- a/src/PhpSpreadsheet/IOFactory.php +++ b/src/PhpSpreadsheet/IOFactory.php @@ -44,7 +44,7 @@ class IOFactory * @static */ private static $autoResolveClasses = [ - 'Excel2007', + 'Xlsx', 'Excel5', 'Excel2003XML', 'OOCalc', @@ -106,7 +106,7 @@ class IOFactory * * @static * @param Spreadsheet $spreadsheet - * @param string $writerType Example: Excel2007 + * @param string $writerType Example: Xlsx * @throws Writer\Exception * @return Writer\IWriter */ @@ -135,7 +135,7 @@ class IOFactory * Create Reader\IReader * * @static - * @param string $readerType Example: Excel2007 + * @param string $readerType Example: Xlsx * @throws Reader\Exception * @return Reader\IReader */ @@ -213,7 +213,7 @@ class IOFactory case 'xlsm': // Excel (OfficeOpenXML) Macro Spreadsheet (macros will be discarded) case 'xltx': // Excel (OfficeOpenXML) Template case 'xltm': // Excel (OfficeOpenXML) Macro Template (macros will be discarded) - $extensionType = 'Excel2007'; + $extensionType = 'Xlsx'; break; case 'xls': // Excel (BIFF) Spreadsheet case 'xlt': // Excel (BIFF) Template diff --git a/src/PhpSpreadsheet/Reader/Excel2007.php b/src/PhpSpreadsheet/Reader/Xlsx.php similarity index 99% rename from src/PhpSpreadsheet/Reader/Excel2007.php rename to src/PhpSpreadsheet/Reader/Xlsx.php index a86f1abc..14035841 100644 --- a/src/PhpSpreadsheet/Reader/Excel2007.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -24,7 +24,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader; * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ -class Excel2007 extends BaseReader implements IReader +class Xlsx extends BaseReader implements IReader { /** * ReferenceHelper instance @@ -34,14 +34,14 @@ class Excel2007 extends BaseReader implements IReader private $referenceHelper = null; /** - * Excel2007\Theme instance + * Xlsx\Theme instance * - * @var Excel2007\Theme + * @var Xlsx\Theme */ private static $theme = null; /** - * Create a new Excel2007 Reader instance + * Create a new Xlsx Reader instance */ public function __construct() { @@ -398,7 +398,7 @@ class Excel2007 extends BaseReader implements IReader $themeColours[$themePos] = $xmlColourData['val']; } } - self::$theme = new Excel2007\Theme($themeName, $colourSchemeName, $themeColours); + self::$theme = new Xlsx\Theme($themeName, $colourSchemeName, $themeColours); } break; } @@ -1827,7 +1827,7 @@ class Excel2007 extends BaseReader implements IReader 'SimpleXMLElement', \PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions() ); - $objChart = \PhpOffice\PhpSpreadsheet\Reader\Excel2007\Chart::readChart($chartElements, basename($chartEntryRef, '.xml')); + $objChart = \PhpOffice\PhpSpreadsheet\Reader\Xlsx\Chart::readChart($chartElements, basename($chartEntryRef, '.xml')); if (isset($charts[$chartEntryRef])) { $chartPositionRef = $charts[$chartEntryRef]['sheet'] . '!' . $charts[$chartEntryRef]['id']; diff --git a/src/PhpSpreadsheet/Reader/Excel2007/Chart.php b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php similarity index 99% rename from src/PhpSpreadsheet/Reader/Excel2007/Chart.php rename to src/PhpSpreadsheet/Reader/Xlsx/Chart.php index 7ebb73c2..a47188f8 100644 --- a/src/PhpSpreadsheet/Reader/Excel2007/Chart.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php @@ -1,6 +1,6 @@ setSpreadsheet($spreadsheet); $writerPartsArray = [ - 'stringtable' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Excel2007\\StringTable', - 'contenttypes' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Excel2007\\ContentTypes', - 'docprops' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Excel2007\\DocProps', - 'rels' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Excel2007\\Rels', - 'theme' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Excel2007\\Theme', - 'style' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Excel2007\\Style', - 'workbook' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Excel2007\\Workbook', - 'worksheet' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Excel2007\\Worksheet', - 'drawing' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Excel2007\\Drawing', - 'comments' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Excel2007\\Comments', - 'chart' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Excel2007\\Chart', - 'relsvba' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Excel2007\\RelsVBA', - 'relsribbonobjects' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Excel2007\\RelsRibbon', + 'stringtable' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\StringTable', + 'contenttypes' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\ContentTypes', + 'docprops' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\DocProps', + 'rels' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Rels', + 'theme' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Theme', + 'style' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Style', + 'workbook' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Workbook', + 'worksheet' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Worksheet', + 'drawing' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Drawing', + 'comments' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Comments', + 'chart' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\Chart', + 'relsvba' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\RelsVBA', + 'relsribbonobjects' => '\\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx\\RelsRibbon', ]; // Initialise writer parts @@ -152,7 +152,7 @@ class Excel2007 extends BaseWriter implements IWriter * Get writer part * * @param string $pPartName Writer part name - * @return \PhpOffice\PhpSpreadsheet\Writer\Excel2007\WriterPart + * @return \PhpOffice\PhpSpreadsheet\Writer\Xlsx\WriterPart */ public function getWriterPart($pPartName = '') { @@ -416,7 +416,7 @@ class Excel2007 extends BaseWriter implements IWriter * * @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet PhpSpreadsheet object * @throws Exception - * @return Excel2007 + * @return Xlsx */ public function setSpreadsheet(Spreadsheet $spreadsheet = null) { @@ -519,7 +519,7 @@ class Excel2007 extends BaseWriter implements IWriter * Set Office2003 compatibility * * @param bool $pValue Office2003 compatibility? - * @return Excel2007 + * @return Xlsx */ public function setOffice2003Compatibility($pValue = false) { diff --git a/src/PhpSpreadsheet/Writer/Excel2007/Chart.php b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php similarity index 99% rename from src/PhpSpreadsheet/Writer/Excel2007/Chart.php rename to src/PhpSpreadsheet/Writer/Xlsx/Chart.php index 90915669..b7dc5765 100644 --- a/src/PhpSpreadsheet/Writer/Excel2007/Chart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php @@ -1,6 +1,6 @@ startElement('font'); - // Weird! The order of these elements actually makes a difference when opening Excel2007 + // Weird! The order of these elements actually makes a difference when opening Xlsx // files in Excel2003 with the compatibility pack. It's not documented behaviour, // and makes for a real WTF! diff --git a/src/PhpSpreadsheet/Writer/Excel2007/Theme.php b/src/PhpSpreadsheet/Writer/Xlsx/Theme.php similarity index 99% rename from src/PhpSpreadsheet/Writer/Excel2007/Theme.php rename to src/PhpSpreadsheet/Writer/Xlsx/Theme.php index 3f4413ea..38b73e09 100644 --- a/src/PhpSpreadsheet/Writer/Excel2007/Theme.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Theme.php @@ -1,6 +1,6 @@