PDA

View Full Version : Excel export from .php



SameerMirza
11-13-2009, 04:19 PM
hi all,
I have just created a simple web application based on php and mssql which retrieves the records from databse on user request and displays it on the screen. Now I want to add an export excel button on .php file so that user can export the records to .csv file if required.

Can any one please help me out with it. I know there are few solutions available when you google on it but problem is that most are just for IE but I am looking for more general solution. It is urgent for me and I hope some one will be able to help me out with it.

Regards,
Sameer.

maneetpuri
11-20-2009, 11:02 AM
Hi,

This what you can do, when the user clicks to get the XLS then fetch the records from the database and start creating a string that mainly will be the code for html table. Once this is ready open a new file connection for a .xls file, write this string in that file and close the file extension then change the header type of the page to Excel and through the XLS file as the output and the user will get what he needs.

Hope this helps.

Cheers,

~Maneet

jude.fernando.1960
11-20-2009, 01:25 PM
Follow this thread
http://www.dynamicdrive.com/forums/showthread.php?t=43955