alexa
menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Search Results for

    Show / Hide Table of Contents

    Class WorksheetAddingEventArgs

    Provides information about the WorksheetAdding event, which is triggered before a new worksheet is added.

    Inheritance
    object
    WorksheetAddingEventArgs
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Syncfusion.Blazor.Spreadsheet
    Assembly: Syncfusion.Blazor.Spreadsheet.dll
    Syntax
    public class WorksheetAddingEventArgs
    Remarks

    This event allows you to intercept the process of adding a new worksheet to the spreadsheet.

    You can use the properties of this class to get details about the incoming worksheet and to cancel the operation if needed.

    Constructors

    WorksheetAddingEventArgs()

    Declaration
    public WorksheetAddingEventArgs()

    Properties

    Cancel

    Gets or sets a value indicating whether the worksheet adding operation should be cancelled.

    Declaration
    public bool Cancel { get; set; }
    Property Value
    Type Description
    bool

    A bool indicating whether to cancel the operation. The default value is false. When set to true, the new worksheet will not be added to the spreadsheet.

    Remarks

    Setting this property to true will prevent the new worksheet from being inserted, effectively canceling the "Worksheet Adding" event.

    This is useful for implementing custom logic to restrict the creation of new worksheets, e.g., based on user permissions or predefined limits.

    Examples
    // Example: Cancel the addition of a new worksheet if certain conditions are not met
    private void OnWorksheetAdding(WorksheetAddingEventArgs args)
    {
        // Prevent adding if the proposed name is "Restricted"
        if (args.Name == "Restricted")
        {
            args.Cancel = true;
        }
    }

    Index

    Gets or sets the zero-based index at which the new worksheet will be inserted.

    Declaration
    public int Index { get; set; }
    Property Value
    Type Description
    int

    An int representing the proposed insertion index of the new worksheet.

    Remarks

    You can modify this property to change the position where the worksheet will be inserted.

    Examples
    // Example: Insert the new worksheet at a specific index
    private void OnWorksheetAdding(WorksheetAddingEventArgs args)
    {
        // Insert the new sheet as the second sheet (index 1)
        args.Index = 1;
    }

    Name

    Gets or sets the name of the new worksheet to be added.

    Declaration
    public string Name { get; set; }
    Property Value
    Type Description
    string

    A string representing the proposed name of the new worksheet.

    Remarks

    You can modify this property to change the name of the worksheet before it is added to the spreadsheet.

    The name must be unique within the workbook to avoid conflicts.If a worksheet with the same name already exists, the spreadsheet component will typically append a number to make it unique (e.g., "Sheet1 (2)"). However, it's best practice to ensure uniqueness yourself when modifying this property.

    Name of the worksheet cannot exceed 30 characters. It it exceed means insert sheet will not perform.

    Examples
    // Example: Set a custom name for the new worksheet
    private void OnWorksheetAdding(WorksheetAddingEventArgs args)
    {
        args.Name = "New_Custom_Sheet";
    }
    In this article
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved