Skip to content

Commit f51f4bc

Browse files
author
MarkBaker
committed
Update change log and documentation
1 parent 09c66ab commit f51f4bc

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
3131
- Memory and speed improvements, particularly for the Cell Collection, and the Writers.
3232

3333
See [the Discussion section on github](https://github.com/PHPOffice/PhpSpreadsheet/discussions/2821) for details of performance across versions
34+
- Improved performance for removing rows/columns from a worksheet
3435

3536
### Deprecated
3637

docs/topics/recipes.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1348,14 +1348,31 @@ Removing a merge can be done using the unmergeCells method:
13481348
$spreadsheet->getActiveSheet()->unmergeCells('A18:E22');
13491349
```
13501350

1351-
## Inserting rows/columns
1351+
## Inserting or Removing rows/columns
13521352

13531353
You can insert/remove rows/columns at a specific position. The following
13541354
code inserts 2 new rows, right before row 7:
13551355

13561356
```php
13571357
$spreadsheet->getActiveSheet()->insertNewRowBefore(7, 2);
13581358
```
1359+
while
1360+
```php
1361+
$spreadsheet->getActiveSheet()->removeRow(7, 2);
1362+
```
1363+
will remove 2 rows starting at row number 7 (ie. rows 7 and 8).
1364+
1365+
Equivalent methods exist for inserting/removing columns:
1366+
1367+
```php
1368+
$spreadsheet->getActiveSheet()->removeColumn('C', 2);
1369+
```
1370+
1371+
All subsequent rows (or columns) will be moved to allow the insertion (or removal) with all formulae referencing thise cells adjusted accordingly.
1372+
1373+
Note that this is a fairly intensive process, particularly with large worksheets, and especially if you are inserting/removing rows/columns from near beginning of the worksheet.
1374+
1375+
If you need to insert/remove several consecutive rows/columns, always use the second argument rather than making multiple calls to insert/remove a single row/column if possible.
13591376

13601377
## Add a drawing to a worksheet
13611378

0 commit comments

Comments
 (0)