feat: 完成excel导出操作

This commit is contained in:
橙子
2024-01-02 23:26:05 +08:00
parent 0aac42e19b
commit e3108f7382
6 changed files with 66 additions and 23 deletions

View File

@@ -3,6 +3,8 @@ using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Json;
using Yi.Framework.Core.Extensions;
using static System.Net.WebRequestMethods;
namespace Yi.Framework.AspNetCore.Microsoft.AspNetCore.Middlewares
{
@@ -10,7 +12,20 @@ namespace Yi.Framework.AspNetCore.Microsoft.AspNetCore.Middlewares
{
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{
context.Response.OnStarting(() =>
{
if (context.Response.StatusCode == StatusCodes.Status200OK
&& context.Response.Headers["Content-Type"].ToString() == "application/vnd.ms-excel")
{
context.FileAttachmentHandle($"{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.xlsx");
}
return Task.CompletedTask;
});
await next(context);
}
}
}