tags:

views:

190

answers:

1

Hi there

My application generates some .xls files and until now I was using PHPExcel lib. One of the SO has recommend me to use this approach. The problem is that I have to use some .xls templates and to append some data to them.

Who can help me with some pointers. I don't get how xlsBOF() and xlsEOF() works or have to work in my case.

many thanks

+2  A: 

If the approach you use right now works for you, don't bother with anything else.

PHPExcel writes XML files (or more accurately zip files containing XML files), in the new Excel 2007 format. For this reason, it's not compatible with older office versions (unless you install the compatibility plugin in the older office).

What this code does is write a binary XLS file in Excel 97 (BIFF8) format. It's a bit of a hack though. This won't deal correctly with unicode issues and so on. xlsBOF writes the binary header of the XLS file, and xlsEOF the footer.

If you want to write binary XLS files, you're better off using PEAR Excel Writer. I have mixed experiences with that. It gets the job done, but to use it with unicode you have to look through the bug list for a few patches that fix BIFF8 format bugs (the package is poorly maintained). It's still better than the code you linked to though.

Update: PHPExcel supports export as Excel 97 also. I remember that it used to be limited to the office 2007 file format, but apparently currently it's not. So I would recommend using PHPExcel.

Joeri Sebrechts
I might be wrong, but the API suggests PHPExcel has writers for Excel2007, Excel5, CSV, HTML and PDF.
Gordon
@Gordon: thanks for the heads up.
Joeri Sebrechts
@Gordon: it works, but it takes 3-4 seconds to generate a file. And the file isn't to big, it is about 1000 records only(30rows*30col*30 sheets + some headers).
dole doug
@dole doug: I really can't say much about PHPExcel or how it performs. I just remembered to have created Excel5 files from it once. The good thing is, it works, isn't it?
Gordon