Range.CopyToAsync 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
Performs an operation on this document without activating another worksheet.
Syntax
Overload 1
public Task CopyToAsync(Range destination, CancellationToken cancellationToken = default)
| Parameter | Type | Optional | Description |
|---|---|---|---|
destination | Range | No | Operation-specific input; see this type's units and ownership contract. |
cancellationToken | CancellationToken | Yes | Cancels the pending operation. |
Return value: Task. The operation result, returned asynchronously.
Overload 2
public Task CopyToAsync(Range destination, PasteOptions options, CancellationToken cancellationToken = default)
| Parameter | Type | Optional | Description |
|---|---|---|---|
destination | Range | No | A worksheet-bound destination in the same workbook. |
options | PasteOptions | No | Content, formatting, transpose or live-link mode; unsupported modes fail atomically. |
cancellationToken | CancellationToken | Yes | Cancels the pending operation. |
Return value: Task. A task that completes when the paste has been applied.
Examples
Create the sample document data first, then use Range.CopyToAsync. The returned value can be used by the calling report or application.
using Range = TXTextControl.TXSheetControl.Server.Range;
using TXTextControl.TXSheetControl.Server;
async Task UseRangeCopyToAsync(ServerSheetControl control, Range destination)
{
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 range = sheet.Range("B8:B9");
await range.FormatAsync(new { numberFormatCode = "#,##0.00", fontFamily = "Liberation Sans", fontSize = 11 });
await range.CopyToAsync(destination);
}
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.