ColdFusion export to Excel using CFCONTENT doesn't work anymore

时间:2017-10-12 10:09:37

标签: excel coldfusion

I've been using all my life <cfheader> and <cfcontent> tags in ColdFusion in order to export a HTML table in Excel format (.xls). So far, it worked just perfect, all exported files were good and opened without problems in Excel or OpenOfifce Calc.

Today I discovered that this doesn't work anymore: even if the code was not changed for years, the export result (file.xls) is no longer recognized as a valid Excel file. When I try to open the file using MS Excel I am getting this error message:

Can't open file. This file is unsupported by this version of Office.

OpenOffice Calc doesn't even start.

My code for exporting the Excel file from ColdFusion is as simple as this:

<cfheader name="Content-Disposition" value="attachment; filename=test.xls">
<cfcontent type="application/vnd.ms-excel">#Trim(VARIABLES.html_content)#

If I open the exported file, it contains the HTML code of a simple table. Does anyone else experienced this problem recently?

1 个答案:

答案 0 :(得分:1)

使用此:

<cfheader name="Content-Disposition" value="inline; filename=test.xls">
<cfcontent type="application/msexcel">
#Trim(VARIABLES.html_content)#