TX Sheet Control

Workbook.LoadAsync Method

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

Loads a binary document with the same reusable options as the owning control.

Syntax

Overload 1

public Task<LoadResult> LoadAsync(byte[] bytes, StreamType streamType, LoadOptions? options = null, CancellationToken cancellationToken = default)
ParameterTypeOptionalDescription
bytesbyte[]NoDocument bytes in the selected format.
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 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 the sample document data first, then use Workbook.LoadAsync. The returned value can be used by the calling report or application.

using TXTextControl.TXSheetControl.Server;

async Task<LoadResult> UseWorkbookLoadAsync(ServerSheetControl control, byte[] bytes)
{
    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.LoadAsync(bytes, StreamType.SpreadsheetML, new LoadOptions());
    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.

See Also