Skip to content

Commit 1e3d0cf

Browse files
committed
refactor: 重构逻辑
1 parent a31df7a commit 1e3d0cf

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/components/BootstrapBlazor.TableExport/Services/DefaultTableExport.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,21 @@ private async Task<bool> InternalExportAsync<TModel>(IEnumerable<TModel> items,
5454
options ??= serviceProvider.GetRequiredService<IOptions<BootstrapBlazorOptions>>().Value.TableSettings.TableExportOptions;
5555
cols ??= Utility.GetTableColumns<TModel>();
5656

57-
var configuration = new OpenXmlConfiguration()
57+
IConfiguration? configuration = null;
58+
if (excelType == ExcelType.XLSX)
5859
{
59-
AutoFilter = options.AutoFilter,
60-
EnableAutoWidth = options.EnableAutoWidth,
61-
};
60+
configuration = new OpenXmlConfiguration()
61+
{
62+
AutoFilter = options.EnableAutoFilter,
63+
EnableAutoWidth = options.EnableAutoWidth,
64+
};
65+
}
6266

6367
var lookupService = serviceProvider.GetRequiredService<ILookupService>();
6468
var value = new ExportDataReader<TModel>(items, cols, options, lookupService);
6569

6670
using var stream = new MemoryStream();
67-
await MiniExcel.SaveAsAsync(stream, value, excelType: excelType,configuration: configuration);
71+
await MiniExcel.SaveAsAsync(stream, value, excelType: excelType, configuration: configuration);
6872

6973
fileName ??= $"ExportData_{DateTime.Now:yyyyMMddHHmmss}.{GetExtension()}";
7074
stream.Position = 0;

0 commit comments

Comments
 (0)