Open a xlsx file with Coldfusion 10

New Here ,
May 19, 2017 May 19, 2017

Copy link to clipboard

Copied

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>

Views

2.7K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 20, 2017 May 20, 2017

Copy link to clipboard

Copied

Some suggestions:

1) Use application/vnd.ms-excel instead of application/msexcel for XLS.

2) <cfheader name="Cache-Control" value="private"> and reset="Yes" seem to have no use. Remove them.

3) The error message suggests that the content is not of type XLSX. Test with the file attribute instead, that is,

<cfcontent type="application/vnd.ms-excel" file="#request.getXlsFile.Uploaded_XLS_File#"> 
<cfcontent type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" file="#request.getXlsFile.Uploaded_XLS_File#"> 

<cfcontent type="application/vnd.ms-excel.sheet.macroEnabled.12" file="#request.getXlsFile.Uploaded_XLS_File#"> 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 22, 2017 May 22, 2017

Copy link to clipboard

Copied

Hello,

First of all, I would like to thanks for your support.

Next, I tried your suggestion. Effectively, the document open. But I'm afraid that if the document have functions or configuration relative to Excel 2010, I will have problem !

What do you think?

Thanks

Best regards

André

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 22, 2017 May 22, 2017

Copy link to clipboard

Copied

andrél93139241  wrote

Next, I tried your suggestion. Effectively, the document open.

Is that the answer your original question? If so, then please mark the question as correctly answered before you move on to further questions. When you do so, you help others who have similar questions.

But I'm afraid that if the document have functions or configuration relative to Excel 2010, I will have problem !

What do you think?

I expect no problems with Excel 2010 files. If you find any, bring it here and we shall look into it together, of course.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 22, 2017 May 22, 2017

Copy link to clipboard

Copied

LATEST

Hello,

Ok, Thank you for your answer.

Best regards

André

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines