TX Sheet Control

ServerSheetControl.LoadAsync 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

Loads workbook or UTF-8 CSV/XML/JSON tabular bytes atomically. Raises Loading once and Loaded only after replacement succeeds.

Syntax

Overload 1

public Task<LoadResult> LoadAsync(byte[] bytes, StreamType streamType, LoadOptions? options = null, CancellationToken cancellationToken = default)
ParameterTypeOptionalDescription
bytesbyte[]NoInput bytes copied before notification; the caller retains ownership.
streamTypeStreamTypeNoSpreadsheetML, InternalWorkbookFormat, CSV, XML or JSON; PDF is save-only.
optionsLoadOptions?YesReusable package and conversion limits.
cancellationTokenCancellationTokenYesCancels the operation. Started failures raise FileOperationFailed.

Return value: Task<LoadResult>.

Overload 2

public Task<LoadResult> LoadAsync(string fileName, StreamType streamType, LoadOptions? options = null, CancellationToken cancellationToken = default)
ParameterTypeOptionalDescription
fileNamestringNoApplication-authorized input or output file path.
streamTypeStreamTypeNoThe supported input or output format. PDF is output-only.
optionsLoadOptions?YesSupported settings for this operation; omitted settings retain documented defaults.
cancellationTokenCancellationTokenYesCancels waiting or execution as supported by this operation.

Return value: Task<LoadResult>.

Overload 3

public Task<LoadResult> LoadAsync(Stream stream, StreamType streamType, LoadOptions? 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.
optionsLoadOptions?YesSupported settings for this operation; omitted settings retain documented defaults.
cancellationTokenCancellationTokenYesCancels waiting or execution as supported by this operation.

Return value: Task<LoadResult>.

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[]> CreateInvoiceLoadAsyncAsync(ServerSheetControl control, byte[] originalXlsx)
{
    await control.LoadAsync(originalXlsx, StreamType.SpreadsheetML);

    var sheet = await control.Workbook.Sheets.AtAsync(0);
    await sheet.Cell("A1").SetTextAsync("Reviewed invoice");
    await sheet.Cell("A1").FormatAsync(new { fontFamily = "Liberation Sans", fontSize = 16, bold = true, textColor = "#ffffff", fillColor = "#163b63" });
    return await control.SaveAsync(StreamType.PDF, new SaveOptions { OmitDashboards = true });
}

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