Click here to Skip to main content
15,894,955 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Expert I created excel file using Open XML SDK 2.0 and open, it is successfully open.
but when user download this file and open, it cannot open. Error message comes file "Excel found unreadable content myExcel.xlsx do you want to open" when i clicked on yes show message ="the file is corrupt and cannot be opened."
please tell me how to make downloading functionality for this type of file

My downloading code:

C#
FileInfo _file = new FileInfo(file);
            if (_file.Exists)
            {
                Response.Clear();
                Response.ClearHeaders();
                Response.ClearContent();
                Response.AddHeader("content-disposition", "attachment; filename=" + _file.Name);
                Response.AddHeader("Content-Type", "application/Excel");
                Response.ContentType = "application/vnd.xlsx";
                Response.AddHeader("Content-Length", file.Length.ToString());
                Response.WriteFile(_file.FullName);
                Response.End();
}


thanx in advanced.....
Posted
Comments
Prasad Khandekar 29-May-13 10:16am    
Have you checked the size of downloaded file? Not related to your problem, though I would like you to read this article as well. (http://blogs.msdn.com/b/aspnetue/archive/2010/05/25/response-end-response-close-and-how-customer-feedback-helps-us-improve-msdn-documentation.aspx).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900