asp.net下简单的Epplus导出excel

引用的命名空间

using System.IO;

using OfficeOpenXml;

 

 

/// <summary>
/// 导出excel
/// </summary>
/// <param name="context"></param>
/// <param name="fileName"></param>
public void exportExcel(HttpContext context,string fileName)
{
ExcelPackage ep = new ExcelPackage();
ExcelWorkbook wb = ep.Workbook;
ExcelWorksheet ws = wb.Worksheets.Add("helloworld");
ws.Cells["A1"].Value = "hello world";
FileInfo file = new FileInfo(fileName);
ep.SaveAs(file);
}

 

 

使用exportExcel函数

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string path= Server.MapPath("~/excel");
exportExcel(Context, path + "\\test.xlsx");

}
}

EPPlus详细使用情况可参考:http://epplus.codeplex.com/SourceControl/latest

asp.net下简单的Epplus导出excel,布布扣,bubuko.com

asp.net下简单的Epplus导出excel

上一篇:Web服务器控件的中英文名称对应


下一篇:Jquery揭秘系列:Validation实现