The first thing we do in our script is to set the Content Type we are going to return to the client browser.
Response.ContentType = "application/vnd.ms-excel"
Now that we have told the browser that we are sending back an Excel file, we simply create our standard HTML table and send that back. This table could be generated from the results of a database query for example or simply a static HTML.A demo is available, and the source code is below :
<table>
<tr>
<td><b>Main Header</b></td>
<td><b>Content</b></td>
</tr>
<tr>
<td>First Column, First Cell</td>
<td>First Column, Second Cell</td>
</tr>
<tr>
<td>Second Column, First Cell</td>
<td>Second Column, Second Cell</td>
</tr>
</table>
<table>
<tr>
<td><b>First Value</b></td>
<td><b>Second Value</b></td>
<td><b>Total</b></td>
</tr>
<tr>
<td><b>10</b></td>
<td><b>20</b></td>
<td><b>=Sum(A2:B2)</b></td>
</tr>
</table>
This should suffice many developers, but if you need a little more flexibility or complexity, then you will have to use an ActiveX component, as detailed in the next section.