spatie/simple-excel
Lightweight reader/writer for simple CSV and XLSX files in PHP/Laravel. Uses generators and LazyCollection for low memory usage on large files. Quickly stream rows for processing or export data without loading entire spreadsheets into memory.
LazyCollection) but remains compatible with vanilla PHP via openspout/spout, making it versatile for both Laravel and non-Laravel PHP applications.SimpleExcelReader/SimpleExcelWriter) with fluent methods (e.g., headersToSnakeCase(), fromSheet()) reduces integration complexity.LazyCollection enables seamless integration with Laravel’s query builder, Eloquent, and other collections.openspout/spout, but requires manual handling of collections (e.g., IteratorAggregate).spatie/simple-excel and openspout/spout (handled as a transitive dependency).LazyCollection (e.g., eager loading) could still cause spikes. Risk mitigated by documentation/examples.formatHeadersUsing) for custom handling.toBrowser()) requires careful buffer management for large datasets (e.g., flush() calls).LazyCollection integration enables seamless chaining with Eloquent, queues, or jobs (e.g., SimpleExcelReader::create()->getRows()->each(fn($row) => Model::create($row))).IteratorAggregate). Useful for CLI scripts or non-Laravel PHP apps.openspout/spout (included transitively).spatie/simple-excel.SimpleExcelReader for imports).SimpleExcelWriter for exports).openspout/spout compatibility..xlsx (not .xls). Multi-sheet functionality available but limited to basic operations.openspout/spout (~3MB) may increase bundle size slightly.SimpleExcelReader for data ingestion (lower risk).getRows() + LazyCollection.SimpleExcelWriter for exports (higher risk due to streaming/browser handling).streamDownload().formatHeadersUsing) for edge cases.openspout/spout may require occasional updates.spatie/simple-excel version in composer.json to avoid breaking changes.getReader() to access openspout/spout for low-level debugging.LazyCollection operations to identify memory leaks.toBrowser()) reduces peak memory but may increase CPU usage.LazyCollection supports parallel processing (e.g., chunk() for batch imports).->chunk(1000)->each()).skip()/take() to process subsets of data.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Corrupt Excel/CSV file | Application crash or silent failure | Validate files pre-processing (e.g., file_exists, fopen). |
| Out-of-memory on large files | Worker process death | Use LazyCollection + chunking. Monitor memory. |
| Browser streaming timeout | Partial/incomplete downloads | Implement flush() for large streams. |
| Header parsing errors | Incorrect data mapping | Use useHeaders() or formatHeadersUsing. |
| Multi-sheet Excel misconfiguration | Wrong sheet processed | Validate sheet names/indices pre-processing. |
| Dependency conflicts | Package installation failures |
How can I help you explore Laravel packages today?