Blazor
The TXTextControl.TXSheetControl.Blazor NuGet package adds the browser spreadsheet editor to Blazor Server and WebAssembly on .NET 10, with typed C# workbook APIs and completed notifications.
Install the Package
Install the package from the Text Control Private NuGet Feed with the nuget.config from your assignment email, as Install the NuGet Packages describes. Without the feed, add the nuget folder of the download as another source and keep nuget.org enabled:
dotnet nuget add source /path/to/TX-Sheet-Control-2.0/nuget TXSheetControl
dotnet new blazor SheetServer Server
dotnet add SheetServer/SheetServer.csproj package TXTextControl.TXSheetControl.Blazor 2.0.0
For standalone WebAssembly:
dotnet new blazorwasm SheetClient
dotnet add SheetClient/SheetClient.csproj package TXTextControl.TXSheetControl.Blazor 2.0.0
The package includes protected JavaScript, Shadow DOM styles, fonts, language files and the portable C# document API. It does not require the native Server package.
Configure Licensing
Download tx-sheet-control.license with the License button of the email that you receive when a serial number is assigned to you, and pass its contents unchanged to SheetControlOptions.License. Set TXSheetControl:License in application configuration. WebAssembly can read this from wwwroot/appsettings.json. Browser configuration is public. Keep store issuer secrets out of it. The existing store-issued browser reader verifies the license before Ready. Trial, Developer and OEM licensing and watermark rules match the other editor integrations.
Add a Worksheet
Add this component to an interactive page. In Blazor Server, add @rendermode InteractiveServer above the markup. Standalone WebAssembly needs no render-mode directive.
@using TXTextControl.TXSheetControl.Blazor
@using TXTextControl.TXSheetControl.Server
@inject Microsoft.Extensions.Configuration.IConfiguration Configuration
<TXSheetControl Options="options" Ready="OnReady" Error="OnError" Height="640" />
<p role="status">@status</p>
@code {
private SheetControlOptions options = default!;
private string status = "Initializing";
protected override void OnInitialized() => options = new()
{ License = Configuration["TXSheetControl:License"] ?? "", Rows = 2000, Columns = 20 };
private async Task OnReady(BlazorSheetControl control)
{
var sheet = await control.Workbook.Sheets.AtAsync(0);
await sheet.Range("A1:D2").SetValuesAsync([
[], ["Notebook", 5, 12, null]
]);
await sheet.Cell("D2").SetFormulaAsync("=B2*C2");
await sheet.Range("A1:D1").FormatAsync(new { font = new { bold = true } });
status = $"Ready ({(await control.GetLicenseInfoAsync()).Type})";
}
private void OnError(SheetControlErrorEventArgs error) =>
status = $"{error.Code}: {error.Message}";
}
Wait for Ready before using the API. Prerendering emits the host element, and initialization starts after interactive rendering. Shared Workbook, Worksheet, Cell and Range types remain in TXTextControl.TXSheetControl.Server when used by Blazor.
Load and Save
Keep the control received by Ready in a field. Import Microsoft.AspNetCore.Components.Forms and connect <InputFile OnChange="OpenFile" /> to this handler:
private BlazorSheetControl control = default!;
private async Task OpenFile(InputFileChangeEventArgs args)
{
await using var stream = args.File.OpenReadStream(128L * 1024 * 1024);
await control.LoadAsync(stream, StreamType.SpreadsheetML);
}
private Task<byte[]> ExportPdf() => control.SaveAsync(StreamType.PDF);
Use exported bytes for a download or an application API request. Binary transfers are bounded to 128 MiB, and caller-owned streams remain open. Filesystem-name overloads throw PlatformNotSupportedException.
Events and Lifetime
The component exposes Changed, Edited, Loaded, Saved, Event and SelectionChanged callbacks. Error handles initialization and callback failures. Awaited API calls also throw ServerSheetControlException with a machine-readable Code and need their own error handling.
Completed events arrive asynchronously and cannot cancel committed edits. Configure validation rules before editing. Synchronous before-events and synchronous C# cell-renderer callbacks are unavailable in the browser host.
The component owns and disposes its control when removed from the render tree. Dispose independent mail-merge result controls before their parent. Loading a replacement workbook invalidates previously acquired worksheet, cell and range handles.
Update Options
Assign a new options record to change theme, language, zoom, author, ribbon policies, resource overrides, view mode, chrome visibility or dependent highlighting:
options = options with
{
Theme = "dark", Language = "de", Zoom = 125,
Ribbon = new() { Layout = "compact", DisplayMode = "expanded" }
};
License, initial capacities, growth limits, dashboard policy, locale and font URLs are mount settings. Change @key to recreate the component when changing these settings. Omitted ribbon, resource and author patches preserve current values.
Custom Calculation
Register C# custom functions through Workbook.Calculation.RegisterFunctionAsync. Browser evaluation calls C# asynchronously. Keep callbacks short, observe their cancellation token and return the calculated value. Calling back into the same control from its formula callback is rejected to prevent interop deadlock.
Backend Processing
Blazor Server still runs the editor engine in the browser. Install the native Server package separately for independent backend jobs. Exchange TXWB or XLSX bytes explicitly. The browser and backend controls do not share live workbook state.