Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using MiniExcelLibs;
using MiniExcelLibs.OpenXml;
using System.Text;

namespace BootstrapBlazor.Components;
Expand Down Expand Up @@ -52,11 +53,18 @@ private async Task<bool> InternalExportAsync<TModel>(IEnumerable<TModel> items,
{
options ??= serviceProvider.GetRequiredService<IOptions<BootstrapBlazorOptions>>().Value.TableSettings.TableExportOptions;
cols ??= Utility.GetTableColumns<TModel>();

var configuration = new OpenXmlConfiguration()
{
AutoFilter = options.AutoFilter,
EnableAutoWidth = options.EnableAutoWidth,
};

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

using var stream = new MemoryStream();
await MiniExcel.SaveAsAsync(stream, value, excelType: excelType);
await MiniExcel.SaveAsAsync(stream, value, excelType: excelType,configuration: configuration);

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