please help - Creating a .xls file with PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
grsamson
Forum Newbie
Posts: 1
Joined: Mon May 25, 2009 7:42 pm

please help - Creating a .xls file with PHP

Post 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
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

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

Post by Mark Baker »

Take a look at libraries developed specially for reading/writing Excel files such as PHPExcel
Post Reply