ASP 101 - Active Server Pages 101 - Web06
The Place ASP Developers Go!

Please visit our partners

Windows Technology Windows Technology
15 Seconds
ASP 101
ASP Wire
VB Forums
VB Wire
internet.commerce internet.commerce
Partners & Affiliates

ASP 101 is an site
ASP 101 is an site
Internet News
Small Business
Personal Technology

Corporate Info
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash

 Top ASP 101 Stories Top ASP 101 Stories
An Overview of ASP.NET
Connections, Commands, And Procedures
What is ASP?

Server-Side vs. Client-Side Scripting
Show All Tips >>
ASP 101 RSS Feed ASP 101 Updates

Quick Tips

Displaying Data from ASP in Excel

The following sample script creates an Excel spreadsheet with three columns.

The first two contain numeric data in the cells and the third sends a function which will calculate a sum of the numbers in the first two columns.

<%@ Language=VBScript %>
Response.Buffer = True
Response.ContentType = "application/"
<table border="1">
    <th>Column A</th>
    <th>Column B</th>
    <th>Totals Column</th>
    <td><font color="red">=sum(a2:b2)</font></td>
    <td><font color="red">=sum(a3:b3)</font></td>

The above code will work in IE 4 and above. The client also needs to have Microsoft Excel installed. The magic is the Response.ContentType command. It tells the browser what type of content to expect... in this case an Excel Spreadsheet. The rest of what happens is all dependent on how Excel handles the HTML and luckily it does a pretty darn good job.

While this won't let you do everything Excel is capable of, it can be quite handy if, for example, you're developing an Intranet and just want to send a user some data that they then need to perform some calculations with. Just return your data as standard HTML and let Excel handle it.

And don't hesitate to try things like borders or even complex formatting... you'd be amazed at how much Excel knows about HTML.

Previous      Show All Tips      Next

If you have a tip you would like to submit, please send it to:

Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback
The Network for Technology Professionals



Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers