PHPExcel vs PHP_XLSXWriter Comparison
PHPExcel is a common library used for writing XLSX files. However when writing large spreadsheets, it starts to show its memory and CPU limitations.
PHPExcel discussions are full of reports of memory being exhausted.
* Out of memory when writing huge file
* Memory exhausted in large data
* Writing Large Dataset to Excel XLSX Failing
* How to handle large files
Below are a few test cases, writing large xlsx spreadsheet files with PHPExcel and PHP_XLSXWriter for comparison.
|Case 1: 10 columns, 10,000 rows in 4 sheets (400,000 cells)|
|Case 2: 10 columns, 10,000 rows in 6 sheets (600,000 cells)|
|Case 3: 10 columns, 20,000 rows in 4 sheets (800,000 cells)|
In a few simple tests, PHP_XLSXWriter shows a 98% savings on memory and 95% savings on time when compared to PHPExcel for writing large files. Though PHPExcel may have more features, it doesn't compare with PHP_XLSXWriter when it comes to performance.
Internally, PHPExcel stores a representation of each cell in memory before being able to write it. PHP_XLSXWriter on the other hand, writes the spreadsheet to a temporary file as it goes, which saves on memory and speed in cases of large files.