I need to use php to change an html table to an MS excel document. Is it possible?
anybody have a good tutorial or (free or low-cost) solution?
Thanks!
ernieweaselfat 2008.01.03, 05:24PM — php to xls?
Tha.Riddla 2008.01.03, 07:24PM —
you can open .html files in excel....table cells/rows/columns convert. or did you need something very specific?
Stickman 2008.01.04, 09:37AM —
XLS Reader -- costs US$67.
xls2mysql -- costs $15, converts to MySQL but you could either hack that bit out or just export from MySQL to HTML afterwards
ernieweaselfat 2008.01.04, 10:04AM —
Originally posted by: Stickman
XLS Reader -- costs US$67.
xls2mysql -- costs $15, converts to MySQL but you could either hack that bit out or just export from MySQL to HTML afterwards
I actually want to go the other way php --> xls. I found that xls generator one before (the same company that makes xls reader), have you used it, Stick? I just want to make sure it works before I buy it...
Stickman 2008.01.04, 11:07AM —
Ah..oops. I blame the drugs I'm on for this stupid cold, I feel like I have a head full of sawdust.
No I haven't tried it, sorry. I just Googled. 
ernieweaselfat 2008.01.07, 10:15AM —
Originally posted by: ShEx
I've used the pear one before, there's an article on it here
cool, thanks, ShEx.
scudsucker 2008.01.16, 09:28AM —
Just set the mime type and spit out the HTML page- Excel will recognise it as an XLS:
header('Content-type: application/vnd.ms-excel');
If you want to force a download (rather than have IE open it in the browser) add
header('Content-Disposition: attachment; filename="ExcelDoc.xls"');
poliguin 2008.01.16, 02:21PM —
the one caveat with that is it depends on the type of document reader you have. In open office it will open it as a html document in calc and you won't have the same functionality as you would normally expect in an excel document. Microsoft Excel doesn't have a problem with it.
I haven't tried others.
With that said, the best solution I've found cross different excel readers is to us the XML format. As far as I've noticed the readers use the Microsoft Excel format (or at least recognize it).
blogs.msdn.com/brian_jones/archive/category/10277.aspx
It can be a little annoying to debug though. If there are errors with the client they will get an alert saying that there was some sort of error in some temporary document. You will need this document in order to track down the error (if you can't reproduce it yourself).
It will require open office or MS Excel 2003+.

