I am trying to send an xlsx file using
Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName); Response.AddHeader("Content-Length", file.Length.ToString()); Response.ContentType = "application/vnd-ms.excel"; Response.TransmitFile(file.FullName); Response.End();
An IE dialog box will appear and I can successfully save the file and then open it from a folder that works fine and dandy. But if I click "Open" in the IE dialog box, I get "myFile.xlsx could not be loaded." I press "Retry" and open Excel, but pops up "Excel cannot open the file" myFile.xlsx "because the file format or file extension is invalid ...". I am currently starting a site from VS2010 in debug mode.
Does anyone know why this will allow me to save, but not open directly?
Edit
Chrome just downloads it. FF tried to open it, but gave the error The file you are trying to open, 'myFile.xlsx.xls', is in a different format than specified by the file extension... I can choose to open it anyway, and It opens successfully, but in readonly mode.
So, something scared is happening here. fileName = "myFile.xlsx"
Edit 2
This is in IE 9. I also tried octet-stream and application/vnd.openxmlformats-officedocument.spreadsheetml.sheet as ContentType.
Marcus
source share