TX Sheet Control

WorkbookEvents.BeforeStructure Event

Event
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

Syntax

public event EventHandler<WorkbookEventArgs> BeforeStructure

Event Type

EventHandler<WorkbookEventArgs>.

Examples

Subscribe while processing a document and return detached notifications for the application UI or audit trail. Handlers are synchronous: do not call document methods inside them. Only matching operations raise the selected event.

using TXTextControl.TXSheetControl.Server;

async Task<string[]> CaptureReportNotificationsAsync(ServerSheetControl control)
{
    var book = control.Workbook;
    var sheet = await book.Sheets.AtAsync(0);
    var events = new List<string>();
    void OnNotification(object? sender, WorkbookEventArgs args)
    {
        events.Add(args.Name + ": " + string.Join(", ", args.Addresses));
    }

    book.Events.BeforeStructure += OnNotification;

    try
    {
        await sheet.Cell("A1").SetTextAsync("October invoice");
        await sheet.Cell("A1").FormatAsync(new { fontFamily = "Liberation Sans", fontSize = 16, bold = true, textColor = "#ffffff", fillColor = "#163b63" });
        await control.SaveAsync(StreamType.PDF);
    }
    finally
    {
        book.Events.BeforeStructure -= OnNotification;
    }

    return events.ToArray();
}

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