NpoiHelper

时间:2023-01-06 04:44:21
【文件属性】:

文件名称:NpoiHelper

文件大小:18KB

文件格式:CS

更新时间:2023-01-06 04:44:21

npoi对excel操作导入,导

提供npoi对excel的操作代码,包括对excel的写入读取,将DataTable数据导入到excel中 调用测试: //将获取到的供货商IList集合转换为DataTable类型 DataTable dt = NpoiHelper.ToDataTable(list); MemoryStream ms = new MemoryStream(); //将数据导出到Excel中 if (dt.Rows.Count > 0) { Dictionary dictionary = new Dictionary() { ["SupplierName"] = "供货商名称", ["LinkName"] = "联系人", ["Mobile"] = "手机号", ["FullName"] = "所在区域", }; ms = NpoiHelper.Export(dt, dictionary, ExcelVersions.LowExcel, "供货商"); return File(ms, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "供货商.xls"); } else { return File(ms, "application/Response.write", "该文件无信息"); }


网友评论