Thursday, March 6, 2008

Excel file with CFcontent

It is extremely easy to give your customers access to an Excel file containing their data.

The key is a nicely formatted HTML table, with correctly placed cfheader/cfcontent tags.
Consider the following example:

<cfsetting showdebugoutput="no">
<cfheader name="Content-Disposition" value="attachment;filename=""My File Name.xls""">
<cfcontent type="application/msexcel;charset=utf-16">
<table>
<tr>
<th>Color</th>
<th>Code</th>
</tr>
<tr>
<td>red</td>
<td>#ff0000</td>
</tr>
<tr>
<td>green</td>
<td>#00ff00</td>
</tr>
<tr>
<td>blue</td>
<td>#0000ff</td>
</tr>
</table>
<cfabort>


If you have any other tips or ideas feel free to share them!

No comments: