如何在不使用第三方控件的情况下使用mvc将数据导出到excel [英] How to export data to excel using mvc without using third party control
本文介绍了如何在不使用第三方控件的情况下使用mvc将数据导出到excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在不使用任何第三方控件的情况下以asp.net MVC格式将数据以.xls和.xlsx格式导出为excel.
我尝试了以下代码,但它不支持.xlsx格式.意味着文件已成功生成,但无法在Office 2007中打开它(.xlsx).
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.
推荐答案
引用链接:
http://stackoverflow.com/questions/301986/export-to-excel- in-asp-net-mvc
refer links:
http://stackoverflow.com/questions/301986/export-to-excel-in-asp-net-mvc
这篇关于如何在不使用第三方控件的情况下使用mvc将数据导出到excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文