MVC通过NPOI.dll导出word文档
2016-02-01 14:51
204 查看
下载地址:http://download.csdn.net/detail/lilinoscar/9424645
1.首先项目添加并引用:NPOI.dll
2.控制器引用NPOI:
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
3.代码:
1.首先项目添加并引用:NPOI.dll
2.控制器引用NPOI:
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
3.代码:
public ActionResult ExportData() { HSSFWorkbook workbook = new HSSFWorkbook(); ISheet sheet = workbook.CreateSheet("sheet1"); IRow row = null; ICell cell = null; row = sheet.CreateRow(0); cell = row.CreateCell(0); cell.SetCellValue("数字"); for (int i = 0; i <= 12; i++) { row = sheet.CreateRow(i); cell = row.CreateCell(0); cell.SetCellValue(i); } string fileName ="20160101.xls"; MemoryStream ms = new MemoryStream(); workbook.Write(ms); return File(ms.ToArray(), "application/ms-excel", fileName); }
相关文章推荐
- 翻翻git之---溜的飞起的加载效果AVLoadingIndicatorView
- 翻翻git之---溜的飞起的加载效果AVLoadingIndicatorView
- Android读取Asset读取指定的Text文档
- codeforces 621E(dp, matrices)
- 制作winform安装程序
- 抓取crash
- 查看python的admin模板位置
- nginx笔记
- OpenCV 图像相似度匹配之感知哈希算法
- MySQL 触发器简单实例
- logstash日志分析的配置和使用
- 封装好的socket,拿去用
- Ubuntu下Redis的学习(一)
- 一道简单的题目引发的思考
- 消息队列技术终结者(一)—通俗深刻地认识JMS(即Java Message Service)
- win7 64位上Oracle11g数据库的安装,卸载,plsql的安装
- 使用HttpURLConnection发送HTTP请求
- 使用clippath时在有些系统版本上无效
- Spring使用Ehcache
- SpringMVC4.2+Jackson2.6/2.7