Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Simple Excel

Simple Excel Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Read and write simple Excel and CSV files

Frequently asked questions about Simple Excel
How does spatie/simple-excel handle large Excel/CSV files without memory issues?
The package uses PHP generators and Laravel’s LazyCollection to process files row-by-row, avoiding loading entire spreadsheets into memory. This makes it ideal for files over 100MB, as each row is streamed dynamically during iteration.
Can I use spatie/simple-excel in a non-Laravel PHP project?
Yes, but with limitations. While it works with vanilla PHP, you’ll need to handle collections manually (e.g., using IteratorAggregate) since it relies on Laravel’s LazyCollection by default. The core functionality remains the same for reading/writing files.
What Laravel versions does spatie/simple-excel support?
The package supports Laravel 8.x, 9.x, and 10.x. Check the [GitHub repo](https://github.com/spatie/simple-excel) for the latest compatibility details, as minor updates may align with new Laravel releases.
How do I convert CSV headers to snake_case automatically?
Use the `headersToSnakeCase()` method when creating the reader: `SimpleExcelReader::create($file)->headersToSnakeCase()->getRows()`. This ensures headers like `FirstName` become `first_name` in your processed data.
Does spatie/simple-excel support multi-sheet Excel files?
No, the package focuses on single-sheet operations. For multi-sheet Excel files, consider alternatives like PhpSpreadsheet or PhpOffice/PhpSpreadsheet, though they require more memory for large files.
How can I validate or sanitize CSV data before processing?
Use the `formatHeadersUsing()` or `transformUsing()` methods to preprocess rows. For example, `transformUsing(fn($row) => filter_var($row['email'], FILTER_VALIDATE_EMAIL))` ensures only valid emails pass through.
Will spatie/simple-excel work with Laravel queues or jobs?
Absolutely. Since it returns a LazyCollection, you can chain operations like `getRows()->each()` directly in a job or queue. This is perfect for background processing of large imports without blocking requests.
How do I handle malformed Excel/CSV files (e.g., missing headers, corrupt data)?
The package skips malformed rows by default. For stricter control, wrap the `getRows()` iteration in a try-catch block or use `transformUsing()` to validate each row before processing.
Can I stream Excel files directly to a browser for download?
Yes, use the `toBrowser()` method on `SimpleExcelWriter` to stream files directly. For large files, manually flush output buffers (`ob_flush()`) to avoid timeouts or memory spikes during download.
What are the alternatives to spatie/simple-excel for Laravel Excel handling?
For lightweight needs, this package is ideal. For advanced Excel features (e.g., formulas, charts), use PhpSpreadsheet. For CSV-only tasks, League/Csv is a minimal alternative. Choose based on memory constraints and feature requirements.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony