Skip to content

Commit a31df7a

Browse files
committed
feat(DefaultTableExport): 添加是否启用 Excel 自动筛选,是否启用 Excel 自动宽度参数 #5845
1 parent 28a4404 commit a31df7a

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Microsoft.Extensions.Logging;
99
using Microsoft.Extensions.Options;
1010
using MiniExcelLibs;
11+
using MiniExcelLibs.OpenXml;
1112
using System.Text;
1213

1314
namespace BootstrapBlazor.Components;
@@ -52,11 +53,18 @@ private async Task<bool> InternalExportAsync<TModel>(IEnumerable<TModel> items,
5253
{
5354
options ??= serviceProvider.GetRequiredService<IOptions<BootstrapBlazorOptions>>().Value.TableSettings.TableExportOptions;
5455
cols ??= Utility.GetTableColumns<TModel>();
56+
57+
var configuration = new OpenXmlConfiguration()
58+
{
59+
AutoFilter = options.AutoFilter,
60+
EnableAutoWidth = options.EnableAutoWidth,
61+
};
62+
5563
var lookupService = serviceProvider.GetRequiredService<ILookupService>();
5664
var value = new ExportDataReader<TModel>(items, cols, options, lookupService);
5765

5866
using var stream = new MemoryStream();
59-
await MiniExcel.SaveAsAsync(stream, value, excelType: excelType);
67+
await MiniExcel.SaveAsAsync(stream, value, excelType: excelType,configuration: configuration);
6068

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

0 commit comments

Comments
 (0)