feat: 完成excel导出操作
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user