Skip to content

Commit ed8eafd

Browse files
committed
feat: 增加保存文档示例
1 parent 7dd5038 commit ed8eafd

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/BootstrapBlazor.Server/Components/Samples/UniverSheets.razor

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
<div class="bb-sheet-demo">
2020
<UniverSheet @ref="_sheetExcel" OnReadyAsync="OnReadyAsync"></UniverSheet>
2121
</div>
22+
<section ignore>
23+
<Textarea rows="3" readonly Value="@_jsonData"></Textarea>
24+
</section>
2225
</DemoBlock>
2326

2427
<DemoBlock Title="@Localizer["PluginTitle"]"
@@ -29,6 +32,6 @@
2932
<Button OnClickWithoutRender="OnPushPluginData" Text="@Localizer["PushButtonText"]"></Button>
3033
</section>
3134
<div class="bb-sheet-demo">
32-
<UniverSheet @ref="_sheetPlugin" Plugins="Plugins" OnPostDataAsync="OnPostDataAsync"></UniverSheet>
35+
<UniverSheet @ref="_sheetPlugin" Plugins="_plugins" OnPostDataAsync="OnPostDataAsync"></UniverSheet>
3336
</div>
3437
</DemoBlock>

src/BootstrapBlazor.Server/Components/Samples/UniverSheets.razor.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@ public partial class UniverSheets
1919
[Inject, NotNull]
2020
private IStringLocalizer<UniverSheets>? Localizer { get; set; }
2121

22-
private readonly Dictionary<string, string> Plugins = new()
22+
private readonly Dictionary<string, string> _plugins = new()
2323
{
2424
{ "ReportPlugin", "univer-sheet/plugin.js" }
2525
};
2626

27-
private UniverSheet _sheetExcel = default!;
27+
[NotNull]
28+
private UniverSheet? _sheetExcel = null;
2829

29-
private UniverSheet _sheetPlugin = default!;
30+
[NotNull]
31+
private UniverSheet? _sheetPlugin = null;
3032

31-
private static string? _reportData = default!;
33+
private static string? _reportData = null;
34+
35+
private string? _jsonData = null;
3236

3337
/// <summary>
3438
/// <inheritdoc/>
@@ -72,10 +76,12 @@ await _sheetExcel.PushDataAsync(new UniverSheetData()
7276

7377
private async Task OnSaveExcelData()
7478
{
75-
var data = await _sheetExcel.PushDataAsync(new UniverSheetData()
79+
var result = await _sheetExcel.PushDataAsync(new UniverSheetData()
7680
{
7781
CommandName = "GetWorkbook"
7882
});
83+
_jsonData = result?.Data?.ToString();
84+
StateHasChanged();
7985
}
8086

8187
private async Task OnPushPluginData()

0 commit comments

Comments
 (0)