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
By default, when reading a spreadsheet with dates or times, the values are returned as `DateTimeImmutable` objects. To return a formatted date (e.g., “9/20/2024”) instead, use the `preserveDateTimeFormatting` method. The date format will match what’s specified in the spreadsheet.
297
+
298
+
```php
299
+
$rows = SimpleExcelReader::create($pathToXlsx)
300
+
->preserveDateTimeFormatting()
301
+
->getRows();
302
+
```
303
+
304
+
#### Preserve empty rows
305
+
306
+
You can preserve empty rows by using the `preserveEmptyRows` method.
307
+
308
+
```php
309
+
$rows = SimpleExcelReader::create($pathToXlsx)
310
+
->preserveEmptyRows()
311
+
->getRows();
312
+
```
313
+
294
314
### Writing files
295
315
296
316
Here's how you can write a CSV file:
@@ -367,12 +387,12 @@ foreach (range(1, 10_000) as $i) {
367
387
'first_name' => 'John',
368
388
'last_name' => 'Doe',
369
389
]);
370
-
390
+
371
391
if ($i % 1000 === 0) {
372
392
flush(); // Flush the buffer every 1000 rows
373
393
}
374
394
}
375
-
395
+
376
396
$writer->toBrowser();
377
397
```
378
398
@@ -383,7 +403,7 @@ use Spatie\SimpleExcel\SimpleExcelWriter;
383
403
use OpenSpout\Common\Entity\Row;
384
404
385
405
$writer = SimpleExcelWriter::streamDownload('user-list.xlsx', function ($writerCallback, $downloadName) {
386
-
406
+
387
407
$writerCallback->openToBrowser($downloadName);
388
408
389
409
$writerCallback->addRow(Row::fromValues([
@@ -467,7 +487,7 @@ $border = new Border(
467
487
new BorderPart(Border::RIGHT, Color::LIGHT_BLUE, Border::WIDTH_THIN, Border::STYLE_SOLID),
468
488
new BorderPart(Border::TOP, Color::LIGHT_BLUE, Border::WIDTH_THIN, Border::STYLE_SOLID)
0 commit comments