TX Sheet Control

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

Creates an independent document with its own workbook contents and edit history.

Syntax

public ServerSheetControl CreateSession(ServerSheetControlOptions? options = null)

Parameters

ParameterTypeOptionalDescription
optionsServerSheetControlOptions?YesOptional document defaults; omission inherits the owner's font source and workbook settings.

Return Value

ServerSheetControl. A new document control. Dispose it before the control that created it.

Exceptions

  • ObjectDisposedException: The owner has been disposed.

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[]> CreateInvoiceCreateSessionAsync(ServerSheetControl control)
{
    await using var session = control.CreateSession();
    var sheet = await session.Workbook.Sheets.AtAsync(0);
    await sheet.Cell("A1").SetTextAsync("Independent customer invoice");
    await sheet.Cell("A1").FormatAsync(new { fontFamily = "Liberation Sans", fontSize = 16, bold = true, textColor = "#ffffff", fillColor = "#163b63" });
    return await session.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