rap2hpoutre/fast-excel
Fast Excel import/export for Laravel, powered by Spout. Export Eloquent models, queries, or collections to xlsx, ods, or csv with a simple API, customize columns via callbacks, and handle large files efficiently. Benchmark-tested for speed.
startRow() alone used to double as the header row too, so reading a file starting anywhere but row 1 lost the real headers — the first data row got used as the header names instead. headerRow() decouples the two.
$rows = (new FastExcel())->headerRow(1)->startRow(4)->import('file.xlsx');
This is also what makes chunked imports work cleanly: every chunk can read the same header row while sliding its own startRow()/limitRows() window over the data. startRow() on its own keeps its historical meaning, so nothing breaks for existing callers.
Fixes #349, reported by @MaarekVarres.
Cell values starting with =, +, - or @ are treated as formulas by Excel and other spreadsheet software, which can silently execute unintended content when a file is opened. escapeFormulas() writes those values as plain text instead.
(new FastExcel($rows))->escapeFormulas()->export('file.xlsx');
Fixes #356, reported by @LauKL1991. Thanks also to @ariprw and @gmutinel, whose '-prefix workarounds on the issue shaped the fix.
Thanks to @dannyyol for reviewing both of these.
Full changelog: https://github.com/rap2hpoutre/fast-excel/compare/v5.16.0...v5.17.0
XLSX exports can now open as proper right-to-left sheets. Column order, scroll direction and the grid all run right to left, which is what Arabic business documents expect.
(new FastExcel($report))->rightToLeft()->export('report.xlsx');
Multi-sheet exports are covered too: every sheet in a SheetCollection gets the setting, not just the first. Pass rightToLeft(false) to turn it back off. CSV and ODS ignore it, since neither format has an equivalent.
Thanks to @moemadeldin for this one. He opened #420 explaining why configureWriterUsing() couldn't reach the setting (the sheet doesn't exist yet when that hook runs), then sent #421 with the fix and tests covering both the single-sheet and multi-sheet paths. The issue write-up did half the work.
importSheets() can now pass the sheet name to your callback, so the same field names can be treated differently depending on which sheet they came from.
$sheets = (new FastExcel)
->withSheetContext()
->importSheets('file.xlsx', function ($sheetName, $row) {
return $row + ['_sheet' => $sheetName];
});
Requested in #369 by @StarkOne, whose earlier patch shaped the final version.
Full changelog: https://github.com/rap2hpoutre/fast-excel/compare/v5.14.0...v5.15.0
Full Changelog: https://github.com/rap2hpoutre/fast-excel/compare/v5.13.0...v5.14.0
Full Changelog: https://github.com/rap2hpoutre/fast-excel/compare/v5.12.0...v5.13.0
Full Changelog: https://github.com/rap2hpoutre/fast-excel/compare/v5.11.0...v5.12.0
Full Changelog: https://github.com/rap2hpoutre/fast-excel/compare/v5.10.0...v5.11.0
Full Changelog: https://github.com/rap2hpoutre/fast-excel/compare/v5.9.0...v5.10.0
Full Changelog: https://github.com/rap2hpoutre/fast-excel/compare/v5.8.0...v5.9.0
Full Changelog: https://github.com/rap2hpoutre/fast-excel/compare/v5.7.0...v5.8.0
Full Changelog: https://github.com/rap2hpoutre/fast-excel/compare/v3.0.2...v3.1.0
How can I help you explore Laravel packages today?