Export your application/vnd.ms-excel
as an HTML table, it gives you access to a variety of worksheet formatting options:
Use:
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("content-disposition", "attachment; filename=" + fileName);
And send something like the following:
<table border="1">
<caption>This is a caption, it appears centered across all columns</caption>
<colgroup>
<col width="100">
<col width="200">
</colgroup>
<tr valign="bottom">
<td><b>Header 1</b></td>
<td filter="all"><b>Header 2 (filterable)</b></td>
</tr>
<tr valign="top">
<td style="vnd.ms-excel.numberformat:$#,##0.00_)[semicolon]($#,##0.00)">1</td>
<td style="vnd.ms-excel.numberformat:00000000">2</td>
</tr>
<tr valign="top">
<td style="vnd.ms-excel.numberformat:$#,##0_)[semicolon]($#,##0)">3</td>
<td style="vnd.ms-excel.numberformat:00000000">4</td>
</tr>
<tr valign="top">
<td style="vnd.ms-excel.numberformat:$#,##0.00_)[semicolon]($#,##0.00)">-5</td>
<td style="vnd.ms-excel.numberformat:00000000">2</td>
</tr>
<tr valign="top">
<td style="vnd.ms-excel.numberformat:$#,##0.00_)[semicolon][red]$#,##0.00">-7</td>
<td style="vnd.ms-excel.numberformat:00000000">8</td>
</tr>
<tr valign="bottom">
<td formula="=sum(a2:a5)" style="vnd.ms-excel.numberformat:$#,##0.00_)[semicolon][red]$#,##0.00"></td>
<td formula="=average(b2:b5)" style="vnd.ms-excel.numberformat:00000000"></td>
</tr>
</table>
Note that by using the HTML table syntax you can add a column AutoFilter, specify the vertical row alignment, control the width of columns, combine columns with <colspan>
(not shown), add formulas and specify the format of column data with vnd.ms-excel.numberformat. You can even do Crosstab (PivotTables) (not shown).
I had a link to more comprehensive documentation about what HTML tags and attributes are supported, and what they do, but I seem to have misplaced it. If anyone else has a good link to Microsoft documentation about this, feel free to edit my answer or include a comment.
EDIT: It seems that you can do a lot more with HTML/XML to build complicated Excel worksheets. I've never gone to these lengths, but it is interesting to know what is possible.