Excel导出新增多sheet方法
This commit is contained in:
parent
3f9ae2213e
commit
7bfd1c76b0
@ -145,6 +145,24 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
return (sFileName, fullPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出多个工作表(Sheet)
|
||||
/// </summary>
|
||||
/// <param name="sheets"></param>
|
||||
/// <param name="fileName"></param>
|
||||
/// <returns></returns>
|
||||
protected (string, string) ExportExcelMini(Dictionary<string, object> sheets, string fileName)
|
||||
{
|
||||
IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment));
|
||||
string sFileName = $"{fileName}{DateTime.Now:MM-dd-HHmmss}.xlsx";
|
||||
string fullPath = Path.Combine(webHostEnvironment.WebRootPath, "export", sFileName);
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
|
||||
|
||||
MiniExcel.SaveAs(fullPath, sheets);
|
||||
return (sFileName, fullPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载导入模板
|
||||
/// </summary>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user