I'm working on getting an html table to export to excel using coldfusion. I've got the table to export successfully but I have run into 2 problems.
First, the submit button I use to initiate the export is being sent to the excel file with the table data. Is there a way to prevent the export button that's being posted from showing up in my excel spreadsheet?
Secondly, when opening the excel file I get an error message stating "The file format and extension of '.xls' don't match..."
If anyone knows a solution to either problems please share.
Thanks
<cfsetting enablecfoutputonly="Yes">
<!---Navigation Logic--->
<cfif isdefined("form.nav")>
<cfswitch expression="#Form.nav#">
<cfcase value="export">
<cfcontent type="application/vnd.ms-excel">
<cfheader name="Content-Disposition" value="attachment; filename=Radio.xls">
</cfcase>
</cfswitch>
</cfif>
<cfoutput>
<table name ="radTable" id="radTable" class="radTable">
<tr><th>Sort</th><th>Date</th><th>Name</th><th>Volume Knob</th>
<th>Channel Knob</th><th>Antenna</th><th>Microphone</th>
<th>Microphone Clip</th><th>Battery</th><th>Battery Clip</th>
</tr>
<cfloop query="sqlRadio" startrow="#rowStart#" endRow="#rowEnd#">
<tr>
<td>#Sort#</td><td>#DateFormat(Date, "mm/dd/yyyy")#</td><td>#eName#</td>
<td>#vKnob#</td><td>#cKnob#</td><td>#Antenna#</td><td>#Microphone#</td>
<td>#mClip#</td><td>#Battery#</td><td>#bClip#</td>
</tr>
<tr><td colspan="10" style="text-align:left">Comments: #Comments#</td></tr>
</cfloop>
</table>
<form name="pageNav" action="results.cfm" method="post">
<input type="hidden" name="rowStart" value="#rowStart#">
<input type="hidden" name="rowEnd" value="#rowEnd#">
<input type="hidden" name="selRad" value="#radName#">
<input type="submit" name="nav" form="pageNav" value="<<">
<input type="submit" name="nav" form="pageNav" value="<">
<input type="submit" name="nav" form="pageNav" value=">">
<input type="submit" name="nav" form="pageNav" value=">>">
<input type="submit" name="nav" form="pageNav" value="export">
</form>
</cfoutput>