ExcelExportAsync(ExportContext)">
+
MS-Excel
diff --git a/src/BootstrapBlazor.Shared/Samples/Table/TablesExport.razor.cs b/src/BootstrapBlazor.Shared/Samples/Table/TablesExport.razor.cs
index af9295e1d..3fae9cb54 100644
--- a/src/BootstrapBlazor.Shared/Samples/Table/TablesExport.razor.cs
+++ b/src/BootstrapBlazor.Shared/Samples/Table/TablesExport.razor.cs
@@ -58,7 +58,5 @@ public partial class TablesExport
private static Task
OnExportAsync(IEnumerable Items, QueryPageOptions options) => Task.FromResult(true);
- private static Task ExcelExportAsync(ITableExportContext context) => context.ExportAsync();
-
private Task CsvExportAsync() => ToastService.Success("CSV export", "Export CSV data successfully");
}
diff --git a/test/UnitTest/Components/TableTest.cs b/test/UnitTest/Components/TableTest.cs
index 4e1392118..785106841 100644
--- a/test/UnitTest/Components/TableTest.cs
+++ b/test/UnitTest/Components/TableTest.cs
@@ -577,6 +577,7 @@ public class TableTest : TableTestBase
[Fact]
public void ExportButtonDropdownTemplate_Ok()
{
+ ITableExportContext? context = null;
var localizer = Context.Services.GetRequiredService>();
var cut = Context.RenderComponent(pb =>
{
@@ -585,8 +586,9 @@ public class TableTest : TableTestBase
pb.Add(a => a.ShowToolbar, true);
pb.Add(a => a.ShowExportButton, true);
pb.Add(a => a.ExportButtonText, "Test_Export");
- pb.Add(a => a.ExportButtonDropdownTemplate, builder =>
+ pb.Add(a => a.ExportButtonDropdownTemplate, c => builder =>
{
+ context = c;
builder.OpenElement(0, "div");
builder.AddContent(1, "test-export-dropdown-item");
builder.CloseElement();
@@ -602,6 +604,13 @@ public class TableTest : TableTestBase
});
});
cut.Contains("test-export-dropdown-item");
+ Assert.NotNull(context);
+
+ Assert.Single(context.Columns);
+ Assert.Single(context.GetVisibleColumns());
+ Assert.NotNull(context.BuildQueryPageOptions());
+ Assert.Equal(80, context.Rows.Count());
+ Assert.NotNull(context.ExportAsync());
}
[Fact]
diff --git a/test/UnitTest/Extensions/ObjectExtensionsTest.cs b/test/UnitTest/Extensions/ObjectExtensionsTest.cs
index eb4120313..0b0474db8 100644
--- a/test/UnitTest/Extensions/ObjectExtensionsTest.cs
+++ b/test/UnitTest/Extensions/ObjectExtensionsTest.cs
@@ -56,6 +56,16 @@ public class ObjectExtensionsTest
Assert.Equal(expect, actual);
}
+ [Theory]
+ [InlineData(typeof(TimeSpan?), true)]
+ [InlineData(typeof(TimeSpan), true)]
+ [InlineData(typeof(string), false)]
+ public static void IsTimeSpan_Ok(Type source, bool expect)
+ {
+ var actual = source.IsTimeSpan();
+ Assert.Equal(expect, actual);
+ }
+
[Theory]
[InlineData(typeof(SortOrder), "枚举")]
[InlineData(typeof(int), "数字")]