1.用nuget命令行安装NPOI引用:
Install-Package NPOI -Version 2.4.0;
2.方法:
public void ToExcelFile(string filename, DataTable dt, KeyValuePair<string, string>[] column_names)
{
try
{
// 根据模板文件创建副本
//string filePath = Server.MapPath(this.TemporaryFolder + Path.DirectorySeparatorChar + Guid.NewGuid().ToString() + “.xls”);
MemoryStream ms = new MemoryStream();
var book = new HSSFWorkbook();
var sheet = book.CreateSheet(Path.GetFileNameWithoutExtension(filename));
继续阅读









