ServerSheetControl.LoadAsync Method
- Namespace
TXTextControl.TXSheetControl. Server
- Package
TXTextControl.asTXSheetControl. Server TXTextControl.from the private NuGet feed or the supplied NuGet folderTXSheetControl. Server. dll
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)
| Parameter | Type | Optional | Description |
|---|---|---|---|
bytes | byte[] | No | Input bytes copied before notification; the caller retains ownership. |
streamType | StreamType | No | SpreadsheetML, InternalWorkbookFormat, CSV, XML or JSON; PDF is save-only. |
options | LoadOptions? | Yes | Reusable package and conversion limits. |
cancellationToken | CancellationToken | Yes | Cancels 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)
| 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 | LoadOptions? | 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<LoadResult>.
Overload 3
public Task<LoadResult> LoadAsync(Stream stream, StreamType streamType, LoadOptions? 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 | LoadOptions? | 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<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.