decorative image for this page

Serving an Excel Worksheet to a browser.

23rd June 2006 15:13 | Categories: HowTo, ASP

Writing an excel worksheet to a browser is pretty simple - all you need is the correct response type, and to format the data using an HTML table.

The response type for generating Microsoft Excel worksheets on a server is (the example is in ASP, but it could be any server side technology)

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

After that, write a simple table (without HTML head), and Excel will convert it to a worksheet. You can use formulas etc:

<%Response.ContentType = "application/vnd.ms-excel"%>
<table border="1">
<tr>
<th>Name</th>
<th>Cost</th>
</tr>
<tr>
<td>John</td>
<td>34</td>
</tr>
<tr>
<td>Marl</td>
<td>122</td>
</tr>
<tr>
<th>TOTAL</th>
<td>=SUM(B2:B3)</td>
</tr>
</table>

You can even use style sheet statements to change border styles, background colours, etc.

this is what fritz looks like

Email | Resume

This is a post within the site. You can navigate through posts via the links labelled 'next', or click on 'search/sitemap' at the top right handside of the page to navigate more quickly.

RSS

ampersand

Fritz is an Italian chap who's been living and working in London for almost 20 years.

He's currently technical director for an integrated digital agency.

In the past he's been a chef, a musician, and author of comics.

home

Reading multi language text in Microsoft Office

2006-07-27 15:26 | Tags Microsoft / Windows, HowTo

Reading documents with Cyrillic text is a breeze on a Mac, but with MS Office it can be a right ...

Serving an Excel Worksheet to a browser.

2006-06-23 15:13 | Tags HowTo, ASP

Writing an excel worksheet to a browser is pretty simple - all you need is the correct response type, and ...

Handling dates in Javascript

2006-06-23 15:12 | Tags Javascript / DHTML, HowTo

A few pointers. Comparing Dates If you have two date objects, you need to compare their values returned by their valueOf or ...