Forum Moderators: open

Message Too Old, No Replies

ASP generating Excel

This is a very useful way to download summary data

         

cyril kearney

12:51 am on Nov 26, 2001 (gmt 0)

10+ Year Member



It is fairly straight forward to generate an Excel Spreadsheet from an ASP Page.

Include:
Response.ContentType = "application/vnd.ms-excel"

as the first line of code. Instead of sending back an HTML document, asp will send it back as a spreadsheet. Your <table>,<tr> and <td> will be used to get things to the right cells.

Including things like =SUM(A1:A10) will be interpeted as a formula.

The client pc must have Excel installed on it to use this output. When the spreadsheet is downloaded the file may be displayed in the IE 5.5 and NS 4.7 browser or saved to a file.

Does anyone have any experience is loading VBA to the downloaded spreadsheet?

gethan

9:45 am on Nov 26, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've done similar using perl.

print "Content-Type: application/vnd.ms-excel\n\n"; - instead of text/html.

using \t as delimiters for the columns - not html - though I'll try that later, find out whether its asp or excel handling the conversion.

Thanks for the tip on formulas. As for VBA erm ... nope not done that yet (hoping I don't have to ;))

Tapolyai

12:47 am on Dec 4, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



An other very easy way to do this is create the pagewith .CSV extension, be it static or on the fly.

On Windows, Macs and even Linux, where .CSV is associated with a spreadsheet software the it will be properly interpreted as a spreadsheet.

caveat emptor - CSV will only allow data not functions or formating.

sdaly

3:48 pm on Jan 11, 2002 (gmt 0)



Does anyone know how to get the excel sheet, once rendered using asp, to retain it's original form and spacing?