From 781b2470f693e273738c848db6338506c6d376b1 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Sun, 30 May 2021 12:27:56 +0200 Subject: [PATCH] Documentation updates (#2131) * Update notes in documentation for memory sizing on 32-bit and 64-bit PHP versions * Additional notes on the fact that PHPSpreadsheet does not change cell addresses when loading a spreadsheet using a Read Filter --- docs/topics/memory_saving.md | 2 +- docs/topics/reading-and-writing-to-file.md | 5 +++++ docs/topics/reading-files.md | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/topics/memory_saving.md b/docs/topics/memory_saving.md index 157bb704..e52a83e4 100644 --- a/docs/topics/memory_saving.md +++ b/docs/topics/memory_saving.md @@ -1,6 +1,6 @@ # Memory saving -PhpSpreadsheet uses an average of about 1k per cell in your worksheets, so +PhpSpreadsheet uses an average of about 1k per cell (1.6k on 64-bit PHP) in your worksheets, so large workbooks can quickly use up available memory. Cell caching provides a mechanism that allows PhpSpreadsheet to maintain the cell objects in a smaller size of memory, or off-memory (eg: on disk, in APCu, diff --git a/docs/topics/reading-and-writing-to-file.md b/docs/topics/reading-and-writing-to-file.md index 9e4376e9..e5c2afd9 100644 --- a/docs/topics/reading-and-writing-to-file.md +++ b/docs/topics/reading-and-writing-to-file.md @@ -139,6 +139,11 @@ $reader->setReadFilter( new MyReadFilter() ); $spreadsheet = $reader->load("06largescale.xlsx"); ``` +Read Filtering does not renumber cell rows and columns. If you filter to read only rows 100-200, cells that you read will still be numbered A100-A200, not A1-A101. Cells A1-A99 will not be loaded, but if you then try to call `getCell()` for a cell outside your loaded range, then PHPSpreadsheet will create a new cell with a null value. + +Methods such as `toArray()` assume that all cells in a spreadsheet has been loaded from A1, so will return null values for rows and columns that fall outside your filter range: it is recommended that you keep track of the range that your filter has requested, and use `rangeToArray()` instead. + + ### \PhpOffice\PhpSpreadsheet\Writer\Xlsx #### Writing a spreadsheet diff --git a/docs/topics/reading-files.md b/docs/topics/reading-files.md index 1451f2ab..e1a1a179 100644 --- a/docs/topics/reading-files.md +++ b/docs/topics/reading-files.md @@ -324,6 +324,10 @@ 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. +Read Filtering does not renumber cell rows and columns. If you filter to read only rows 100-200, cells that you read will still be numbered A100-A200, not A1-A101. Cells A1-A99 will not be loaded, but if you then try to call `getCell()` for a cell outside your loaded range, then PHPSpreadsheet will create a new cell with a null value. + +Methods such as `toArray()` assume that all cells in a spreadsheet has been loaded from A1, so will return null values for rows and columns that fall outside your filter range: it is recommended that you keep track of the range that your filter has requested, and use `rangeToArray()` instead. + ```php $inputFileType = 'Xls'; $inputFileName = './sampleData/example2.xls';