Page 1 of 1

Export to excel in php

Posted: Thu Jul 02, 2009 6:13 am
by r4r4
I am trying to export data from a mysql database to an excel spreadsheet using php. The script works fine in Excel 2003, but in 2007 I get the folowing error:

The file your are trying to open 'filename.xls', is in a different format that specified by the file extension. Verify that the file is not corrupted and is from a trusted srouce before opening the file. Do you want to open the file now?

You can still click "yes" and open the file. Anyone know a way to solve this annoyance?

Re: Export to excel in php

Posted: Thu Jul 02, 2009 6:15 am
by Mark Baker
r4r4 wrote:I am trying to export data from a mysql database to an excel spreadsheet using php. The script works fine in Excel 2003, but in 2007
Anyone know a way to solve this annoyance?
Well to start with, how are you generating your Excel spreadsheet?

Re: Export to excel in php

Posted: Thu Jul 02, 2009 6:29 am
by SeaJones
CSV is the simplest way, but PHPExcel is also a great tool for when you need a bit more flexibility as to how the sheet turns out. There are one or two other php Excel libraries out there, if you google them.

Re: Export to excel in php

Posted: Thu Jul 02, 2009 11:54 am
by califdon
Split from another topic. Note to original poster: please ask new questions as a new post, don't "tail-gate" on another topic.