导出到Excel在Asp.net MVC [英] Export to Excel in Asp.net MVC
问题描述
我工作的一个ASP.NET MVC应用程序,我需要将数据导出到Excel US preadsheet。 previously,在web表单应用程序,我使用了一些code,我发现渲染的GridView为Excel兼容的文件。这是很方便。我想知道最快/最有效的方法是做到这一点的MVC。谢谢你。
I am working on an ASP.NET MVC application where I need to export data to an excel spreadsheet. Previously, in webforms apps, I used some code I found to render a GridView as an excel-compatible file. This was quite handy. I was wondering what the quickest/most effective method would be to do this in MVC. Thanks.
推荐答案
一个简单的选择是创建一个视图来呈现一个Excel文件的XML版本。你既可以使用新的Office 2007版本或更早的2003版本。我们选择了2003版让更多的人可以使用它,但这是你的,当然。
One simple option would be to create a view to render an XML-version of an Excel File. You could either use the new Office 2007 version, or the older 2003 version. We chose the 2003 version so that more people could use it, but that's up to you, of course.
MSDN上 XML 2003 REF
XML 2003 ref on MSDN
MSDN上 XML 2007 REF
XML 2007 ref on MSDN
这篇关于导出到Excel在Asp.net MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!