You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/topics/reading-files.md
+68-1
Original file line number
Diff line number
Diff line change
@@ -168,6 +168,68 @@ Once you have created a reader object for the workbook that you want to
168
168
load, you have the opportunity to set additional options before
169
169
executing the `load()` method.
170
170
171
+
All of these options can be set by calling the appropriate methods against the Reader (as described below), but some options (those with only two possible values) can also be set through flags, either by calling the Reader's `setFlags()` method, or passing the flags as an argument in the call to `load()`.
Many Excel files have empty rows or columns at the end of a worksheet, which can't easily be seen when looking at the file in Excel (Try using Ctrl-End to see the last cell in a worksheet).
205
+
By default, PhpSpreadsheet will load these cells, because they are valid Excel values; but you may find that an apparently small spreadsheet requires a lot of memory for all those empty cells.
206
+
If you are running into memory issues with seemingly small files, you can tell PhpSpreadsheet not to load those empty cells using the `setReadEmptyCells()` method.
207
+
208
+
```php
209
+
$inputFileType = 'Xls';
210
+
$inputFileName = './sampleData/example1.xls';
211
+
212
+
/** Create a new Reader of the type defined in $inputFileType **/
/** Advise the Reader that we only want to load cell's that contain actual content **/
215
+
$reader->setReadEmptyCells(false);
216
+
/** Load $inputFileName to a Spreadsheet Object **/
217
+
$spreadsheet = $reader->load($inputFileName);
218
+
```
219
+
220
+
Note that cells containing formulae will still be loaded, even if that formula evaluates to a NULL or an empty string.
221
+
Similarly, Conditional Styling might also hide the value of a cell; but cells that contain Conditional Styling or Data Validation will always be loaded regardless of their value.
222
+
223
+
This option is available for the following formats:
If your workbook contains a number of worksheets, but you are only
@@ -642,7 +706,7 @@ Xlsx | NO | Xls | NO | Xml | NO |
642
706
Ods | NO | SYLK | NO | Gnumeric | NO |
643
707
CSV | YES | HTML | NO
644
708
645
-
###A Brief Word about the Advanced Value Binder
709
+
## A Brief Word about the Advanced Value Binder
646
710
647
711
When loading data from a file that contains no formatting information,
648
712
such as a CSV file, then data is read either as strings or numbers
@@ -694,6 +758,9 @@ Xlsx | NO | Xls | NO | Xml | NO
694
758
Ods | NO | SYLK | NO | Gnumeric | NO
695
759
CSV | YES | HTML | YES
696
760
761
+
Note that you can also use the Binder to determine how PhpSpreadsheet identified datatypes for values when you set a cell value without explicitly setting a datatype.
762
+
Value Binders can also be used to set formatting for a cell appropriate to the value.
763
+
697
764
## Error Handling
698
765
699
766
Of course, you should always apply some error handling to your scripts
0 commit comments