Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to export data to excel both in .xls and .xlsx format in asp.net MVC without using any third party control.

I tried following code but it doesn't support .xlsx format. Means file is generated successfully but it(.xlsx) can't opened in office 2007.

Response.AddHeader("Content-Disposition", "attachment;  
filename=test.xlsx"); 
Response.ContentType = "application/ms-excel"; 
Response.Write(sw.ToString()); 
Response.End(); 


Pls give me solution.
Posted
Updated 30-Sep-10 19:56pm
v2
Comments
Hiren solanki 1-Oct-10 1:56am    
'pre' tag addition.

1 solution

 
Share this answer
 

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