Open a xlsx file with Coldfusion 10
Good morning everybody,
I have a page containing a list of files (Excel in different format such as xls, xlsx and xlsm).
To open it, I use different content type: (see code below)
For the extension xls and xlsm, it work fine.
for xlsx, I receive the following error:
"Excel cannot open the file 'xxx.xlsx' because the file format or file extension is not valid."
I already search on internet https://forums.adobe.com/message/8911025#8911025 and tried without effect.
I can open if I use the "cfcontent type='application/msexcel' " but I loose everything about Excel 2010.
There is anyone which can help me?
Thank you in advance for your support
Best regards
André
the code:
<cfset FileName = Replace(request.getXlsFile.Uploaded_File_Name, ' ', '_',"All") >
<cfset extension = request.getXlsFile.template_ext >
<cfoutput>
<cfheader name="Cache-Control" value="private">
<cfheader name="Content-Disposition" value="attachment; filename=#FileName#" >
<cfswitch expression="#extension#" >
<!--- Excel format --->
<cfcase value="xls">
<cfcontent type="application/msexcel" reset="Yes" variable="#request.getXlsFile.Uploaded_XLS_File#">
</cfcase>
<cfcase value="xlsx" >
<cfcontent type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" reset="Yes" variable="#request.getXlsFile.Uploaded_XLS_File#">
</cfcase>
<cfcase value="xlsm" >
<cfcontent type="application/vnd.ms-excel.sheet.macroEnabled.12" reset="Yes" variable="#request.getXlsFile.Uploaded_XLS_File#">
</cfcase>
<cfdefaultcase>
<cfcontent type="application/msexcel" reset="Yes" variable="#request.getXlsFile.Uploaded_XLS_File#">
</cfdefaultcase>
</cfswitch>
</cfoutput>
<cfabort>
