homepage Welcome to WebmasterWorld Guest from 54.196.77.82
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Can PHP write Excel 2003/2007 file from data taken from database?
dbarasuk




msg:4294037
 6:13 am on Apr 8, 2011 (gmt 0)

Hi all,
At my workstation we have a mysql database containing customers payment information. My boss has just asked me to write a PHP application that can get data from this database and point the business analysts to save or download query results from the database in an excel format, either Excel 2003 or 2007. I have never done this task before. Searching on the web i found a tutorial that says this could be possible using a PEAR package SpreadSheetExcelWriter but generating only Excel version 5 (version of 1993), which means this PEAR version cannot help me.

Has someone done this task in the past or just point me to a good tutorial?

Thank you for your time to help.

 

Matthew1980




msg:4294049
 7:42 am on Apr 8, 2011 (gmt 0)

Hi there dbarasuk,

*Hopefully* I am not breaking any forum rules with this link; but I think this will be useful to you, I was playing with this last year, and has been in my bookmarks list ever since!

Have a play! [the-art-of-web.com]

If your successful, let us know. I just tried this code, and it works for me in excel 2003;2007 so should be good.

Cheers,
MRb

dbarasuk




msg:4294138
 1:07 pm on Apr 8, 2011 (gmt 0)

Dear Matthew1980,
thank you so much. The link you gave me contains code that works fine. However, if you remember the code, it has a series of php native functions that are throwing errors in the generated excel file, those are array_values() and implode(). This first one was saying that the first parameter is expected to be an array and a NULL value was passed to it. This was a simple warning because i saw the excel file generated from the database.
Is there any other way to format the headers (comming from the database table) to something more readable by humans, and not just the table columns?

Thanks

drooh




msg:4298086
 5:12 am on Apr 15, 2011 (gmt 0)

you might try searching for php excell codeplex

henry0




msg:4299147
 9:48 pm on Apr 16, 2011 (gmt 0)

Can't you directly from MySQL save as a CSV
then you have it

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved