强大的导出EXCEL,比NPOI更好用,更强大,可惜只有4.0版本的。

  记录一下DEMO

                var sheet = p.Workbook.Worksheets.Add("My Sheet");

                //Cells的起始索引是1
sheet.Cells[, ].Value = 1234.123;
sheet.Cells[, ].Value = ;
sheet.Cells[, ].Value = ;
sheet.Cells[, ].Value = ; sheet.Cells[, ].Style.Numberformat.Format = "#,##0.00";//这是保留两位小数 var sheet2 = p.Workbook.Worksheets.Add("My Sheet2");
sheet2.Cells[, ].Value = "jie";
sheet2.Cells[, ].Value = "xiaom";
sheet2.Cells[, ].Value = "ccx";
sheet2.Cells[, ].Value = "zhangs"; sheet2.Cells[, ].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;//水平居中
sheet2.Cells[, ].Style.Font.Bold = true;//字体为粗体
sheet2.Cells[, ].Style.Font.Size = ;//字体大小 p.SaveAs(new FileInfo(@"F:\Temp\output.xlsx"));

-------------------------------------------------

        public ActionResult ExportExcel()
{
// 写入到客户端
System.IO.MemoryStream ms = new System.IO.MemoryStream(); using (var p = new ExcelPackage(ms))
{
var sheet = p.Workbook.Worksheets.Add("My Sheet"); //Cells的起始索引是1
sheet.Cells[, ].Value = 1234.123;
sheet.Cells[, ].Value = ;
sheet.Cells[, ].Value = ;
sheet.Cells[, ].Value = ; sheet.Cells[, ].Style.Numberformat.Format = "#,##0.00";//这是保留两位小数 var sheet2 = p.Workbook.Worksheets.Add("My Sheet2");
sheet2.Cells[, ].Value = "jie";
sheet2.Cells[, ].Value = "xiaom";
sheet2.Cells[, ].Value = "ccx";
sheet2.Cells[, ].Value = "zhangs"; sheet2.Cells[, ].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;//水平居中
sheet2.Cells[, ].Style.Font.Bold = true;//字体为粗体
sheet2.Cells[, ].Style.Font.Size = ;//字体大小 //写到客户端(下载)
HttpContext.Response.Clear();
HttpContext.Response.AddHeader("content-disposition", "attachment; filename=FileFlow.xlsx");
HttpContext.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
HttpContext.Response.BinaryWrite(p.GetAsByteArray());
//ep.SaveAs(Response.OutputStream); 第二种方式
HttpContext.Response.Flush();
HttpContext.Response.End(); } return null;
}

.NET/C#- EPPLUS DEMO的更多相关文章

  1. .net mvc中epplus导出excel

    帮助类 using OfficeOpenXml; using OfficeOpenXml.Style; using System; using System.Collections.Generic; ...

  2. 在.NET中使用EPPlus生成Excel报表 .

    --摘抄自:http://blog.csdn.net/zhoufoxcn/article/details/14112473 在开发.NET应用中可能会遇到需要生成带图表(Chart)的Excel报表的 ...

  3. 在ASP.NET Core中使用EPPlus导入出Excel文件

    这篇文章说明了如何使用EPPlus在ASP.NET Core中导入和导出.xls/.xlsx文件(Excel).在考虑使用.NET处理excel时,我们总是寻找第三方库或组件.使用Open Offic ...

  4. .Net Excel 导出图表Demo(柱状图,多标签页)

    1 使用插件名称Epplus,多个Sheet页数据应用,Demo为柱状图(Epplus支持多种图表) 2 Epplus 的安装和引用 新建一个工程文件或控制台应用程序 打开 Vs2017 Tools  ...

  5. .Net Excel 导出图表Demo(柱状图,多标签页) .net工具类 分享一个简单的随机分红包的实现方式

    .Net Excel 导出图表Demo(柱状图,多标签页) 1 使用插件名称Epplus,多个Sheet页数据应用,Demo为柱状图(Epplus支持多种图表) 2 Epplus 的安装和引用 新建一 ...

  6. C# 操作Excel,使用EPPlus

    EPPlus下载地址:http://www.codeplex.com/EPPlus 引用命名空间: using OfficeOpenXml; using OfficeOpenXml.Table; us ...

  7. .NET CORE webapi epplus 导入导出 (实习第一个月的笔记)

    最近有个需求就是网页表格里面的数据导出到excel  于是从各位前辈的博客园搜了搜demo  大部分非为两类 都是用的插件NPOI和Eppluse ,因此在这里就介绍Eppluse 用法,还有就是在博 ...

  8. EPPlus生成Excel表格(只支持2007及以上)

    主要来源: https://www.cnblogs.com/rumeng/p/3785748.html http://epplus.codeplex.com/ FileInfo newFile = n ...

  9. 基于EPPlus和NPOI实现的Excel导入导出

    基于EPPlus和NPOI实现的Excel导入导出 CollapseNav.Net.Tool.Excel(NuGet地址) 太长不看 导入 excel 文件流将会转为 ExcelTestDto 类型的 ...

随机推荐

  1. php的类型约束

    //如下面的类 class MyClass { /** * 测试函数 * 第一个参数必须为 OtherClass 类的一个对象 */ public function test(OtherClass $ ...

  2. loadrunner ---<三>循环输出关联数组

    web_reg_save_param,将Ord参数值设定为ALL,则关联函数将自动把符合条件的关联值保存到参数数组里.在本例中,假设关联值返回三条记录,则LR分别将值保存到sor_1,sor_2,so ...

  3. 部署K2 Blackpearl流程时出错(与基础事务管理器的通信失败或Communication with the underlying transaction manager has failed.

    转:http://www.cnblogs.com/dannyli/archive/2011/12/01/2270222.html 亲,在部署K2流程是,是否遇到这个错误(以下是中.英文错误信息) 中文 ...

  4. 【转】谈一谈PHP字串清除空格函数不安全

    清除空格的方法是不安全的,部分原因是因为字符中的空格非常多,例如 "addslashes的问题在 于黑客 可以用0xbf27来代替单引号,而addslashes只是将0xbf27修改为0xb ...

  5. 说说shell脚本中的export 和 source,bash

    小弟刚刚接触linux,对linux上的很多东西都比较陌生,所以写一写博客,当做自己工作的总结和技术的积累吧,也是鞭策自己不断努力的去学习. 今天之所以起这个标题,把export,source ,ba ...

  6. 处理 JSON null 和空数组及对象

    描述了对 JSON 数据中使用的 null 和空数组及对象的处理. JSON 数据具有 null 和空数组及对象的概念.此部分说明其中每个概念如何映射到 null 和未设置的数据对象概念. Null ...

  7. 【转】linux下cpio命令使用

    转自:http://www.51testing.com/html/32/498132-816949.html 功能说明:备份文件. 补充说明:cpio是用来建立,还原备份档的工具程序,它可以加入,解开 ...

  8. 北邮网关登录python脚本

    闲来无聊,来码一发 安装 pip install byrlogin 登录 登出

  9. JS操作文件

    ) ;   ;   fso );   f1.Close();   // 读取文件的内容.  // Response.Write("Reading file <br>") ...

  10. html --- canvas --- javascript --- 拖拽圆圈

    代码如下: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <tit ...