Page 1 of 1

please help - Creating a .xls file with PHP

Posted: Mon May 25, 2009 7:52 pm
by grsamson
Does anyone have any experience in saving an Excel spreadsheet via php? Here is my situation:

I need to create an Excel file and save it on the server. (It is eventually emailed as an attachment to someone.) Thus it needs to be a flat xls file, not a dynamic php file with php headers for Excel.

So far, I can successfully create and save the .xls file (populated with xhtml table data), but the file appears to have some issues, and needs to be resaved in Excel before the data can be processed -- I am guessing it is because when saving the file there is no reference to any document headers, though I am not sure about this.

Very grateful if you can help with some code. Currently I am simply using fwrite() to save the file called "test.xls".

Thanks,
Geoff

Re: please help - Creating a .xls file with PHP

Posted: Tue May 26, 2009 2:57 am
by Mark Baker
Take a look at libraries developed specially for reading/writing Excel files such as PHPExcel