Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Send down Excel files w/o Excel - just regular code
Old 09-18-2007, 02:52 AM Send down Excel files w/o Excel - just regular code
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
Trades: 0
Since Office 2002, which most people have by now, Excel has supported a format called "XML Spreadsheet." As the name implies, it's just a text file, so you can produce these things on the fly without having to buy a thing. And everyone loves using Excel to filter, sort, and graph data; it makes them feel smart. Plus, it prints a lot better than raw html. Check Microsoft's reference to make sure you get the number formats right.

One approach is xslt transforms on the server; most browsers have xslt, but not when you want to use different mime types. You're better off taking a sample report in the format you like, then using File -> Save As -> File Type: XML Spreadsheet, then finding the few edits you'll need to make. One is obvious, the data itself, but you'll have to change the size of the worksheet, too.

Finally, either use Response.Write("<content type=application/vnd.ms-excel>") or Response.ContentType = "application/vnd.ms-excel" and send the data. Or, build the file in advance and link to it, letting IIS actually serve it up.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
 
Register now for full access!
Old 09-18-2007, 08:23 AM Re: Send down Excel files w/o Excel - just regular code
Experienced Talker

Posts: 44
Trades: 0
Thanks for sharing the info.It seems to be quite useful.
__________________

Please login or register to view this content. Registration is FREE

Best Place to hunt for Code
codingmaster is offline
Reply With Quote
View Public Profile
 
Old 09-18-2007, 02:29 PM Re: Send down Excel files w/o Excel - just regular code
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
You can use XML in the old school ASP? Are you sure?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 09-19-2007, 12:03 AM Re: Send down Excel files w/o Excel - just regular code
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
Trades: 0
Of course you can use XML in asp 3.0! It's plain text - that's the appeal. All you need to do is stream a particular flavor of XML down to the client with search and replace string functionality. It's actually pretty easy.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Old 09-24-2007, 08:48 AM Re: Send down Excel files w/o Excel - just regular code
Junior Talker

Posts: 2
Trades: 0
Hi,
Its very interesting and informative.As i am a bud in this technology ,Really it is useful and helpful for me.Thanks for sharing with us.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Raeligh is offline
Reply With Quote
View Public Profile
 
Old 09-24-2007, 01:53 PM Re: Send down Excel files w/o Excel - just regular code
Skilled Talker

Posts: 97
Name: Ganesh
Trades: 0
If its a single sheet report a simplest and fastest way to reproduce excel output is.

Using the FileSystem object create the flat file with html table statements like below and save as .xls file. When the html get opened in excel, it uses the table structure to rows and columns, fastest ever.

This code will trigger excel to open with the desired output.


Code:
<%
Response.ContentType = "application/vnd.ms-excel"
Response.write("<table>")
Response.write("<tr>")
Response.write("<th>")
Response.write("column  header 1")
Response.write("</th>")
Response.write("<th>")
Response.write("column  header 2")
Response.write("</th>")
Response.write("</tr>")
 
Response.write("<tr>")
Response.write("<td>")
Response.write("Row 1 column  data 1")
Response.write("</td>")
Response.write("<td>")
Response.write("Row 1 column  data 2")
Response.write("</td>")
Response.write("</tr>")
 
Response.write("<tr>")
Response.write("<td>")
Response.write("Row 2 column  data 1")
Response.write("</td>")
Response.write("<td>")
Response.write("Row 2 column  data 2")
Response.write("</td>")
Response.write("</tr>")
Response.write("</table>")
 
%>
__________________
Gather. Search. Compare. Save on Hotel and Flight Prices @
Please login or register to view this content. Registration is FREE
sri_gan is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Send down Excel files w/o Excel - just regular code
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30779 seconds with 12 queries