PDA

View Full Version : convert html table to excel and *.txt document


kalosneri
07-26-2005, 05:07 AM
i have develop a system where it generates all the report by using the asp and mysql. the customer want me to convert all the report to excel spreadsheet document and text document. anybody out there knows the coding please help me. thank u.

SpirtOfGrandeur
07-26-2005, 04:23 PM
To create an excel sheet all you need to do is change the page header into something that is not known by the browser then set the file type.

Response.ContentType = "application/x-download"
Response.AddHeader "content-disposition","attachment;filename=Test.xls"

Then you can go ahead and just print the table code and it will work.

For a text file you must do the same thing with the header

Response.ContentType = "application/x-download"
Response.AddHeader "content-disposition","attachment;filename=Test.txt"

But instead of printing the table code you need to print out the data in a tab formatted list.

Good Luck!

kalosneri
07-27-2005, 02:42 AM
thank you for all your help