TX Sheet Control

WorkbookEventArgs.CanCancel Property

Property
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

True only for events that can stop the proposed operation.

Syntax

public bool CanCancel { get; init; }

Property Value

bool.

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 System.Text.Json;
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(JsonSerializer.Serialize(args.CanCancel));
    }

    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();
}

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