Since I broke my right hand 3 weeks ago while biking, I found myself with a lot of spare time :/. It is amazing just how limited your ability to do things becomes when you can only use one hand. So, to stave off the boredom, I've been slowly toiling away on a PHP Excel extension that I intend to use at work, which I've finally gotten ready for release today.
You can find it on github at: http://github.com/iliaal/php_excel.
First of all, why? Our business requirements at work require us to frequently to generate Excel versions of the reports from the system and occasionally import data from Excel. For last few years we've done this via php classes; Spreadsheet Excel Writer and Reader. They do the job, but have severe limitations, one them being speed, and the other the output that supports only BIFF5. Unfortunately quite a few things don't grok BIFF5, such as Blackerries, Numbers from Apple's iWork, iPhones, etc… In instances when this poses an issue we've mitigated the problem by up-converting to BIFF7 via Gnumeric's command line tool, at a further speed loss. A workable, but a sub-optimal solution.
As we are doing more & more Excel output generation, this became a bigger and bigger problem. At first we've tried solving the problem via a newer PHP based Excel library, PHPExcel. Unfortunately, it is massive beast, that is not only slower than the old Spreadsheet Excel Writer/Reader, but memory hog too. Without caching, 1 Excel cell takes 10kb(!!!!) of memory and with caching a mere 1kb of memory. Trying to generate a 500-600 cell spreadsheet easily spikes one X5560 @ 2.80GHz core a few seconds, even after we've spent some time tweaking the library.
So, I turned to Google and found LibXL, which is a small, C++ (with C, C++ interfaces) library that promised really fast Excel reading & writing. The library natively generates BIFF 7/8 format, which can be opened all devices and Excel readers I've tried it on and is available for Linux, Mac and Windows. Unfortunately, the library is not Open Source, it is a closed source commercial product and while I'd prefer to use an Open Source solution, it is what it is. Fortunately the licensing cost is fairly minimal and the promised speed was quite amazing and after a few small test cases I was sold. Hence the 1.5 week process of writing PHP interface to it with one hand .
The end result is a PHP extension that offers a complete, object oriented interface to the library that allows you to do just about anything with Excel. I've also introduced a few helper functions to streamline reading/writing from Excel files. The speed and memory usage are pretty damn impressive, on my debug build of PHP, it can generate 10,000 cells in 0.03 seconds with a 262kb complete PHP memory usage, not just the code. Sample script is below:
$sT = microtime(1);
$x = new ExcelBook();
$s = $x->addSheet("Sheet 1");
The extension is fully object oriented, and includes some 50 tests that demonstrate all of the available functionality, I've also added arginfo information, so you can see interrogate all of the available functionality via Reflection extension. Outside of that there is no documentation yet, I'll try to get to it, when I can better use my right hand (hopefully soon).
So if you need to work with Excel files, definitely try this little extension, maybe it can help you as well. If you have any feedback on bugs, or suggested features I please let me know...
One thing I should note, is that the underlying library currently does not support Office's XML format.
I have the same experience with phpexcel. It's eat all the php's memory even if it is set to its maximum.
Does your extension support for styling cells? and does a precompiled windows extension exists?
Many thanks and all bests for your right hand,
Hello I am new to php/mysql and am told you can do anything with it! I am currently working with excel spreadsheets and want to enable workers to input their hours and expenses onto a database from anywhere in the world. Will this application help? Any help would be gratefully recieved. Kind regards, Paul Winter.