function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Suraj GharatSuraj Gharat 

Excel cannnot open the file 'somefile.xlsx' because the file format or file extension is not valid..

Hi Everyone,

I want to develop MS Excel download feature for some of my data, thus I created a VF page with following attribute on the apex:page tag.
contentType="application/vnd.ms-excel#somefile.xls"
With this I get the file downloaded but when I try to open it, the Excel application (I use 2013 version) shows a warning message before showing the data.

"Excel cannnot open the file 'somefile.xlsx' because the file format or file extension is not valid. Verify that file has not been corrupted and that the file extension matches the format of the file."

I think issue is with its given MIME type or file extension since i can see data, its not corrupted. Could anybody help me make this download without that warning message ?
 
Brian Cherry FWIBrian Cherry FWI
Try adding cache="true"
Suraj GharatSuraj Gharat
Sadly cache="true" doesnt help. Thank you for your reply.