HELP with a Export to Excel Button

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
StaticConvulsioN
Forum Newbie
Posts: 3
Joined: Thu Apr 26, 2007 12:30 pm

HELP with a Export to Excel Button

Post by StaticConvulsioN »

Hello, i have a web page that works with a database, and i print database reports, but now i need a button,
that exports those reports to excel, does anyone now how to do this, im using plain php, plz i need help thnxs,
im not too knowledgeable with php, so i need help to understand how to do this

THNXS.
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

The simplest way to do it is to export as a CSV (comma-separated values) file, which is just a plain text file. If I remember correctly, Excel is pretty lenient when it comes to format, but a row would normally have its values enclosed in double quotes and separated by commas or tabs. Rows are terminated with \n or \r\n.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Most php developers are better in generating html than csv.. So i would consider the simplest way to generate a html table that represents the excel sheet... If the file is stored with an xsl extension excel will happily open it ;)
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

I didn't know that, but when I tried it out, excel was displaying it without borders.
Post Reply