ColdFusion export to Excel using CFCONTENT doesn't work anymore

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?

3

1 Answer

Use This :

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like