Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Table): support export as Pdf #2550

Merged
merged 35 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a8e9ba3
doc: 更新示例文档
ArgoZhang Dec 10, 2023
f758b3d
feat: 增加 Pdf 导出方法
ArgoZhang Dec 10, 2023
e8ecc7a
chore: 增加 Csv 相关资源文件
ArgoZhang Dec 11, 2023
d0d569f
refactor: 完善 IHtml2Pdf 接口服务
ArgoZhang Dec 11, 2023
53138e5
refactor: 重构 TableExport 导出服务
ArgoZhang Dec 11, 2023
fd6702c
feat: 合并导出服务
ArgoZhang Dec 11, 2023
701ade9
feat: 增加 IHtml2Pdf 服务
ArgoZhang Dec 11, 2023
72beb00
feat: 增加 Csv 图标参数
ArgoZhang Dec 11, 2023
e7c7225
feat: 增加 ExportCsvDropdownItemText 参数
ArgoZhang Dec 11, 2023
bc345bc
feat: 内置导出 Csv 按钮参数
ArgoZhang Dec 11, 2023
67b0f8e
feat: 移除 Pdf/Excel 服务统一使用 TableExport 服务
ArgoZhang Dec 11, 2023
9ff6a24
refator: 调整注入服务
ArgoZhang Dec 11, 2023
3722944
refactor: 更改图标参数名称
ArgoZhang Dec 11, 2023
701ef78
refactor: 增加图标宽度
ArgoZhang Dec 11, 2023
075abf8
refactor: 精简代码
ArgoZhang Dec 11, 2023
f6f632f
doc: 更新导出按钮示例
ArgoZhang Dec 11, 2023
f7f913a
doc: 重构 Html2Pdf 示例
ArgoZhang Dec 11, 2023
67a9480
feat: 增加 ITableExportPdf 服务
ArgoZhang Dec 11, 2023
925b55b
feat: 增加 PdfSteamAsync 方法
ArgoZhang Dec 11, 2023
7b47923
doc: 重构代码
ArgoZhang Dec 11, 2023
c9b77b8
feat: 实现项目 Pdf 导出服务
ArgoZhang Dec 11, 2023
ffd00c1
refactor: 增加 PdfStreamAsync 方法
ArgoZhang Dec 11, 2023
e347a09
feat: 增加 ExportPdfAsync 方法
ArgoZhang Dec 11, 2023
217ad4a
chore: 更新图标
ArgoZhang Dec 11, 2023
4b600f7
test: 更新单元测试
ArgoZhang Dec 11, 2023
fa58df2
chore: 更新字典
ArgoZhang Dec 11, 2023
b832aa9
chore: bump version 8.0.6-beta01
ArgoZhang Dec 11, 2023
01d398c
chore: bump version 8.0.2-beta01
ArgoZhang Dec 11, 2023
1b6bcfc
chore: bump version 8.0.1-beta01
ArgoZhang Dec 11, 2023
79289f1
chore: bump version 8.0.2-beta01
ArgoZhang Dec 11, 2023
a42923b
chore: 更新依赖组件包到最新
ArgoZhang Dec 11, 2023
c63f3fd
refactor: 重构代码消除警告信息
ArgoZhang Dec 11, 2023
2cc2cdf
test: 更新单元测试
ArgoZhang Dec 11, 2023
3bba7b0
refactor: 精简代码
ArgoZhang Dec 11, 2023
2bcf705
test: 更新单元测试
ArgoZhang Dec 11, 2023
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
1 change: 1 addition & 0 deletions exclusion.dic
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ Splittings
Foos
Localizer
onchange
Render
1 change: 1 addition & 0 deletions localization/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
"ExportToastTitle": "Daten exportieren",
"ExportToastContent": "Daten exportieren {0}, automatisches Schließen in {1} Sekunden",
"ExportToastInProgressContent": "Daten exportieren, automatisches Schließen in {0} Sekunden",
"ExportCsvDropdownItemText": "MS-Csv",
"ExportExcelDropdownItemText": "MS-Excel",
"ExportPdfDropdownItemText": "Pdf",
"PageInfoText": "{0} - {1} Total {2}",
Expand Down
1 change: 1 addition & 0 deletions localization/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
"ExportToastTitle": "Exportar datos",
"ExportToastContent": "Exportar datos {0}, cierre automático en {0} segundos",
"ExportToastInProgressContent": "Exportar datos, cierre automático en {0} segundos",
"ExportCsvDropdownItemText": "MS-Csv",
"ExportExcelDropdownItemText": "MS-Excel",
"ExportPdfDropdownItemText": "Pdf",
"PageInfoText": "{0} - {1} Total {2}",
Expand Down
1 change: 1 addition & 0 deletions localization/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
"ExportToastTitle": "Exportar dados",
"ExportToastContent": "Exportar dados {0}, Fechamento automático em {0} segundos",
"ExportToastInProgressContent": "Exportar dados, Fechamento automático em {0} segundos",
"ExportCsvDropdownItemText": "MS-Csv",
"ExportExcelDropdownItemText": "MS-Excel",
"ExportPdfDropdownItemText": "Pdf",
"PageInfoText": "{0} - {1} Total {2}",
Expand Down
3 changes: 2 additions & 1 deletion localization/th-TH.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"BootstrapBlazor.Components.AutoComplete": {
"NoDataTip": "ไม่มีข้อมูลที่ตรงกัน",
"PlaceHolder": "กรุณากรอก"
Expand Down Expand Up @@ -225,6 +225,7 @@
"ExportToastTitle": "ส่งออกข้อมูล",
"ExportToastContent": "ส่งออกข้อมูล {0},{1} ปิดอัตโนมัติหลังจากวินาที",
"ExportToastInProgressContent": "กำลังส่งออกข้อมูล โปรดทราบภายหลัง, {0} ปิดอัตโนมัติหลังจากวินาที",
"ExportCsvDropdownItemText": "ไมโครซอฟท์ Csv รูปแบบ",
"ExportExcelDropdownItemText": "ไมโครซอฟท์ Excel รูปแบบ",
"ExportPdfDropdownItemText": "Pdf รูปแบบ",
"PageInfoText": "{0} - {1} ทั้งหมด {2} บทความ",
Expand Down
1 change: 1 addition & 0 deletions localization/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"ExportToastTitle": "匯出資料",
"ExportToastContent": "匯出資料 {0},{1} 秒後自動關閉",
"ExportToastInProgressContent": "正在匯出資料,請稍後, {0} 秒後自動關閉",
"ExportCsvDropdownItemText": "微軟 Csv 格式",
"ExportExcelDropdownItemText": "微軟 Excel 格式",
"ExportPdfDropdownItemText": "Pdf 格式"
},
Expand Down
6 changes: 3 additions & 3 deletions src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
<PackageReference Include="BootstrapBlazor.FileViewer" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.FontAwesome" Version="8.0.1" />
<PackageReference Include="BootstrapBlazor.Gantt" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.Html2Pdf" Version="8.0.1" />
<PackageReference Include="BootstrapBlazor.Html2Pdf" Version="8.0.2-beta01" />
<PackageReference Include="BootstrapBlazor.ImageCropper" Version="*" />
<PackageReference Include="BootstrapBlazor.Live2DDisplay" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.Markdown" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.MaterialDesign" Version="8.0.1" />
<PackageReference Include="BootstrapBlazor.MaterialDesign.Extensions" Version="8.0.1" />
<PackageReference Include="BootstrapBlazor.MaterialDesign.Extensions" Version="8.0.2-beta01" />
<PackageReference Include="BootstrapBlazor.Middleware" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.MindMap" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.MouseFollower" Version="8.0.0" />
Expand All @@ -56,7 +56,7 @@
<PackageReference Include="BootstrapBlazor.SignaturePad" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.Splitting" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.SummerNote" Version="8.0.1" />
<PackageReference Include="BootstrapBlazor.TableExport" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.TableExport" Version="8.0.1-beta01" />
<PackageReference Include="BootstrapBlazor.Topology" Version="8.0.1" />
<PackageReference Include="BootstrapBlazor.VideoPlayer" Version="8.0.1" />
<PackageReference Include="BootstrapBlazor.WebAPI" Version="8.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ public partial class Html2Pdfs
[NotNull]
private DownloadService? DownloadService { get; set; }

[Inject]
[NotNull]
private IComponentHtmlRenderer? HtmlRenderService { get; set; }

[Inject]
[NotNull]
private IWebHostEnvironment? WebHostEnvironment { get; set; }
Expand Down Expand Up @@ -63,7 +59,7 @@ private async Task OnExportAsync()

// 拼接导出文件网址
var url = $"{NavigationManager.BaseUri}{fileName}";
var data = await PdfService.ExportDataAsync(url);
var data = await PdfService.PdfDataAsync(url);
using var stream = new MemoryStream(data);
await DownloadService.DownloadFromStreamAsync("table.pdf", stream);
await ToastService.Success("Pdf Export", "Export pdf element success.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<PackageTips Name="BootstrapBlazor.TableExport" />

<p><b>@Localizer["TablesExportTips"]:</b></p>
<p class="mt-3"><b>@Localizer["TablesExportTips"]:</b></p>

<Pre>public void ConfigureServices(IServiceCollection services)
{
Expand Down Expand Up @@ -38,6 +38,24 @@
</Table>
</DemoBlock>

<DemoBlock Title="@Localizer["TablesExportShowExportCsvButtonTitle"]"
Introduction="@Localizer["TablesExportShowExportCsvButtonIntro"]"
Name="ShowCsvExportButton">
<Table TItem="Foo"
IsPagination="true" PageItemsSource="@PageItemsSource"
IsStriped="true" IsBordered="true" IsMultipleSelect="true"
ShowToolbar="true" ShowDefaultButtons="false"
ShowExportButton="true" ShowExportCsvButton="true" ShowExportPdfButton="true"
OnQueryAsync="@OnQueryAsync">
<TableColumns>
<TableColumn @bind-Field="@context.DateTime" Width="180" />
<TableColumn @bind-Field="@context.Name" Width="100" />
<TableColumn @bind-Field="@context.Address" />
<TableColumn @bind-Field="@context.Count" />
</TableColumns>
</Table>
</DemoBlock>

<DemoBlock Title="@Localizer["TablesExportOnExportAsyncTitle"]"
Introduction="@Localizer["TablesExportOnExportAsyncIntro"]"
Name="OnExportAsync">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public partial class TablesExport
/// </summary>
[NotNull]
private List<Foo>? Items { get; set; }

private static IEnumerable<int> PageItemsSource => new int[] { 4, 10, 20 };

/// <summary>
Expand Down Expand Up @@ -53,15 +54,15 @@ private async Task<bool> OnExportAsync(ITableExportDataContext<Foo> context)
// 自定义导出方法
// 通过 context 参数可以自己查询数据进行导出操作
// 本例使用 context 传递来的 Rows/Columns 自定义文件名为 Test.xlsx
var ret = await Exporter.ExportAsync(context.Rows, context.Columns, "Test.xlsx");
var ret = await TableExport.ExportExcelAsync(context.Rows, context.Columns, "Test.xlsx");

// 返回 true 时自动弹出提示框
return ret;
}

[Inject]
[NotNull]
private ITableExcelExport? Exporter { get; set; }
private ITableExport? TableExport { get; set; }

[Inject]
[NotNull]
Expand Down Expand Up @@ -124,7 +125,7 @@ private async Task ExcelExportAsync(ITableExportContext<Foo> context)
// 自定义导出模板导出当前页面数据为 Excel 方法
// 使用 BootstrapBlazor 内置服务 ITableExcelExport 实例方法 ExportAsync 进行导出操作
// 导出数据使用 context 传递来的 Rows/Columns 即为当前页数据
var ret = await Exporter.ExportAsync(context.Rows, context.Columns, $"Test_{DateTime.Now:yyyyMMddHHmmss}.xlsx");
var ret = await TableExport.ExportExcelAsync(context.Rows, context.Columns, $"Test_{DateTime.Now:yyyyMMddHHmmss}.xlsx");

// 返回 true 时自动弹出提示框
await ShowToast(ret);
Expand All @@ -145,7 +146,7 @@ private async Task ExcelExportAllAsync(ITableExportContext<Foo> context)
var data = Items.Where(filter.GetFilterFunc<Foo>());

// 导出符合条件的所有数据 data
var ret = await Exporter.ExportAsync(data, context.Columns, $"Test_{DateTime.Now:yyyyMMddHHmmss}.xlsx");
var ret = await TableExport.ExportExcelAsync(data, context.Columns, $"Test_{DateTime.Now:yyyyMMddHHmmss}.xlsx");

// 返回 true 时自动弹出提示框
await ShowToast(ret);
Expand All @@ -156,7 +157,7 @@ private async Task CsvExportAsync(ITableExportContext<Foo> context)
// 自定义导出模板导出当前页面数据为 Csv 方法
// 使用 BootstrapBlazor 内置服务 ITableExcelExport 实例方法 ExportCsvAsync 进行导出操作
// 导出数据使用 context 传递来的 Rows/Columns 即为当前页数据
var ret = await Exporter.ExportCsvAsync(context.Rows, context.Columns, $"Test_{DateTime.Now:yyyyMMddHHmmss}.csv");
var ret = await TableExport.ExportCsvAsync(context.Rows, context.Columns, $"Test_{DateTime.Now:yyyyMMddHHmmss}.csv");

// 返回 true 时自动弹出提示框
await ShowToast(ret);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public static IServiceCollection AddWebSiteServices(this IServiceCollection serv

// 增加 Table Excel 导出服务
services.AddBootstrapBlazorTableExcelExport();
services.AddTransient<ITableExportPdf, TableExportPdfService>();

return services;
}
Expand Down
2 changes: 2 additions & 0 deletions src/BootstrapBlazor.Server/Locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5136,6 +5136,8 @@
"TablesExportNote2": "Add Table Excel export service",
"TablesExportShowExportButtonTitle": "Table export function",
"TablesExportShowExportButtonIntro": "Whether to display the export button by setting the <code>ShowExportButton</code> property, the default is <code>false</code>",
"TablesExportShowExportCsvButtonTitle": "Export Csv/Pdf Button",
"TablesExportShowExportCsvButtonIntro": "Show/hide <code>Csv/Pdf</code> button by set <code>ShowExportCsvButton=\"true\"</code> <code>ShowExportPdfButton=\"true\"</code>",
"TablesExportOnExportAsyncTitle": "Custom export method",
"TablesExportOnExportAsyncIntro": "You can customize the export method by setting the <code>OnExportAsync</code> callback delegate method. If you don't set it, the built-in export function of the component will be used.",
"TablesExportButtonDropdownTemplateTitle": "Custom export dropdown button",
Expand Down
2 changes: 2 additions & 0 deletions src/BootstrapBlazor.Server/Locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -5136,6 +5136,8 @@
"TablesExportNote2": "增加 Table Excel 导出服务",
"TablesExportShowExportButtonTitle": "表格导出功能",
"TablesExportShowExportButtonIntro": "通过设置 <code>ShowExportButton=\"true\"</code> 属性是否显示导出按钮,默认为<code>false</code>",
"TablesExportShowExportCsvButtonTitle": "导出 Csv/Pdf",
"TablesExportShowExportCsvButtonIntro": "通过设置 <code>ShowExportCsvButton=\"true\"</code> <code>ShowExportPdfButton=\"true\"</code> 控制 <code>Csv/Pdf</code> 导出按钮",
"TablesExportOnExportAsyncTitle": "自定义导出方法",
"TablesExportOnExportAsyncIntro": "通过设置 <code>OnExportAsync</code> 回调委托方法可自定义导出方法,不设置将使用组件内置导出函数",
"TablesExportButtonDropdownTemplateTitle": "自定义导出下拉框按钮",
Expand Down
9 changes: 2 additions & 7 deletions src/BootstrapBlazor.Server/Services/TableDemoDataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@ namespace BootstrapBlazor.Server.Services;
/// <summary>
/// 演示网站示例数据注入服务实现类
/// </summary>
internal class TableDemoDataService<TModel> : DataServiceBase<TModel> where TModel : class, new()
class TableDemoDataService<TModel>(IStringLocalizer<TModel> localizer) : DataServiceBase<TModel> where TModel : class, new()
{
[NotNull]
private List<TModel>? Items { get; set; }

private IStringLocalizer<TModel> Localizer { get; set; }

public TableDemoDataService(IStringLocalizer<TModel> localizer)
{
Localizer = localizer;
}
private IStringLocalizer<TModel> Localizer { get; } = localizer;

/// <summary>
/// 查询操作方法
Expand Down
46 changes: 46 additions & 0 deletions src/BootstrapBlazor.Server/Services/TableExportPdfService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

namespace BootstrapBlazor.Server.Services;

class TableExportPdfService(IWebHostEnvironment webHostEnvironment, NavigationManager navigationManager, IHtml2Pdf html2Pdf) : ITableExportPdf
{
private readonly IWebHostEnvironment _webHostEnvironment = webHostEnvironment;
private readonly NavigationManager _navigationManager = navigationManager;
private readonly IHtml2Pdf _html2Pdf = html2Pdf;

public async Task<byte[]> PdfDataAsync(string content)
{
var url = await GenerateHtmlAsync(content);

// 生成 Pdf
return await _html2Pdf.PdfDataAsync(url);
}

public async Task<Stream> PdfStreamAsync(string content)
{
var url = await GenerateHtmlAsync(content);

// 生成 Pdf
return await _html2Pdf.PdfStreamAsync(url);
}

private async Task<string> GenerateHtmlAsync(string content)
{
// 通过 template 模板文件生成网页文件
var templateFileName = Path.Combine(_webHostEnvironment.WebRootPath, "pdf/template.htm");
var template = await File.ReadAllTextAsync(templateFileName);

// 生成静态 html 文件
var htmlFileName = $"pdf/{Guid.NewGuid()}.html";
var filePath = Path.Combine(_webHostEnvironment.WebRootPath, htmlFileName);
using var writer = File.CreateText(filePath);
await writer.WriteLineAsync(string.Format(template, content));
await writer.FlushAsync();
writer.Close();

// 拼接导出文件网址
return $"{_navigationManager.BaseUri}{htmlFileName}";
}
}
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>8.0.5</Version>
<Version>8.0.6-beta01</Version>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
Expand Down
7 changes: 7 additions & 0 deletions src/BootstrapBlazor/Components/Table/Table.razor
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@
}
else
{
if (ShowExportCsvButton)
{
<div class="dropdown-item" @onclick="@ExportCsvAsync">
<i class="@CsvExportIcon"></i>
<span>@ExportCsvDropdownItemText</span>
</div>
}
if (ShowExportExcelButton)
{
<div class="dropdown-item" @onclick="@ExportExcelAsync">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ private void OnInitLocalization()
ExportToastTitle ??= Localizer[nameof(ExportToastTitle)];
ExportToastContent ??= Localizer[nameof(ExportToastContent)];
ExportToastInProgressContent ??= Localizer[nameof(ExportToastInProgressContent)];
ExportCsvDropdownItemText ??= Localizer[nameof(ExportCsvDropdownItemText)];
ExportExcelDropdownItemText ??= Localizer[nameof(ExportExcelDropdownItemText)];
ExportPdfDropdownItemText ??= Localizer[nameof(ExportPdfDropdownItemText)];
CopyColumnTooltipText ??= Localizer[nameof(CopyColumnTooltipText)];
Expand Down
36 changes: 27 additions & 9 deletions src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public partial class Table<TItem>
[Parameter]
public bool ShowExportExcelButton { get; set; } = true;

/// <summary>
/// 获得/设置 是否显示 Csv 导出按钮 默认为 false 显示
/// </summary>
[Parameter]
public bool ShowExportCsvButton { get; set; }

/// <summary>
/// 获得/设置 是否显示 Pdf 导出按钮 默认为 false 显示
/// </summary>
Expand All @@ -75,6 +81,12 @@ public partial class Table<TItem>
[Parameter]
public string? ExportButtonIcon { get; set; }

/// <summary>
/// 获得/设置 内置导出 Csv 按钮图标
/// </summary>
[Parameter]
public string? CsvExportIcon { get; set; }

/// <summary>
/// 获得/设置 内置导出 Excel 按钮图标
/// </summary>
Expand Down Expand Up @@ -117,6 +129,12 @@ public partial class Table<TItem>
[Parameter]
public RenderFragment<ITableExportContext<TItem>>? ExportButtonDropdownTemplate { get; set; }

/// <summary>
/// 获得/设置 内置导出微软 Csv 按钮文本 默认 null 读取资源文件
/// </summary>
[Parameter]
public string? ExportCsvDropdownItemText { get; set; }

/// <summary>
/// 获得/设置 内置导出微软 Excel 按钮文本 默认 null 读取资源文件
/// </summary>
Expand Down Expand Up @@ -374,16 +392,12 @@ public Func<TItem, bool>? ShowDeleteButtonCallback

[Inject]
[NotNull]
private ITableExcelExport? ExcelExport { get; set; }

[Inject]
[NotNull]
private ITablePdfExport? PdfExport { get; set; }
private ITableExport? TableExport { get; set; }

/// <summary>
/// 获得/设置 各列是否显示状态集合
/// </summary>
private List<ColumnVisibleItem> VisibleColumns { get; } = new();
private List<ColumnVisibleItem> VisibleColumns { get; } = [];

/// <summary>
/// 获得当前可见列集合
Expand Down Expand Up @@ -1021,15 +1035,19 @@ private async Task ExecuteExportAsync(Func<Task<bool>> callback)

private Task ExportAsync() => ExecuteExportAsync(() => OnExportAsync != null
? OnExportAsync(new TableExportDataContext<TItem>(TableExportType.Unknown, Rows, GetVisibleColumns(), BuildQueryPageOptions()))
: ExcelExport.ExportAsync(Rows, GetVisibleColumns()));
: TableExport.ExportAsync(Rows, GetVisibleColumns()));

private Task ExportCsvAsync() => ExecuteExportAsync(() => OnExportAsync != null
? OnExportAsync(new TableExportDataContext<TItem>(TableExportType.Pdf, Rows, GetVisibleColumns(), BuildQueryPageOptions()))
: TableExport.ExportCsvAsync(Rows, GetVisibleColumns()));

private Task ExportPdfAsync() => ExecuteExportAsync(() => OnExportAsync != null
? OnExportAsync(new TableExportDataContext<TItem>(TableExportType.Pdf, Rows, GetVisibleColumns(), BuildQueryPageOptions()))
: PdfExport.ExportAsync(Rows, GetVisibleColumns()));
: TableExport.ExportPdfAsync(Rows, GetVisibleColumns()));

private Task ExportExcelAsync() => ExecuteExportAsync(() => OnExportAsync != null
? OnExportAsync(new TableExportDataContext<TItem>(TableExportType.Excel, Rows, GetVisibleColumns(), BuildQueryPageOptions()))
: ExcelExport.ExportAsync(Rows, GetVisibleColumns()));
: TableExport.ExportExcelAsync(Rows, GetVisibleColumns()));

/// <summary>
/// 获取当前 Table 选中的所有行数据
Expand Down
Loading