Workbook.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
Saves a detached binary document snapshot; export metadata never changes the live workbook.
Syntax
Overload 1
public Task<byte[]> SaveAsync(StreamType streamType, SaveOptions? options = null, CancellationToken cancellationToken = default)
| Parameter | Type | Optional | Description |
|---|---|---|---|
streamType | StreamType | No | The supported input or output format. PDF is output-only. |
options | SaveOptions? | Yes | Supported settings for this operation; omitted settings retain documented defaults. |
cancellationToken | CancellationToken | Yes | Cancels waiting or execution as supported by this operation. |
Return value: Task<byte[]>.
Overload 2
public Task SaveAsync(string fileName, StreamType streamType, SaveOptions? options = null, CancellationToken cancellationToken = default)
| Parameter | Type | Optional | Description |
|---|---|---|---|
fileName | string | No | Application-authorized input or output file path. |
streamType | StreamType | No | The supported input or output format. PDF is output-only. |
options | SaveOptions? | Yes | Supported settings for this operation; omitted settings retain documented defaults. |
cancellationToken | CancellationToken | Yes | Cancels waiting or execution as supported by this operation. |
Return value: Task.
Overload 3
public Task SaveAsync(Stream stream, StreamType streamType, SaveOptions? options = null, CancellationToken cancellationToken = default)
| Parameter | Type | Optional | Description |
|---|---|---|---|
stream | Stream | No | Value matching stream's declared type and the owning object's validation rules. |
streamType | StreamType | No | The supported input or output format. PDF is output-only. |
options | SaveOptions? | Yes | Supported settings for this operation; omitted settings retain documented defaults. |
cancellationToken | CancellationToken | Yes | Cancels waiting or execution as supported by this operation. |
Return value: Task.
Examples
Create the sample document data first, then use Workbook.SaveAsync. The returned value can be used by the calling report or application.
using TXTextControl.TXSheetControl.Server;
async Task<byte[]> UseWorkbookSaveAsync(ServerSheetControl control)
{
var book = control.Workbook;
var sheet = await book.Sheets.AtAsync(0);
await sheet.Cell("B8").SetValueAsync(120);
await sheet.Cell("B9").SetValueAsync(80);
await sheet.Cell("B10").SetFormulaAsync("=SUM(B8:B9)");
var workbook = book;
var result = await workbook.SaveAsync(StreamType.PDF, new SaveOptions { Pdf = new PdfOptions { Locale = "de-DE", Title = "Invoice" } });
return result;
}
Remarks
Use the member with an instance or settings object from the documented package. Await task-returning operations. Document-bound handles must be resolved again after loading or deleting their owner.