From 4e0b457bbe0cc3fc1d77db4189e680fe5880c89a Mon Sep 17 00:00:00 2001 From: dev01 Date: Mon, 15 May 2023 17:10:17 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BE=8C=E5=8F=B0][=E5=BE=8C=E7=AB=AF]=20?= =?UTF-8?q?=E6=B0=B4=E9=9B=BB=E5=A0=B1=E8=A1=A8=20Export=20=E5=8C=AF?= =?UTF-8?q?=E5=87=BA=E5=A0=B1=E8=A1=A8=20api=20=E9=83=A8=E5=88=86=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FrontendWebApi/ApiControllers/HydroMeterController.cs | 7 +++++-- FrontendWebApi/Startup.cs | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/FrontendWebApi/ApiControllers/HydroMeterController.cs b/FrontendWebApi/ApiControllers/HydroMeterController.cs index 281bfd0..293ae3b 100644 --- a/FrontendWebApi/ApiControllers/HydroMeterController.cs +++ b/FrontendWebApi/ApiControllers/HydroMeterController.cs @@ -452,14 +452,15 @@ namespace FrontendWebApi.ApiControllers workbook.Write(ms); ms.Flush(); ms.Seek(0, SeekOrigin.Begin); - + Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition"); return File(ms, "application/vnd.ms-excel", "電表報表.xlsx"); } - [HttpGet] + [HttpPost] [Route("api/ExportWaterList")] public FileResult OpeExportExcelWater([FromBody] HydroMeterInput input) { + var result = this.WaterList(input).Result.Value.Data.ToList(); var workbook = new XSSFWorkbook(); @@ -602,6 +603,8 @@ namespace FrontendWebApi.ApiControllers ms.Flush(); ms.Seek(0, SeekOrigin.Begin); + Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition"); + return File(ms, "application/vnd.ms-excel", "水表報表.xlsx"); } } diff --git a/FrontendWebApi/Startup.cs b/FrontendWebApi/Startup.cs index 956d4d8..1d8079f 100644 --- a/FrontendWebApi/Startup.cs +++ b/FrontendWebApi/Startup.cs @@ -68,7 +68,8 @@ namespace FrontendWebApi { policy.AllowAnyOrigin() .AllowAnyHeader() - .AllowAnyMethod(); + .AllowAnyMethod() + .WithExposedHeaders("Content-Disposition"); }); }); services.AddLogging(