如何在ASP.NET MVC应用程序中导出为CSV? [英] How can I export to CSV in an ASP.NET MVC application?

查看:127
本文介绍了如何在ASP.NET MVC应用程序中导出为CSV?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题已经以多种方式提出和回答,但是没有一个问题成为我需要理解的问题的症结所在.在WebForms中,我们颠覆"呈现过程并直接写入Response的输出流.如何使用Controller Action将CSV写入Excel文件?

I know this question has been asked and answered in several ways, but none of them get to the crux of the matter that I need to understand. In WebForms, we 'subvert' the rendering process and write straight to the Response's output stream. How does one achieve that using a Controller Action, to write CSV to a file for Excel?

推荐答案

使用相同的方式编写其他文件-使用FileResult及其后代.

Same way you'd write any other file -- use FileResult and it's descendants.

这篇关于如何在ASP.NET MVC应用程序中导出为CSV?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆