Skip to content

Commit 8ad39f7

Browse files
committed
Update Documentation
1 parent 27bdda2 commit 8ad39f7

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

docs/topics/accessing-cells.md

+21-12
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ particularly when working with large spreadsheets. One technique used to
4646
reduce this memory overhead is cell caching, so cells are actually
4747
maintained in a collection that may or may not be held in memory while you
4848
are working with the spreadsheet. Because of this, a call to `getCell()`
49-
(or any similar method) returns the cell data, and a pointer to the collection.
49+
(or any similar method) returns the cell data, and sets a cell pointer to that cell in the collection.
5050
While this is not normally an issue, it can become significant
5151
if you assign the result of a call to `getCell()` to a variable. Any
52-
subsequent calls to retrieve other cells will unset that pointer, although
52+
subsequent calls to retrieve other cells will change that pointer, although
5353
the cell object will still retain its data values.
5454

5555
What does this mean? Consider the following code:
@@ -441,16 +441,25 @@ foreach ($worksheet->getRowIterator() as $row) {
441441
echo '</table>' . PHP_EOL;
442442
```
443443

444-
Note that we have set the cell iterator's
445-
`setIterateOnlyExistingCells()` to FALSE. This makes the iterator loop
446-
all cells within the worksheet range, even if they have not been set.
447-
448-
The cell iterator will return a `null` as the cell value if it is not
449-
set in the worksheet. Setting the cell iterator's
450-
`setIterateOnlyExistingCells()` to `false` will loop all cells in the
451-
worksheet that can be available at that moment. This will create new
452-
cells if required and increase memory usage! Only use it if it is
453-
intended to loop all cells that are possibly available.
444+
Note that we have set the cell iterator's `setIterateOnlyExistingCells()`
445+
to FALSE. This makes the iterator loop all cells within the worksheet
446+
range, even if they have not been set.
447+
448+
The cell iterator will create a new empty cell in the worksheet if it
449+
doesn't exist; return a `null` as the cell value if it is not set in
450+
the worksheet; although we can also tell it to return a null value
451+
rather than returning a new empty cell.
452+
Setting the cell iterator's `setIterateOnlyExistingCells()` to `false`
453+
will loop all cells in the worksheet that can be available at that
454+
moment. If this is then set to create new cells if required, then it
455+
will likely increase memory usage!
456+
Only use it if it is intended to loop all cells that are possibly
457+
available; otherwise use the option to return a null value if a cell
458+
doesn't exist, or iterate only the cells that already exist.
459+
460+
It is also possible to call the Row object's `isEmpty()` method to
461+
determine whether you need to instantiate the Cell Iterator for that
462+
Row.
454463

455464
### Looping through cells using indexes
456465

0 commit comments

Comments
 (0)