diff --git a/docs/faq.md b/docs/faq.md index 68dbef5d..19f5f8fc 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -11,21 +11,11 @@ with PHP's `iconv()` or `mb_convert_encoding()` functions. PhpSpreadsheet holds an "in memory" representation of a spreadsheet, so it is susceptible to PHP's memory limitations. The memory made available to PHP can be increased by editing the value of the `memory_limit` -directive in your php.ini file, or by using +directive in your `php.ini` file, or by using `ini_set('memory_limit', '128M')` within your code. Some Readers and Writers are faster than others, and they also use -differing amounts of memory. You can find some indication of the -relative performance and memory usage for the different Readers and -Writers, over the different versions of PhpSpreadsheet, on the -[discussion -board](http://phpexcel.codeplex.com/Thread/View.aspx?ThreadId=234150). - -If you've already increased memory to a maximum, or can't change your -memory limit, then [this -discussion](http://phpexcel.codeplex.com/Thread/View.aspx?ThreadId=242712) -on the board describes some of the methods that can be applied to reduce -the memory usage of your scripts using PhpSpreadsheet. +differing amounts of memory. ## Protection on my worksheet is not working? @@ -65,32 +55,3 @@ file in Excel, the actual width is 0.71 less than it should be. The short answer is that PhpSpreadsheet uses a measure where padding is included. See [how to set a column's width](./topics/recipes.md#setting-a-columns-width) for more details. - -## How do I use PhpSpreadsheet with my framework - -- There are some instructions for using PhpSpreadsheet with Joomla on - the [Joomla message - board](http://http:/forum.joomla.org/viewtopic.php?f=304&t=433060) -- A page of advice on using [PhpSpreadsheet in the Yii - framework](http://www.yiiframework.com/wiki/101/how-to-use-phpexcel-external-library-with-yii/) -- [The - Bakery](http://bakery.cakephp.org/articles/melgior/2010/01/26/simple-excel-spreadsheet-helper) - has some helper classes for reading and writing with PhpSpreadsheet - within CakePHP -- Integrating [PhpSpreadsheet into Kohana - 3](http://www.flynsarmy.com/2010/07/phpexcel-module-for-kohana-3/) - and [Интеграция PHPExcel и Kohana - Framework](http://szpargalki.blogspot.com/2011/02/phpexcel-kohana-framework.html) -- Using [PhpSpreadsheet with - TYPO3](http://typo3.org/documentation/document-library/extension-manuals/phpexcel_library/1.1.1/view/toc/0/) - -### Tutorials - -- [English PHPExcel tutorial](http://openxmldeveloper.org) -- [French PHPExcel - tutorial](http://g-ernaelsten.developpez.com/tutoriels/excel2007/) -- [Russian PHPExcel Blog - Postings](http://www.web-junior.net/sozdanie-excel-fajjlov-s-pomoshhyu-phpexcel/) -- [A Japanese-language introduction to - PHPExcel](http://journal.mycom.co.jp/articles/2009/03/06/phpexcel/index.html) - diff --git a/docs/topics/calculation-engine.md b/docs/topics/calculation-engine.md index 94fa3a10..6a84f8c0 100644 --- a/docs/topics/calculation-engine.md +++ b/docs/topics/calculation-engine.md @@ -61,10 +61,8 @@ In Excel `+` wins over `&`, just like `*` wins over `+` in ordinary algebra. The former rule is not what one finds using the calculation engine shipped with PhpSpreadsheet. -Reference for operator precedence in Excel: - - -Reference for operator precedence in PHP: +- [Reference for Excel](https://support.office.com/en-us/article/Calculation-operators-and-precedence-in-Excel-48be406d-4975-4d31-b2b8-7af9e0e2878a) +- [Reference for PHP](http://php.net/manual/en/language.operators.php) #### Formulas involving numbers and text @@ -76,8 +74,7 @@ formula is evaluated as 3 instead of evaluating as an error. This also causes the Excel document being generated as containing unreadable content. -Reference for this behaviour in PHP: - +- [Reference for this behaviour in PHP](http://php.net/manual/en/language.types.string.php#language.types.string.conversion) #### Formulas don’t seem to be calculated in Excel2003 using compatibility pack? diff --git a/docs/topics/file-formats.md b/docs/topics/file-formats.md index 41889f41..c416105c 100644 --- a/docs/topics/file-formats.md +++ b/docs/topics/file-formats.md @@ -11,21 +11,18 @@ Currently, PhpSpreadsheet supports the following File Types for Reading: ### Xls The Microsoft Excel™ Binary file format (BIFF5 and BIFF8) is a binary -file format that was used by Microsoft Excel™ between versions 95 and -2003. The format is supported (to various extents) by most spreadsheet +file format that was used by Microsoft Excel™ between versions 95 and 2003. +The format is supported (to various extents) by most spreadsheet programs. BIFF files normally have an extension of .xls. Documentation -describing the format can be found online at - or -from [as a downloadable -PDF](http://download.microsoft.com/download/2/4/8/24862317-78F0-4C4B-B355-C7B2C1D997DB/%5BMS-XLS%5D.pdf). +describing the format can be [read online](https://msdn.microsoft.com/en-us/library/cc313154(v=office.12).aspx) +or [downloaded as PDF](http://download.microsoft.com/download/2/4/8/24862317-78F0-4C4B-B355-C7B2C1D997DB/%5BMS-XLS%5D.pdf). ### Xml 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 - +format can be [read online](https://msdn.microsoft.com/en-us/library/aa140066(office.10).aspx) though it’s sadly rather sparse in its detail. ### Xlsx @@ -35,23 +32,21 @@ 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 -() +Open XML SpreadsheetML is mostly standardized in [ECMA 376](http://www.ecma-international.org/news/TC45_current_work/TC45_available_docs.htm) and ISO 29500. ### Ods aka Open Document Format (ODF) or OASIS, this is the OpenOffice.org XML -File Format for spreadsheets. It comprises a zip archive including +file format for spreadsheets. It comprises a zip archive including several components all of which are text files, most of these with markup in the eXtensible Markup Language (XML). It is the standard file format for OpenOffice.org Calc and StarCalc, and files typically have an extension of .ods. The published specification for the file format is -available from the OASIS Open Office XML Format Technical Committee web -page -(). -Other information is available from the OpenOffice.org XML File Format -web page (), part of the +available from [the OASIS Open Office XML Format Technical Committee web +page](https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office). +Other information is available from [the OpenOffice.org XML File Format +web page](http://www.openoffice.org/xml/), part of the OpenOffice.org project. ### Slk @@ -66,12 +61,12 @@ options (unlike CSV files). ### Gnumeric -The Gnumeric file format is used by the Gnome Gnumeric spreadsheet -application, and typically files have an extension of .gnumeric. The +The [Gnumeric file format](https://help.gnome.org/users/gnumeric/stable/sect-file-formats.html.en#file-format-gnumeric) +is used by the Gnome Gnumeric spreadsheet +application, and typically files have an extension of `.gnumeric`. The file contents are stored using eXtensible Markup Language (XML) markup, and the file is then compressed using the GNU project's gzip compression library. - ### Csv diff --git a/docs/topics/links-and-tools.md b/docs/topics/links-and-tools.md deleted file mode 100644 index dab842d7..00000000 --- a/docs/topics/links-and-tools.md +++ /dev/null @@ -1,15 +0,0 @@ -# Useful links and tools - -There are some links and tools which are very useful when developing -using PhpSpreadsheet. - -## OpenXML / SpreadsheetML - -- [File format - documentation](http://www.ecma-international.org/news/TC45_current_work/TC45_available_docs.htm) -- [OpenXML Explained - e-book](http://openxmldeveloper.org/articles/1970.aspx) -- [Microsoft Office Compatibility Pack for Word, Excel, and PowerPoint - 2007 File - Formats](http://www.microsoft.com/downloads/details.aspx?familyid=941b3470-3ae9-4aee-8f43-c6bb74cd1466&displaylang=en) -- [OpenXML Package Explorer](http://www.codeplex.com/PackageExplorer/) diff --git a/docs/topics/memory_saving.md b/docs/topics/memory_saving.md index f2ff2070..3efef43c 100644 --- a/docs/topics/memory_saving.md +++ b/docs/topics/memory_saving.md @@ -47,7 +47,7 @@ you to select the most appropriate implementation for your environnement. You can either implement [PSR-16](http://www.php-fig.org/psr/psr-16/) from scratch, or use [pre-existing libraries](https://packagist.org/search/?q=psr-16). -One such library is [PHP Cache](http://www.php-cache.com/) which +One such library is [PHP Cache](https://www.php-cache.com/) which provides a wide range of alternatives. Refers to their documentation for details, but here are a few suggestions that should get you started. @@ -105,4 +105,4 @@ $pool = new \Cache\Adapter\Memcache\MemcacheCachePool($client); $simpleCache = new \Cache\Bridge\SimpleCache\SimpleCacheBridge($pool); \PhpOffice\PhpSpreadsheet\Settings::setCache($simpleCache); -``` \ No newline at end of file +``` diff --git a/docs/topics/reading-files.md b/docs/topics/reading-files.md index 8f22e71b..3d8f20f7 100644 --- a/docs/topics/reading-files.md +++ b/docs/topics/reading-files.md @@ -4,15 +4,17 @@ XML-based formats such as OfficeOpen XML, Excel2003 XML, OASIS and Gnumeric are susceptible to XML External Entity Processing (XXE) -injection attacks (for an explanation of XXE injection see -http://websec.io/2012/08/27/Preventing-XEE-in-PHP.html) when reading -spreadsheet files. This can lead to: +injection attacks when reading spreadsheet files. This can lead to: - Disclosure whether a file is existent - Server Side Request Forgery - Command Execution (depending on the installed PHP wrappers) -To prevent this, by default every XML-based Reader looks for XML entities declared inside the DOCTYPE and if any is found an exception is raised. +To prevent this, by default every XML-based Reader looks for XML +entities declared inside the DOCTYPE and if any is found an exception +is raised. + +Read more [about of XXE injection](https://websec.io/2012/08/27/Preventing-XXE-in-PHP.html). ## Loading a Spreadsheet File @@ -566,16 +568,16 @@ CSV | YES | HTML | NO When loading data from a file that contains no formatting information, such as a CSV file, then data is read either as strings or numbers (float or integer). This means that PhpSpreadsheet does not -automatically recognise dates/times (such as "16-Apr-2009" or "13:30"), -booleans ("TRUE" or "FALSE"), percentages ("75%"), hyperlinks -("http://www.phpexcel.net"), etc as anything other than simple strings. +automatically recognise dates/times (such as `16-Apr-2009` or `13:30`), +booleans (`true` or `false`), percentages (`75%`), hyperlinks +(`https://www.example.com`), etc as anything other than simple strings. However, you can apply additional processing that is executed against these values during the load process within a Value Binder. A Value Binder is a class that implement the -\PhpOffice\PhpSpreadsheet\Cell\IValueBinder interface. It must contain a -bindValue() method that accepts a `\PhpOffice\PhpSpreadsheet\Cell\Cell` and a -value as arguments, and return a boolean true or false that indicates +`\PhpOffice\PhpSpreadsheet\Cell\IValueBinder` interface. It must contain a +`bindValue()` method that accepts a `\PhpOffice\PhpSpreadsheet\Cell\Cell` and a +value as arguments, and return a boolean `true` or `false` that indicates whether the workbook cell has been populated with the value or not. The Advanced Value Binder implements such a class: amongst other tests, it identifies a string comprising "TRUE" or "FALSE" (based on locale diff --git a/docs/topics/recipes.md b/docs/topics/recipes.md index 6b1f5998..af10798c 100644 --- a/docs/topics/recipes.md +++ b/docs/topics/recipes.md @@ -275,7 +275,7 @@ You can make a cell a clickable URL by setting its hyperlink property: ``` php $spreadsheet->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net'); -$spreadsheet->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('http://www.phpexcel.net'); +$spreadsheet->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('https://www.example.com'); ``` If you want to make a hyperlink to another worksheet/cell, use the diff --git a/samples/templates/Excel2003XMLTest.xml b/samples/templates/Excel2003XMLTest.xml index fb75ab06..db03903e 100644 --- a/samples/templates/Excel2003XMLTest.xml +++ b/samples/templates/Excel2003XMLTest.xml @@ -22310,7 +22310,7 @@ - + PhpSpreadsheet @@ -39528,4 +39528,4 @@ - \ No newline at end of file + diff --git a/samples/templates/OOCalcTest.ods b/samples/templates/OOCalcTest.ods index b29db766..d7fa5739 100644 Binary files a/samples/templates/OOCalcTest.ods and b/samples/templates/OOCalcTest.ods differ diff --git a/samples/templates/sampleSpreadsheet.php b/samples/templates/sampleSpreadsheet.php index 0785ed06..add7e58a 100644 --- a/samples/templates/sampleSpreadsheet.php +++ b/samples/templates/sampleSpreadsheet.php @@ -246,7 +246,7 @@ $spreadsheet->getActiveSheet()->getStyle('B1')->getProtection()->setLocked(Prote // Add a hyperlink to the sheet $helper->log('Add a hyperlink to an external website'); $spreadsheet->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net'); -$spreadsheet->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('http://www.phpexcel.net'); +$spreadsheet->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('https://www.example.com'); $spreadsheet->getActiveSheet()->getCell('E26')->getHyperlink()->setTooltip('Navigate to website'); $spreadsheet->getActiveSheet()->getStyle('E26')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_RIGHT); diff --git a/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php b/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php index 11d8c00c..b1337a0b 100644 --- a/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php +++ b/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php @@ -9,7 +9,7 @@ class HyperlinkTest extends TestCase { public function testGetUrl() { - $urlValue = 'http://www.phpexcel.net'; + $urlValue = 'https://www.example.com'; $testInstance = new Hyperlink($urlValue); @@ -19,7 +19,7 @@ class HyperlinkTest extends TestCase public function testSetUrl() { - $initialUrlValue = 'http://www.phpexcel.net'; + $initialUrlValue = 'https://www.example.com'; $newUrlValue = 'http://github.com/PHPOffice/PhpSpreadsheet'; $testInstance = new Hyperlink($initialUrlValue); @@ -55,7 +55,7 @@ class HyperlinkTest extends TestCase public function testIsInternal() { - $initialUrlValue = 'http://www.phpexcel.net'; + $initialUrlValue = 'https://www.example.com'; $newUrlValue = 'sheet://Worksheet1!A1'; $testInstance = new Hyperlink($initialUrlValue); @@ -69,9 +69,9 @@ class HyperlinkTest extends TestCase public function testGetHashCode() { - $urlValue = 'http://www.phpexcel.net'; + $urlValue = 'https://www.example.com'; $tooltipValue = 'PhpSpreadsheet Web Site'; - $initialExpectedHash = '6f1d4cbf40034b9ddc3fbf6019506e91'; + $initialExpectedHash = '3a8d5a682dba27276dce538c39402437'; $testInstance = new Hyperlink($urlValue, $tooltipValue); diff --git a/tests/PhpSpreadsheetTests/Reader/OdsTest.php b/tests/PhpSpreadsheetTests/Reader/OdsTest.php index b4f3e3fc..a6edaee2 100644 --- a/tests/PhpSpreadsheetTests/Reader/OdsTest.php +++ b/tests/PhpSpreadsheetTests/Reader/OdsTest.php @@ -16,7 +16,7 @@ class OdsTest extends TestCase /** * @var Spreadsheet */ - private $spreadsheetOOCalcTest; + private $spreadsheetOdsTest; /** * @var Spreadsheet @@ -26,17 +26,17 @@ class OdsTest extends TestCase /** * @return Spreadsheet */ - protected function loadOOCalcTestFile() + private function loadOdsTestFile() { - if (!$this->spreadsheetOOCalcTest) { + if (!$this->spreadsheetOdsTest) { $filename = __DIR__ . '/../../../samples/templates/OOCalcTest.ods'; // Load into this instance $reader = new Ods(); - $this->spreadsheetOOCalcTest = $reader->loadIntoExisting($filename, new Spreadsheet()); + $this->spreadsheetOdsTest = $reader->loadIntoExisting($filename, new Spreadsheet()); } - return $this->spreadsheetOOCalcTest; + return $this->spreadsheetOdsTest; } /** @@ -87,7 +87,7 @@ class OdsTest extends TestCase public function testReadValueAndComments() { - $spreadsheet = $this->loadOOCalcTestFile(); + $spreadsheet = $this->loadOdsTestFile(); $firstSheet = $spreadsheet->getSheet(0); @@ -152,7 +152,7 @@ class OdsTest extends TestCase public function testReadColors() { - $spreadsheet = $this->loadOOCalcTestFile(); + $spreadsheet = $this->loadOdsTestFile(); $firstSheet = $spreadsheet->getSheet(0); // Background color @@ -166,7 +166,7 @@ class OdsTest extends TestCase public function testReadRichText() { - $spreadsheet = $this->loadOOCalcTestFile(); + $spreadsheet = $this->loadOdsTestFile(); $firstSheet = $spreadsheet->getSheet(0); self::assertEquals( @@ -189,14 +189,14 @@ class OdsTest extends TestCase public function testReadHyperlinks() { - $spreadsheet = $this->loadOOCalcTestFile(); + $spreadsheet = $this->loadOdsTestFile(); $firstSheet = $spreadsheet->getSheet(0); $hyperlink = $firstSheet->getCell('A29'); self::assertEquals(DataType::TYPE_STRING, $hyperlink->getDataType()); - self::assertEquals('PHPExcel', $hyperlink->getValue()); - self::assertEquals('http://www.phpexcel.net/', $hyperlink->getHyperlink()->getUrl()); + self::assertEquals('PhpSpreadsheet', $hyperlink->getValue()); + self::assertEquals('https://github.com/PHPOffice/phpspreadsheet', $hyperlink->getHyperlink()->getUrl()); } // Below some test for features not implemented yet @@ -205,7 +205,7 @@ class OdsTest extends TestCase { $this->markTestIncomplete('Features not implemented yet'); - $spreadsheet = $this->loadOOCalcTestFile(); + $spreadsheet = $this->loadOdsTestFile(); $firstSheet = $spreadsheet->getSheet(0); // Font styles