如何在Mvc 4中将Excel文件中的数据导出到Web Api [英] How Do I Export Data In Excel File To The Web Api In Mvc 4

查看:92
本文介绍了如何在Mvc 4中将Excel文件中的数据导出到Web Api的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将excel文件中的数据导出到mvc 4中的web api ???

解决方案

按照以下方式输入代码

返回新的FileContentResult(fileContents,application / vnd.ms-excel){FileDownloadName =name.xls}; 
//请注意,此调用将返回FileContentResult对象
返回新文件(fileContents,application / vnd.ms-excel,name.xls);


how do i export data in excel file to the web api in mvc 4???

解决方案

put your code following way

return new FileContentResult(fileContents, "application/vnd.ms-excel") { FileDownloadName = "name.xls" };
// note that this call will return a FileContentResult object
return new File(fileContents, "application/vnd.ms-excel", "name.xls");


这篇关于如何在Mvc 4中将Excel文件中的数据导出到Web Api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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