TX Sheet Control

WorkbookEventArgs Class

Class
Namespace
TXTextControl.TXSheetControl.Server
Package
TXTextControl.TXSheetControl.Server from the private NuGet feed or the supplied NuGet folder
Assembly
TXTextControl.TXSheetControl.Api.dll
Install
dotnet add package TXTextControl.TXSheetControl.Server .NET 10 and later.
Also in
TXTextControl.TXSheetControl.Blazor as TXTextControl.TXSheetControl.Api.dll
Inherits
  1. EventArgs
  2. WorkbookEventArgs

Detached workbook event context. Cancellation is honored by before-events, Loading and Saving.

Syntax

public class WorkbookEventArgs

Members

Constructors

ConstructorDescription
Constructor

Properties

PropertyDescription
AddressSingle-cell address for interaction and editing events.
AddressesAffected A1 cell addresses.
AllowInvalidExplicitly accepts a non-stop validation failure. Stop constraints remain enforced.
ByteLengthKnown input/output length in bytes. File contents and destination paths are never included.
CanCancelTrue only for events that can stop the proposed operation.
CancelSet synchronously in a cancellable event handler to roll back the attempted operation.
CompletedActual completed work in Unit. Counts restart when the phase changes.
DataDetached event-specific values, including input, value or calculation pendingCount.
ErrorCodeDiagnostic code on FileOperationFailed, when available.
ErrorMessageDiagnostic message on FileOperationFailed. The method still throws its original exception.
IsCanceledTrue for a failed operation stopped by an event handler or cancellation request.
NameThe event name shared with the JavaScript typed event surface.
OperationFile operation kind: load or save. Null for other workbook events.
OperationIdOpaque correlation ID for one load/save operation, including concurrent calls.
PhaseProcessing stage: reading, parsing, snapshot, exporting, rendering, writing or completed.
SheetIdWorksheet identity independent of the active sheet.
SourceThe originating operation, when available.
SourcesContributing operations inside one atomic batch.
StreamTypeFile format involved in the operation. PDF is save-only.
TotalKnown amount of work in Unit, or null for indeterminate stages.
UnitProgress counter unit: bytes or pages. Null when only a processing phase is known.
WarningsDetached import notices on Loaded; empty for other events.

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.Changed += 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.Changed -= OnNotification;
    }

    return events.ToArray();
}

See Also