fix 优化导出处理
This commit is contained in:
@@ -5,12 +5,12 @@ namespace Dlhis.ExcelHelper;
|
||||
|
||||
public static class ExcelExtensions
|
||||
{
|
||||
public static async Task<byte[]> ToExcelBytesAsync<T>(this List<T> data) where T : IExcelExportable
|
||||
public static async Task<byte[]> ToExcelBytesAsync<T>(this List<T> data)
|
||||
{
|
||||
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
|
||||
var type = typeof(T);
|
||||
var sheetName = type.GetCustomAttribute<ExcelAttribute>()!.Description;
|
||||
var sheetName = type.GetCustomAttribute<ExcelAttribute>()?.Description ?? type.Name;
|
||||
var excelHeaderNames = type.GetProperties().Where(x => x.IsDefined(typeof(ExcelAttribute))).ToList();
|
||||
|
||||
using var package = new ExcelPackage();
|
||||
|
||||
Reference in New Issue
Block a user