Guide to PHP SecurityQuicksearchCalendar
|
Sunday, August 1. 2010PHP Excel Extension
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: 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. Comments
Display comments as
(Linear | Threaded)
Nice work, I also tried PHPExcel for limited used and it was sufficient for me. I have not tried it yet but looks promising.
Hi,
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, Armand
The extension supports fairly robust cell styling capabilities, ranging from font, dimensions, color, patterns, etc...
There is no Windows extension just yet, since I don't have Win32 build environment, but I am going to see if people who do, can help with that.
Hi Ilia,
If you want to try the extension on a Windows box, I can help you with it. Feel free to ping me by email. Best regards,
What is needed is someone with Win32 build environment, to compile the extension...
Yes, I meant that I can provide the box but I just don't have the skills myself.
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.
All this extension does is enable you to write/read Excel files. If you are planning on doing that, then it can probably help.
Thank's for this work ! On waiting windows extension.
Working with the Java Apache POI library via PHP-Java-Bridge was a whole lot more cumbersome, so thanks a lot for sharing this.
"Fortunately the licensing cost is fairly minimal"
Can you provide more info about how to licence it please? Also can I find a documentation of your extension somewhere? I could not find it on github. Thanks!
The licensing info can be found at: http://www.libxl.com/purchase.html
For most people it is a one-time fee of $199 There are no docs atm, however there are tests that have a sample of just about every method available. |
ArchivesCategoriesSyndicate This BlogBlog Administration |
|||||||||||||||||||||||||||||||||||||||||||||||||










Comments