Laravel XlsWriter: High‑Performance Excel Read/Write Extension Guide
This article introduces the Laravel‑XlsWriter package, explains its high‑performance PHP‑C extension features for writing and reading Excel files, and provides step‑by‑step installation, configuration, and usage instructions including service provider registration, facade aliasing, publishing, and mode options.
php‑xlswriter is a high‑performance PHP C extension for reading and writing Excel 2007+ XLSX files, and Laravel‑XlsWriter wraps this extension to offer an easy‑to‑use Laravel package that currently supports exporting, with reading to be added later.
Features:
xlswriter is a PHP C extension that can read data, insert multiple worksheets, write text, numbers, formulas, dates, charts, images, and hyperlinks.Write: 100% compatible Excel XLSX files, full Excel format, merged cells, sheet naming, filters, charts, data validation, dropdowns, PNG/JPEG images, memory‑optimized mode for large files, cross‑platform support (Linux, FreeBSD, OpenBSD, macOS, Windows), 32‑ and 64‑bit builds, FreeBSD license, only depends on zlib.
Read (future): full data read, cursor read, type‑aware read, XLSX‑to‑CSV conversion.
Installation:
composer require lysice/laravel-xlswriterAfter installation, add the service provider to config/app.php :
'providers' => [
// ... other Laravel service providers
\Lysice\XlsWriter\XlsWriterServiceProvider::class,
];Register the facade alias:
'aliases' => [
// ... other aliases
'Excel' => \Lysice\XlsWriter\Facade\Writer::class,
];Publish the configuration file:
php artisan vendor:publish --provider="Lysice\XlsWriter\XlsWriterServiceProvider"Configuration options:
extension : output file extension, currently supports xlsx and csv .
mode : export mode, either normal or memory‑optimized. Use constants Excel::MODE_NORMAL or Excel::MODE_MEMORY .
export_mode : data export style, either direct export ( Excel::EXPORT_MODE_DATA ) or row‑by‑row export ( Excel::EXPORT_MODE_ROW ).
To verify that the xlswriter extension is correctly installed, run:
php artisan xls:status +---------+---------------------------------------------+
| version | 1.0 |
| author | lysice
|
| docs | https://github.com/Lysice/laravel-xlswriter |
+---------+---------------------------------------------+
XlsWriter extension status:
+-------------------------------+----------------------------+
| loaded | yes |
| xlsWriter author | Jiexing.Wang ([email protected]) |
| xlswriter support | enabled |
| Version | 1.3.7 |
| bundled libxlsxwriter version | 1.0.0 |
| bundled libxlsxio version | 0.2.27 |
+-------------------------------+----------------------------+After following these steps, the Laravel‑XlsWriter package should be ready for high‑performance Excel export in your Laravel applications.
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.