工单导入模板下载

This commit is contained in:
quowingwang
2025-12-18 15:01:20 +08:00
parent 45bfff43e1
commit 82e4d55664
2 changed files with 19 additions and 1 deletions

View File

@@ -68,7 +68,25 @@ namespace ZR.Admin.WebApi.Controllers
// return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileName);
}
protected IActionResult ExportExcel2(string path, string fileName)
{
if (!Path.Exists(path))
{
throw new CustomException(fileName + "文件不存在");
}
var stream = Io.File.OpenRead(path);
// 设置响应头
Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition");
// 对文件名进行编码使用RFC 5987标准
var encodedFileName = Uri.EscapeDataString(fileName);
Response.Headers.Add("Content-Disposition",
$"attachment; filename*=UTF-8''{encodedFileName}");
return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
}
#region
/// <summary>

View File

@@ -59,7 +59,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.pro
public IActionResult ImportTemplateExcel()
{
(string, string) result = DownloadImportTemplate("日生产计划模板");//返回文件名和路径
return ExportExcel(result.Item2, result.Item1);
return ExportExcel2(result.Item2, result.Item1);
}