r/PHPhelp • u/TheMungax • Nov 18 '21
Best Excel lib for PHP
So I'm going to create a excel extract option with the data retrieved from my database, but which excel lib is the best to use in 2021?
The Excel lib should be able to create sheets, and columns with colors, and merging cells together etc.
I see that there is a lot like PHPEXCEL, PHP EXPORT DATA & PEAR EXCEL WRITER, but what are your experience with this and what should I choose?
1
u/miamiscubi Nov 18 '21
I've use both phpoficce/phpspreadsheet and box/spout https://github.com/box/spout
Personally, for reading Excel files, I prefer the spout library, but I haven't looked at their latest update. For my use case, I didn't need to do any cell merging or colors because my clients want a raw output they can then use in a pivot table. However, for reading excel documents, I think it performs better than phpspreadsheet as far as memory goes, especially for large files.
My understanding of the main difference between PHPSpreadsheet and SPOUT on the read side is that PHPSpreadsheet will keep the whole file into memory, so if you load a 65MB file, it'll keep track of every cell in that document. However, SPOUT goes through the files sheet by sheet and row by row, and doesn't keep track of what's going on in the following or previous rows.
PHPEXCEL is I believe deprecated, and I wouldn't recommend it.
10
u/CyberJack77 Nov 18 '21
We use phpoffice/phpspreadsheet. It is actively maintained and used a lot (54M+ installs according to Packagist).