ISheetControl.SaveAsync Method
- Namespace
TXTextControl.TXSheetControl. Server
- Package
TXTextControl.asTXSheetControl. Server TXTextControl.from the private NuGet feed or the supplied NuGet folderTXSheetControl. Api. dll
- Also in
TXTextControl.asTXSheetControl. Blazor TXTextControl.TXSheetControl. Api. dll
Exports an isolated snapshot to caller-owned bytes.
Syntax
Overload 1
public Task<byte[]> SaveAsync(StreamType streamType, SaveOptions? options = null, CancellationToken cancellationToken = default)
Overload 2
public Task SaveAsync(string fileName, StreamType streamType, SaveOptions? options = null, CancellationToken cancellationToken = default)
Overload 3
public Task SaveAsync(Stream stream, StreamType streamType, SaveOptions? options = null, CancellationToken cancellationToken = default)
Parameters
| Name | Type | Description |
|---|---|---|
streamType | StreamType | Document or text format. PDF is save-only. |
options | SaveOptions? | Optional operation settings. |
cancellationToken | CancellationToken | Cancellation before starting the operation, with cooperative cancellation for supported file work. |
fileName | string | A native server filesystem path. Browser hosts reject this overload. |
stream | Stream | Caller-owned readable input or writable output stream. |
Return Value
Task<byte[]>. The awaited operation result, detached from browser transport.
Exceptions
API failures throw ServerSheetControlException with a code. A canceled operation throws OperationCanceledException. Browser filesystem overloads and synchronous C# cell renderers throw PlatformNotSupportedException.
Examples
The control variable is the host received by Ready. File examples use caller-provided xlsxBytes.
var sheet = await control.Workbook.Sheets.AtAsync(0);
await sheet.Cell("A1").SetValueAsync("Orders");
await sheet.Cell("B2").SetValueAsync(8);
byte[] xlsx = await control.SaveAsync(StreamType.SpreadsheetML);
byte[] pdf = await control.SaveAsync(StreamType.PDF);
Remarks
Await asynchronous operations. Replacement workbook loads invalidate earlier worksheet, cell and range handles. Browser callbacks report completed notifications.