TX Sheet Control

ServerSheetControl.SaveAsync Method

Method
Namespace
TXTextControl.TXSheetControl.Server
Package
TXTextControl.TXSheetControl.Server as TXTextControl.TXSheetControl.Server.dll from the private NuGet feed or the supplied NuGet folder

Saves an isolated revision to bytes. Saving is cancellable; Saved follows successful byte generation.

Syntax

Overload 1

public Task<byte[]> SaveAsync(StreamType streamType, SaveOptions? options = null, CancellationToken cancellationToken = default)
ParameterTypeOptionalDescription
streamTypeStreamTypeNoThe supported input or output format. PDF is output-only.
optionsSaveOptions?YesSupported settings for this operation; omitted settings retain documented defaults.
cancellationTokenCancellationTokenYesCancels 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)
ParameterTypeOptionalDescription
fileNamestringNoApplication-authorized input or output file path.
streamTypeStreamTypeNoThe supported input or output format. PDF is output-only.
optionsSaveOptions?YesSupported settings for this operation; omitted settings retain documented defaults.
cancellationTokenCancellationTokenYesCancels 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)
ParameterTypeOptionalDescription
streamStreamNoValue matching stream's declared type and the owning object's validation rules.
streamTypeStreamTypeNoThe supported input or output format. PDF is output-only.
optionsSaveOptions?YesSupported settings for this operation; omitted settings retain documented defaults.
cancellationTokenCancellationTokenYesCancels waiting or execution as supported by this operation.

Return value: Task.

Examples

Create and format a complete invoice before using this processing API. Return document bytes, operation metadata or notifications to the application; dispose owned controls after processing.

using TXTextControl.TXSheetControl.Server;

async Task<byte[]> CreateInvoiceSaveAsyncAsync(ServerSheetControl control)
{
    var book = control.Workbook;
    var sheet = await book.Sheets.AtAsync(0);
    await sheet.Range("A7:D9").SetValuesAsync(new object?[][]
    {
        ["Description", "Quantity", "UnitPrice", "Amount"],
        ["Consulting", 3, 120, 360],
        ["Training", 2, 90, 180]
    });

    var table = await sheet.Tables.AddAsync("InvoiceLines", "A7:D9", new TableOptions { Style = "TableStyleMedium2", ShowRowStripes = true });
    await sheet.Cell("A1").SetTextAsync("October invoice");
    await sheet.Cell("A1").FormatAsync(new { fontFamily = "Liberation Sans", fontSize = 16, bold = true, textColor = "#ffffff", fillColor = "#163b63" });
    await sheet.Range("C8:D9").FormatAsync(new { numberFormatCode = "#,##0.00", fontFamily = "Liberation Sans", fontSize = 11 });
    return await control.SaveAsync(StreamType.PDF);
}

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.

See Also