menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class SfSpreadsheet - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class SfSpreadsheet

    Inheritance
    System.Object
    SfSpreadsheet
    Namespace: Syncfusion.Blazor.Spreadsheet
    Assembly: Syncfusion.Blazor.Spreadsheet.dll
    Syntax
    public class SfSpreadsheet : SfBaseComponent

    Constructors

    SfSpreadsheet()

    Declaration
    public SfSpreadsheet()

    Properties

    ActiveSheetIndex

    Gets or sets the index of the active sheet in the Syncfusion.Blazor.Spreadsheet.

    Declaration
    public int ActiveSheetIndex { get; set; }
    Property Value
    Type Description
    System.Int32

    An System.Int32 representing the zero-based index of the active sheet. The default value is 0.

    Remarks

    This property allows you to programmatically set which sheet should be the active sheet in the spreadsheet.

    Key points to note:

    • The index is zero-based, meaning 0 represents the first sheet, 1 represents the second sheet, and so on.
    • The active sheet will change when this property is set. For example, setting it to 2 will make the third sheet (Sheet3) the active sheet.
    • If an invalid index is provided (e.g., an index that is out of range of the available sheets), the ActiveSheetIndex will be automatically set to 0, making the first sheet active. For example, if a spreadsheet has 3 sheets and you set ActiveSheetIndex = 5, it will be automatically corrected to 0, making the first sheet active.

    AllowAutofill

    Gets or sets a value indicating whether Autofill functionality is enabled in the Syncfusion.Blazor.Spreadsheet. 

    Declaration
    public bool AllowAutofill { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if Autofill is enabled; otherwise, false. The default value is true.

    Remarks

      Autofill is a feature that automatically extends data patterns or formulas when you drag the fill handle  (the small square at the bottom-right corner of a selected cell or range). 

     

    When this property is set to true:

     
    • User can drag the fill handle to automatically fill adjacent cells based on patterns in the selected range.
    • The Autofill functionality works for numbers, dates, and more.
     

    When set to false:

     
    • The Autofill feature is disabled.
    • The fill handle will not be shown.
     

    Disabling this feature can be useful in scenarios where you want to prevent user from accidentally  modifying data through Autofill or when you need more control over data entry. 

     

    AllowEditing

    Gets or sets a value indicating whether editing is allowed in the Syncfusion.Blazor.Spreadsheet.

    Declaration
    public bool AllowEditing { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if editing is allowed; otherwise, false. The default value is true.

    Remarks

    This property controls the editability of the spreadsheet. When set to true, user can:

    • Add new data to empty cells
    • Modify existing cell contents
    • Delete cell contents

    When set to false, the spreadsheet enters a read-only mode where:

    • User cannot add new data to cells
    • Existing cell contents cannot be modified
    • Cell contents cannot be deleted

    Setting this property to false is useful in scenarios where you want to display data without allowing user to make changes, such as in reporting applications or when presenting finalized data.

    AllowFiltering

    Gets or sets a value indicating whether filtering functionality is enabled in the Syncfusion.Blazor.Spreadsheet.

    Declaration
    public bool AllowFiltering { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if filtering is allowed; otherwise, false. The default value is true.

    Remarks

    This property controls the availability of data filtering features within the spreadsheet. When set to true:

    • User can filter data based on various criteria such as text, numbers, or dates.
    • Filtering options are available in the user interface (e.g., column header filter buttons).
    • Programmatic filtering through the API remains functional.

    When set to false:

    • All filtering features are disabled.
    • Filter buttons are removed from column headers.
    • Filtering options are removed from the context menu and disabled in the ribbon, modifying the user interface.
    • Applying filters programmatically is not supported.

    Disabling filtering can be useful in scenarios where:

    • You want user to always see the complete dataset.
    • The spreadsheet is used primarily for data entry rather than data analysis.
    • You want to simplify the user interface by removing filtering options.

    AllowHyperlink

    Gets or sets a value indicating whether the Hyperlink feature and its related functionalities are enabled in the Syncfusion.Blazor.Spreadsheet.

    Declaration
    public bool AllowHyperlink { get; set; }
    Property Value
    Type Description
    System.Boolean

    A System.Boolean indicating whether hyperlink functionality is enabled. The default value is true.

    Remarks

    This property controls whether users can add, remove and interact with Hyperlinks in the spreadsheet cells using the context menu, ribbon, or programmatic API methods.

    Key behaviors based on this property's value:

    • When true: The Hyperlink option is available in the context menu and ribbon for applicable cells, allowing users to create and manage Hyperlinks.
    • When false:: The Hyperlink option is hidden and disabled from the context menu and ribbon respectively, preventing users from creating or managing Hyperlinks via the user interface or API methods.
    • IMPORTANT: When disabled, both UI interactions and programmatic API methods for hyperlink manipulation will not function.
    • IMPORTANT: Regardless of this property's value, hyperlinks will always be loaded and displayed when opening any Excel file.

    Use cases for disabling Hyperlinks:

    • Preventing users from adding external links in controlled environments.
    • Simplifying the user interface for specific data entry scenarios.
    • Maintaining data consistency in template-based spreadsheets.

    AllowImage

    Gets or sets a value indicating whether images can be inserted into the Syncfusion.Blazor.Spreadsheet.

    Declaration
    public bool AllowImage { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if image insertion is allowed; otherwise, false. The default value is true.

    Remarks

    This property controls the ability to insert images into the spreadsheet. When set to true:

    • User can insert images through the user interface.
    • Existing images in the spreadsheet remain visible and can be manipulated.

    When set to false:

    • The option to insert images is disabled in the user interface.
    • Existing images in the spreadsheet remain visible and can be manipulated.

    AllowResizing

    Gets or sets a value indicating whether resizing of columns and rows is allowed in the Syncfusion.Blazor.Spreadsheet.

    Declaration
    public bool AllowResizing { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if resizing of columns and rows is allowed; otherwise, false. The default value is true.

    Remarks

    This property controls the ability to resize columns and rows in the spreadsheet. When set to true:

    • User can manually resize columns by dragging the column header boundaries.
    • User can manually resize rows by dragging the row header boundaries.

    When set to false:

    • Manual resizing of columns and rows is disabled.
    • The resize handles on column and row headers will not be displayed.

    Disabling resizing can be useful in scenarios where:

    • You want to maintain a consistent layout across all users views of the spreadsheet.
    • The spreadsheet is part of a form with a fixed layout.
    • You want to prevent accidental resizing that might affect data visibility or printing layouts.

    AllowSorting

    Gets or sets a value indicating whether sorting functionality is enabled in the Syncfusion.Blazor.Spreadsheet.

    Declaration
    public bool AllowSorting { get; set; }
    Property Value
    Type Description
    System.Boolean

    A System.Boolean indicating whether sorting functionality is enabled. The default value is true.

    Remarks

    This property controls the availability of sorting features within the spreadsheet. When set to true:

    • User can sort data in ascending or descending order.
    • Sorting options are available in the user interface (e.g., context menus, ribbon).
    • Programmatic sorting through the API remains functional.

    When set to false:

    • All sorting features are disabled.
    • Sorting options are removed from the context menu and disabled in the ribbon, modifying the user interface.
    • Applying sorting programmatically is not supported.

    Disabling sorting can be useful in scenarios where:

    • Data order must be preserved for accuracy or consistency reasons.
    • The spreadsheet is part of a form or data entry interface where sorting could disrupt the workflow.
    • You want to simplify the user interface by removing sorting options.

    ColumnCount

    Gets or sets the number of columns to be rendered in the Syncfusion.Blazor.Spreadsheet.

    Declaration
    public int ColumnCount { get; set; }
    Property Value
    Type Description
    System.Int32

    An integer representing the number of columns. The default value is 200.

    Remarks

    The ColumnCount property determines the number of columns that will be rendered in the Spreadsheet. This affects the horizontal size of the sheet and the amount of data that can be displayed at once.

    Important considerations:

    • When no data is provided, an empty sheet is rendered based on this value.
    • When data is provided (via byte array or imported file), additional empty columns are rendered to meet this count if necessary.
    • This property is used to implement finite scrolling, limiting the rendering of unnecessary empty cells.

    Adjusting this property impacts the rendering behavior and can affect performance. It's recommended to set it to a value that balances the amount of data to be displayed and the performance requirements of the application.

    CssClass

    Gets or sets the CSS class or classes to be applied to the Syncfusion.Blazor.Spreadsheet's root element.

    Declaration
    public string CssClass { get; set; }
    Property Value
    Type Description
    System.String

    A string containing one or more CSS class names separated by spaces. The default value is string.Empty.

    Remarks

    This property allows for customization of the appearance of the Spreadsheet component by applying CSS classes to its root element. The property can be used to add custom styles or override default styles.

    DataSource

    Gets or sets the data source items to be used by the spreadsheet component. This property is used to render the Spreadsheet data while loading the component. It accepts byte arrays that can be generated from a file path or a base64 string.

    Declaration
    public byte[] DataSource { get; set; }
    Property Value
    Type Description
    System.Byte[]

    A byte array (byte[]) representing the data from an Excel sheet. This byte array is processed and rendered in the UI.

    Remarks

    The DataSource property accepts a byte array that can be generated from:

    1. A base64 string converted to byte array
    2. A file path by reading the file as bytes This property is used to render the Spreadsheet data while loading the component, allowing users to interact with Excel data directly in the Blazor application.
    Examples
    <SfSpreadsheet DataSource="DataSourceBytes"></SfSpreadsheet>
    @code {
        private byte[] DataSourceBytes { get; set; }
    
        protected override async Task OnInitializedAsync() {
        {
                // Method 1: Reading from a file path
                string filePath = "D:/files/datasource.xlsx";
                DataSourceBytes = File.ReadAllBytes(filePath);
    
                // Method 2: Converting base64 string to byte array
                string base64String = "base64StringFromServer";
                DataSourceBytes = Convert.FromBase64String(base64String);
        }
    }

    EnableClipboard

    Gets or sets a value indicating whether clipboard operations (cut, copy, and paste) are enabled in the Syncfusion.Blazor.Spreadsheet.

    Declaration
    public bool EnableClipboard { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if clipboard operations are enabled; otherwise, false. The default value is true.

    Remarks

    This property controls the availability of clipboard operations within the Spreadsheet. When set to true:

    • User can cut cells or ranges, copying their content to the clipboard and removing it from the source.
    • User can copy cells or ranges to the clipboard without affecting the source.
    • User can paste content from the clipboard into the Spreadsheet.
    • Clipboard operations are available through both user interface (e.g., context menus, keyboard shortcuts) and programmatic methods.

    When set to false:

    • All clipboard operations (cut, copy, and paste) are disabled.
    • Clipboard-related options have been removed from the context menu and disabled in the ribbon, modifying the user interface.
    • Standard keyboard shortcuts for clipboard operations (e.g., Ctrl+X, Ctrl+C, Ctrl+V) are non-functional within the Spreadsheet.
    • Attempts to perform clipboard operations programmatically are not supported.

    EnableContextMenu

    Gets or sets a value indicating whether the context menu option is enabled for the spreadsheet.

    Declaration
    public bool EnableContextMenu { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if the context menu is enabled; otherwise, false. The default value is true.

    Remarks

    When enabled, the context menu will be available for the following elements:

    • Row headers
    • Column headers
    • Sheet tabs
    • Cells
    Disabling this property will remove the context menu from all these elements.

    Height

    Gets or sets the height of the entire Syncfusion.Blazor.Spreadsheet component.

    Declaration
    public string Height { get; set; }
    Property Value
    Type Description
    System.String

    A string representing any valid CSS height value (e.g., "500px", "50vh", "100%"). The default value is auto.

    Remarks

    This property defines the vertical size of the spreadsheet component.

    Usage examples:

    • Set to a fixed pixel value: "500px"
    • Set to a percentage of the viewport height: "50vh"
    • Set to fill the parent container: "100%"
    • Allow the component to determine its own height: "auto"

    ID

    Gets or sets the unique identifier for the Syncfusion.Blazor.Spreadsheet component.

    Declaration
    public string ID { get; set; }
    Property Value
    Type Description
    System.String

    A string representing the unique ID of the component. A random ID is generated by default.

    Remarks

    The ID property allows you to set a custom ID for the spreadsheet component in your Blazor application. This ID can be useful for targeting the spreadsheet in JavaScript operations (e.g., DOM manipulation, event handling) or for applying custom CSS styles. If no value is explicitly set, a random ID is automatically generated and used.

    RowCount

    Gets or sets the number of rows to be rendered in the Syncfusion.Blazor.Spreadsheet.

    Declaration
    public int RowCount { get; set; }
    Property Value
    Type Description
    System.Int32

    An integer representing the number of rows. The default value is 1000.

    Remarks

    The RowCount property determines the number of rows that will be rendered in the Spreadsheet. This affects the vertical size of the sheet and the amount of data that can be displayed at once.

    Important considerations:

    • When no data is provided, an empty sheet is rendered based on this value.
    • When data is provided (via byte array or imported file), additional empty rows are rendered to meet this count if necessary.
    • This property is used to implement finite scrolling, limiting the rendering of unnecessary empty cells.

    Adjusting this property impacts the rendering behavior and can affect performance. It's recommended to set it to a value that balances the amount of data to be displayed and the performance requirements of the application.

    ShowFormulaBar

    Gets or sets a value indicating whether the formula bar is displayed in the Syncfusion.Blazor.Spreadsheet.

    Declaration
    public bool ShowFormulaBar { get; set; }
    Property Value
    Type Description
    System.Boolean

    A System.Boolean indicating whether the formula bar is shown. The default value is true.

    Remarks

    This property controls the visibility of the formula bar in the spreadsheet.

    When set to true, the formula bar is displayed, allowing users to view and edit cell formulas and values.

    When set to false, the formula bar is hidden, potentially simplifying the user interface for scenarios where formula editing is not required.

    The formula bar provides a dedicated area for viewing and editing cell contents, particularly useful when working with complex formulas.

    Width

    Gets or sets the width of the entire Syncfusion.Blazor.Spreadsheet component.

    Declaration
    public string Width { get; set; }
    Property Value
    Type Description
    System.String

    A string representing any valid CSS width value (e.g., "100%", "800px", "75vw"). The default value is auto.

    Remarks

    This property defines the horizontal size of the spreadsheet component.

    Usage examples:

    • Set to fill the parent container: "100%"
    • Set to a fixed pixel value: "800px"
    • Set to a percentage of the viewport width: "75vw"
    • Allow the component to determine its own width: "auto"

    Methods

    AddHyperlinkAsync(String, String, String)

    Adds a hyperlink to a specified cell or range of cells in the spreadsheet.

    Declaration
    public Task AddHyperlinkAsync(string cellAddress, string uri, string displayText = null)
    Parameters
    Type Name Description
    System.String cellAddress

    The address of the cell or range of cells where the hyperlink will be inserted. This can be:

    System.String uri

    The URI representing either a web address or a cell reference. This can point to an external website or to a specific cell within the same sheet or across different sheets.

    System.String displayText

    The text to be displayed in the cell. This is an optional parameter. If not provided, the cell's existing value will be used as the display text. If the cell is empty, the hyperlink URL will be used as the display text by default.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous operation of adding the hyperlink to the specified cell or range.

    Remarks

    The method allows adding a hyperlink to a specified cell or range of cells in the spreadsheet.

    • The cellAddress parameter determines the location where the hyperlink will be added, using standard cell notation (e.g., "A1") or an explicit sheet reference (e.g., "Sheet1!A1").
    • The uri parameter defines the link target. It can be a URL or a reference to another cell, either within the same sheet or on a different sheet.
    • The optional displayText parameter allows specifying custom display text. If omitted, the existing cell value will be used; if the cell is empty, the hyperlink itself will be displayed as the text.

    This operation requires the AllowHyperlink property to be set to true. If AllowHyperlink is set to false, this method will not add hyperlinks to the spreadsheet.

    Sheet protection affects hyperlink insertion. If the sheet is protected, hyperlinks can only be added if:

    • The "Insert Hyperlinks" option is checked in the Sheet Protection Options dialog
    • The target cell or range is in an unlocked area of the protected sheet

    The method will validate the sheet name and cell address before adding any hyperlink. If an invalid sheet name or cell address is provided, the hyperlink will not be added, and no error will be thrown.

    Examples
    // Example: Adding a hyperlink to a cell with a custom display text.
    await spreadsheet.AddHyperlinkAsync("A4", "https://example.com", "Click here");
    
    // Example: Adding a hyperlink to another sheet within the same spreadsheet.
    await spreadsheet.AddHyperlinkAsync("Sheet2!B2", "https://example.com");
    
    // Example: Adding a hyperlink without specifying display text (will use the cell value or hyperlink as the display text).
    await spreadsheet.AddHyperlinkAsync("A8", "https://example.com");
    
    // Example: Adding a hyperlink to a range of cells.
    await spreadsheet.AddHyperlinkAsync("A1:A5", "https://example.com", "Range Link");
    
    // Example: Setting AllowHyperlink property
    spreadsheet.AllowHyperlink = true; // Enable hyperlinks
    await spreadsheet.AddHyperlinkAsync("A10", "https://example.com", "Enabled Link");
    
    spreadsheet.AllowHyperlink = false; // Disable hyperlinks
    // This call won't add a hyperlink because AllowHyperlink is false
    await spreadsheet.AddHyperlinkAsync("A11", "https://example.com", "This won't work");        

    AutofillAsync(String, String)

    Performs an auto-fill operation in the active sheet.

    Declaration
    public Task AutofillAsync(string fillRange, string dataRange = null)
    Parameters
    Type Name Description
    System.String fillRange

    The address of the range to fill. This must be a valid cell range address (e.g., "A1:A10").

    System.String dataRange

    The address of the range containing the data to use for filling. If null, the active cell is used as the data source.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous auto-fill operation.

    Remarks

    This method performs the auto-fill operation and refreshes the content of the spreadsheet after completion.

    The method will not perform the operation if any of these conditions are met:

    • The worksheet is password protected
    • The range is outside the worksheet boundaries
    • Invalid range addresses are provided
    • The AllowAutofill property is set to false
    • If fillRange and dataRange are in lowercase like this a1:a1
    Examples
    <SfButton OnClick="AutofillHandler" Content="Auto Fill"></SfButton>
    <SfSpreadsheet @ref="@SpreadsheetInstance"></SfSpreadsheet>
    
    @code {
        public SfSpreadsheet SpreadsheetInstance { get; set; }
    
        public async Task AutofillHandler()
        {
            // Auto-fills the range A1:A10 downward using the value from cell A1.
            await SpreadsheetInstance.AutofillAsync("A1:A10", "A1");
    
            // Auto-fills the range B1:E1 rightward using the value from cell B1.
            await SpreadsheetInstance.AutofillAsync("B1:E1", "B1");
    
    
            // Uses the active cell as the data source with default direction (Down)
            await SpreadsheetInstance.AutofillAsync("C1:C10");
        }
    }

    BuildRenderTree(RenderTreeBuilder)

    Declaration
    protected override void BuildRenderTree(RenderTreeBuilder __builder)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder

    ClearAllFiltersAsync()

    Clears all filters applied to the active sheet.

    Declaration
    public Task ClearAllFiltersAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    A task representing the asynchronous clear all filters operation.

    Remarks

    This method removes all filters applied to any column in the active worksheet.

    After clearing all filters, it updates the user interface to show all previously hidden rows.

    This method will not work if the AllowFiltering property is set to false.

    This method will not work if the sheet is protected and the Filter option is disabled in sheet protection options.

    Examples
    <SfButton OnClick="ClearAllFilters" Content="Clear All Filters"></SfButton>
    <SfSpreadsheet @ref="@SpreadsheetInstance"></SfSpreadsheet>
    @code {
        public SfSpreadsheet SpreadsheetInstance { get; set; }
    
        public async Task ClearAllFilters()
        {
            await SpreadsheetInstance.ClearAllFiltersAsync();
        }
    }

    ClearFilterAsync(Int32)

    Clears the filter applied to a specific column in the active sheet.

    Declaration
    public Task ClearFilterAsync(int columnIndex)
    Parameters
    Type Name Description
    System.Int32 columnIndex

    The zero-based index of the column whose filter is to be cleared.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A task representing the asynchronous clear filter operation.

    Remarks

    This method removes any filters applied to the specified column index in the active sheet.

    After clearing the filter, it updates the user interface to show previously hidden rows.

    This method will not work if the AllowFiltering property is set to false.

    This method will not work if the sheet is protected and the Filter option is disabled in sheet protection options.

    Examples
    <SfButton OnClick="ClearColumnFilter" Content="Clear Filter"></SfButton>
    <SfSpreadsheet @ref="@SpreadsheetInstance"></SfSpreadsheet>
    @code {
        public SfSpreadsheet SpreadsheetInstance { get; set; }
    
        public async Task ClearColumnFilter()
        {
            // Clear filter from Column A (Index = 0).
            await SpreadsheetInstance.ClearFilterAsync(0);
        }
    }

    CopyCellAsync(String)

    Copies the specified cell or range and its properties, such as value, format, style, etc., to the clipboard asynchronously. This operation will not work if the sheet is protected or if the EnableClipboard property is set to false.

    Declaration
    public Task CopyCellAsync(string cellAddress = "")
    Parameters
    Type Name Description
    System.String cellAddress

    The address of the cell or range to be copied. The parameter accepts various formats:

    - Single cell reference (e.g., "A1")

    - Cell range (e.g., "A1:B5")

    - Sheet-specific reference (e.g., "Sheet1!A1" or "Sheet2!A1:C5")

    If no address is provided, the last selected range will be used. If no range was previously selected, the active cell will be copied.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task that represents the asynchronous copy operation.

    Remarks

    This method will not work if the sheet is protected or if the EnableClipboard property is set to false.

    When calling without a cell address parameter, the operation uses the last selected range. If no selection exists, it defaults to the active cell.

    This operation will not execute if invalid cell references or out-of-boundary ranges are provided. Ensure all cell addresses are within the valid worksheet boundaries.

    Examples

    The following example demonstrates how to copy cells in a spreadsheet:

    <SfSpreadsheet @ref="@SpreadsheetInstance"></SfSpreadsheet>
    
    @code {
        public List<Order> Orders { get; set; }
        public SfSpreadsheet SpreadsheetInstance { get; set; }
    
        public async Task CopyActiveCell()
        {
            // To copy from the current cell.
            await SpreadsheetInstance.CopyCellAsync();
        }
    
        public async Task CopyValues()
        {
            // To copy from the specified cell.
            await SpreadsheetInstance.CopyCellAsync("A2");
        }
    
        public async Task CopyCell()
        {
            // The address, along with the sheet name, to be copied.
            await SpreadsheetInstance.CopyCellAsync("Sheet1!B2");
        }
    
        public async Task CopyRange()
        {
            // To copy a range of cells.
            await SpreadsheetInstance.CopyCellAsync("A1:D10");
        }
    
        public async Task CopyRangeFromSpecificSheet()
        {
            // To copy a range from a specific sheet.
            await SpreadsheetInstance.CopyCellAsync("Sheet2!B3:E8");
        }
    }

    CutCellAsync(String)

    Cuts the specified cell or range and its properties, such as value, format, style, etc., to the clipboard asynchronously. This operation will not work if the sheet is protected or if the EnableClipboard property is set to false.

    Declaration
    public Task CutCellAsync(string cellAddress = "")
    Parameters
    Type Name Description
    System.String cellAddress

    The address of the cell or range to be cut. The parameter accepts various formats:

    - Single cell reference (e.g., "A1")

    - Cell range (e.g., "A1:B5")

    - Sheet-specific reference (e.g., "Sheet1!A1" or "Sheet2!A1:C5")

    If no address is provided, the last selected range will be used. If no range was previously selected, the active cell will be cut.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task that represents the asynchronous cut operation.

    Remarks

    This method will not work if the sheet is protected or if the EnableClipboard property is set to false.

    When calling without a cell address parameter, the operation uses the last selected range. If no selection exists, it defaults to the active cell.

    This operation will not execute if invalid cell references or out-of-boundary ranges are provided. Ensure all cell addresses are within the valid worksheet boundaries.

    Examples
    <SfSpreadsheet @ref="@SpreadsheetInstance"></SfSpreadsheet>
    @code {
        public List<Order> Orders { get; set; }
        public SfSpreadsheet SpreadsheetInstance { get; set; }
    
        public async Task CutActiveCell()
        {
            // To cut from the current cell.
            await SpreadsheetInstance.CutCellAsync();
        }
        public async Task CutValues()
        {
            // To cut from the specified cell.
            await SpreadsheetInstance.CutCellAsync("A2");
        }
        public async Task CutCell()
        {
            // The address, along with the sheet name, to be cut.
            await SpreadsheetInstance.CutCellAsync("Sheet1!B2");
        }
        public async Task CutRange()
        {
            // To cut a range of cells.
            await SpreadsheetInstance.CutCellAsync("A1:D10");
        }
        public async Task CutRangeFromSpecificSheet()
        {
            // To cut a range from a specific sheet.
            await SpreadsheetInstance.CutCellAsync("Sheet2!B3:E8");
        }
    }

    DeleteSheetAsync(Nullable<Int32>)

    Deletes a worksheet at the specified index from the spreadsheet. If no index is specified, deletes the active sheet.

    Declaration
    public Task DeleteSheetAsync(Nullable<int> sheetIndex = null)
    Parameters
    Type Name Description
    System.Nullable<System.Int32> sheetIndex

    The zero-based index of the worksheet to delete. If null, the currently active sheet will be deleted.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous operation of deleting the specified worksheet.

    Remarks

    This method performs the following operations:

    If the specified sheet index is invalid, the method returns without performing any operation.

    If there is only one sheet in the spreadsheet, the deletion will not proceed to ensure at least one sheet always remains.

    Additionally, if the workbook is protected, the sheet deletion operation will not be performed.

    Examples
    <SfButton OnClick="DeleteSheetHandler" Content="Delete Current Sheet"></SfButton>
    <SfSpreadsheet @ref="@SpreadsheetInstance"></SfSpreadsheet>
    
    @code {
        public SfSpreadsheet SpreadsheetInstance { get; set; }
    
        public async Task DeleteSheetHandler()
        {
            // Delete the active sheet.
            await SpreadsheetInstance.DeleteSheetAsync();
        }
    
        public async Task DeleteSpecificSheetHandler()
        {
            // Delete the sheet at index 2 (the third sheet).
            await SpreadsheetInstance.DeleteSheetAsync(2);
        }
    }

    DeleteSheetAsync(String)

    Deletes a worksheet with the specified name from the spreadsheet. If the specified sheet is the only worksheet in the spreadsheet, the deletion will not proceed to maintain at least one worksheet at all times.

    Declaration
    public Task DeleteSheetAsync(string sheetName)
    Parameters
    Type Name Description
    System.String sheetName

    The name of the worksheet to delete. Case-insensitive comparison is used to find the matching worksheet.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous operation of deleting the specified worksheet.

    Remarks

    This method performs the following operations:

    If the sheet name is not found, the method returns without performing any operation.

    If there is only one sheet in the spreadsheet, the deletion will not proceed to ensure at least one sheet always remains.

    Additionally, if the workbook is protected, the sheet deletion operation will not be performed.

    Examples
    <SfButton OnClick="DeleteNamedSheetHandler" Content="Delete Sheet"></SfButton>
    <SfSpreadsheet @ref="@SpreadsheetInstance"></SfSpreadsheet>
    
    @code {
        public SfSpreadsheet SpreadsheetInstance { get; set; }
    
        public async Task DeleteNamedSheetHandler()
        {
            // Delete a sheet by name.
            await SpreadsheetInstance.DeleteSheetAsync("Sheet1");
        }
    }

    DuplicateSheetAsync(Nullable<Int32>)

    Duplicates a sheet in the spreadsheet, creating an exact copy with a sequential naming convention.

    Declaration
    public Task DuplicateSheetAsync(Nullable<int> sheetIndex = null)
    Parameters
    Type Name Description
    System.Nullable<System.Int32> sheetIndex

    The zero-based index position of the sheet to duplicate within the spreadsheet's sheet collection. If null, the currently active sheet will be duplicated.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous operation of duplicating the sheet.

    Remarks

    This method creates an exact copy of the specified sheet, including all data, formatting, formulas, and styling. The duplicated sheet is inserted immediately after the original sheet in the sheet collection.

    If the specified sheet index is out of range, the operation will fail silently. Ensure the index is within the valid range of existing sheets before calling this method.

    This operation will not be performed if the workbook is protected. Sheet duplication is disabled when workbook protection is enabled.

    Examples

    The following example demonstrates how to duplicate sheets in a spreadsheet component:

    <SfButton OnClick="DuplicateActiveSheet" Content="Duplicate Active Sheet"></SfButton>
    <SfSpreadsheet @ref="@SpreadsheetInstance"></SfSpreadsheet>
    @code {
        public SfSpreadsheet SpreadsheetInstance { get; set; }
    
        // Duplicate the currently active sheet
        private async Task DuplicateActiveSheet()
        {
            // Duplicates the active sheet.
            await SpreadsheetInstance.DuplicateSheetAsync();
        }
    
        // Duplicate a specific sheet by index
        private async Task DuplicateSpecificSheet()
        {
            // Duplicates the first sheet.
            await SpreadsheetInstance.DuplicateSheetAsync(0);
        }
    }

    DuplicateSheetAsync(String)

    Duplicates a sheet in the spreadsheet by its name, creating an exact copy with a sequential naming convention. The duplicated sheet preserves all content, formatting, formulas, and visual elements of the original.

    Declaration
    public Task DuplicateSheetAsync(string sheetName)
    Parameters
    Type Name Description
    System.String sheetName

    The name of the sheet to duplicate within the spreadsheet's sheet collection. The sheet name matching is case-insensitive.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous operation of duplicating the sheet.

    Remarks

    This method creates an exact copy of the specified sheet identified by its name, including all data, formatting, formulas, and styling. The duplicated sheet is inserted immediately after the original sheet in the sheet collection.

    If the specified sheet name does not exist in the spreadsheet, the operation will fail silently. Ensure the sheet name exists before calling this method.

    This operation will not be performed if the workbook is protected. Sheet duplication is disabled when workbook protection is enabled.

    Examples

    The following example demonstrates how to duplicate a sheet by name in a spreadsheet component:

    <SfButton OnClick="DuplicateSheetHandler" Content="Duplicate Sheet"></SfButton>
    <SfSpreadsheet @ref="@SpreadsheetInstance"></SfSpreadsheet>
    @code {
        public SfSpreadsheet SpreadsheetInstance { get; set; }
    
        private async Task DuplicateSheetHandler()
        {
            // Duplicate a sheet by name.
            await SpreadsheetInstance.DuplicateSheetAsync("Sheet1");
        }
    }

    FilterByCellValueAsync(String, Object)

    Asynchronously filters a column in the active sheet based on a specific cell value. This method filters using the specified cell address as the filter criteria.

    Declaration
    public Task FilterByCellValueAsync(string cellAddress, object cellValue)
    Parameters
    Type Name Description
    System.String cellAddress

    The address of the cell that contains the filter criteria. This must be a valid cell address (e.g., "A1").

    System.Object cellValue

    The value to filter by. This must not be null.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous filter operation.

    Remarks

    This method applies a filter to the column specified by cellAddress using the provided cellValue.

    If no filter range is defined, it automatically sets the filter range to the used range of the worksheet.

    The filter operation will not proceed under the following conditions:

    • The AllowFiltering property is set to false.
    • If cellAddress is null, empty, or contains spaces.
    • If cellValue is null.
    • If the cell reference part of cellAddress is in lowercase (e.g., "a1").
    • If the value at cellAddress does not match cellValue.
    • If the cell address is outside valid worksheet boundaries.
    • If the worksheet is password-protected and filtering is not allowed for the specified range.
    • Multiple non-contiguous ranges are selected
    Examples
    <SfButton OnClick="ApplyFilter" Content="Filter by Value"></SfButton>
    <SfSpreadsheet @ref="@SpreadsheetInstance"></SfSpreadsheet>
    @code {
        public SfSpreadsheet SpreadsheetInstance { get; set; }
    
        public async Task ApplyFilter()
        {
            // Applies a filter to Column A, displaying rows that contain the value "New York".
            await SpreadsheetInstance.FilterByCellValueAsync("A1", "New York");
        }
    }

    InsertColumnAsync(Int32, Int32, Object, ColumnPosition)

    Represents a method that inserts columns at the specified position in the SfSpreadsheet.

    Declaration
    public Task InsertColumnAsync(int columnIndex, int count, object sheet = null, ColumnPosition position)
    Parameters
    Type Name Description
    System.Int32 columnIndex

    The zero-based index where the columns should be inserted. If position is Right, columns will be inserted after this index. If position is Left, columns will be inserted at this index.

    System.Int32 count

    The number of columns to insert. Must be greater than zero.

    System.Object sheet

    The target worksheet where columns will be inserted. Accepts either a sheet index (integer) or sheet name (string). sheet name is case-insensitive If null, the active sheet will be used. When using an index, note that it is zero-based (i.e., the first sheet is index 0).

    ColumnPosition position

    Specifies the position relative to columnIndex where columns should be inserted. Valid values are Right or Left. The default value is Right.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous operation of inserting columns.

    Remarks

    This method inserts the specified number of columns at the given position in the spreadsheet. When columns are inserted:

    • Existing columns at and after the insertion point are shifted to the right
    • Cell references, formulas, and formatting are automatically updated to reflect the new column positions
    • Selection is maintained and adjusted based on the insertion position

    Sheet protection affects column insertion. If the sheet is protected, columns can only be inserted if:

    • The "Insert Columns" is enabled in the sheet protection options
    • Otherwise, the operation will be silently ignored

    The method validates the sheet, columnIndex, and column count before performing any operation:

    • If the column count is less than or equal to zero, the method will return without performing any operation
    • If the column index is negative or exceeds the available columns, or the sheet index is out of range, the operation will be silently ignored without throwing an error

    For performance considerations, it is recommended to keep the columnCount value as low as possible when inserting multiple columns.

    Examples
    <SfButton OnClick="InsertColumnsHandler" Content="Insert Columns"></SfButton>
    <SfSpreadsheet @ref="@SpreadsheetInstance"></SfSpreadsheet>
    
    @code {
        public SfSpreadsheet SpreadsheetInstance;
    
        public async Task InsertColumnsHandler()
        {
            // Insert 2 columns to the right of column index 2
            await SpreadsheetInstance.InsertColumnAsync(2, 2);
    
            // Insert 3 columns to the left of column index 5
            await SpreadsheetInstance.InsertColumnAsync(5, 3, null, ColumnPosition.Left);
    
            // Insert 1 column to the right of column B in Sheet2
            await SpreadsheetInstance.InsertColumnAsync(1, 1, "Sheet2", ColumnPosition.Right);
    
            // Insert 4 columns to the left of column D in the sheet at index 3
            await SpreadsheetInstance.InsertColumnAsync(3, 4, 3, ColumnPosition.Left);
        }
    }

    InsertRowAsync(Int32, Int32, Object, RowPosition)

    Inserts rows in the spreadsheet at a specified index, either above or below the target row.

    Declaration
    public Task InsertRowAsync(int rowIndex, int count, object sheet = null, RowPosition position)
    Parameters
    Type Name Description
    System.Int32 rowIndex

    The zero-based index where the rows should be inserted. If position is Below, rows will be inserted after this index. If position is Above, rows will be inserted at this index.

    System.Int32 count

    The number of rows to insert. Must be greater than zero.

    System.Object sheet

    The target worksheet where rows will be inserted. Accepts either a sheet index (integer) or sheet name (string). sheet name is case-insensitive. If null, the active sheet will be used. When using an index, note that it is zero-based (i.e., the first sheet is index 0).

    RowPosition position

    Specifies the position relative to rowIndex where rows should be inserted. Valid values are Above or Below. The default value is Above.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous operation of inserting rows.

    Remarks

    This method inserts the specified number of rows at the given position in the spreadsheet. When rows are inserted:

    • Existing rows at and after the insertion point are shifted downward
    • Cell references, formulas, and formatting are automatically updated to reflect the new row positions
    • Selection is maintained and adjusted based on the insertion position

    Sheet protection affects row insertion. If the sheet is protected, rows can only be inserted if:

    • The "Insert Rows" option is enabled in the sheet protection
    • Otherwise, the row insertion will be silently ignored

    The method validates the sheet index, row index, and row count before performing any operation:

    • If the row count is less than or equal to zero, the method will return without performing any operation
    • If the row index is negative or exceeds the available rows, or the sheet index is out of range, the operation will be silently ignored without throwing an error

    For performance considerations, it is recommended to keep the count value as low as possible when inserting multiple rows.

    Examples
    <SfButton OnClick="InsertRowsHandler" Content="Insert Rows"></SfButton>
    <SfSpreadsheet @ref="@SpreadsheetInstance"></SfSpreadsheet>
    
    @code {
        public SfSpreadsheet SpreadsheetInstance;
    
        public async Task InsertRowsHandler()
        {
            // Insert 2 rows above row index 0 in the active sheet
            await SpreadsheetInstance.InsertRowAsync(0, 2);
    
            // Insert 3 rows below row index 2 in the sheet named "Sheet2"
            await SpreadsheetInstance.InsertRowAsync(2, 3, "Sheet2", RowPosition.Below);
    
            // Insert 1 row above row index 1 in the active sheet
            await SpreadsheetInstance.InsertRowAsync(1, 1, null, RowPosition.Above);
    
            // Insert 4 rows below row index 3 in the sheet at index 3
            await SpreadsheetInstance.InsertRowAsync(3, 4, 3, RowPosition.Below);
        }
    }

    InsertSheetAsync(Int32, String)

    Inserts a new sheet at the specified index with a custom name.

    Declaration
    public Task InsertSheetAsync(int index, string sheetName)
    Parameters
    Type Name Description
    System.Int32 index

    The zero-based index at which to insert the new sheet. If this index is greater than the worksheet count, the method returns without performing any operation.

    System.String sheetName

    The name for the newly inserted sheet. This name will be assigned to the worksheet when created.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous insert sheet operation.

    Remarks

    This method provides a way to insert a new worksheet at a specific position with a predefined name, rather than using the default naming convention.

    If the index is negative, the method returns without performing any operation.

    This operation will not be executed if the workbook is protected. Sheet insertion is disabled when workbook protection is enabled.

    Examples
    <SfButton OnClick="InsertNamedSheetHandler" Content="Insert Named Sheet"></SfButton>
    <SfSpreadsheet @ref="@SpreadsheetInstance"></SfSpreadsheet>
    
    @code {
        public SfSpreadsheet SpreadsheetInstance { get; set; }
    
        public async Task InsertNamedSheetHandler()
        {
            // Insert a sheet at index 4 (the 5th position) with a custom name
            await SpreadsheetInstance.InsertSheetAsync(4, "My New Sheet Name");
        }
    }

    InsertSheetAsync(Nullable<Int32>, Int32)

    Inserts one or more new sheets in the spreadsheet.

    Declaration
    public Task InsertSheetAsync(Nullable<int> index = null, int count = 1)
    Parameters
    Type Name Description
    System.Nullable<System.Int32> index

    The zero-based index at which to start inserting new sheets. If null, new sheets will be added after the active sheet.

    System.Int32 count

    The number of sheets to insert. The default value is 1.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous insert sheet operation.

    Remarks

    This method inserts the specified number of sheets starting at the given zero-based index. If the index is greater than the total number of worksheets or is negative, the method returns without performing any operation.

    If the count is negative or equals to zero, the method returns without performing any operation.

    This operation will not be executed if the workbook is protected. Sheet insertion is disabled when workbook protection is enabled.

    Examples
    <SfButton OnClick="InsertSheetHandler" Content="Insert New Sheets"></SfButton>
    <SfSpreadsheet @ref="@SpreadsheetInstance"></SfSpreadsheet>
    @code {
        public SfSpreadsheet SpreadsheetInstance { get; set; }
    
        public async Task InsertSheetHandler()
        {
            await SpreadsheetInstance.InsertSheetAsync(2, 4);
        }
    }

    MoveSheetAsync(Nullable<Int32>, Int32)

    Moves a sheet to a new position within the spreadsheet's sheet collection.

    Declaration
    public Task MoveSheetAsync(Nullable<int> sourceIndex, int destinationIndex)
    Parameters
    Type Name Description
    System.Nullable<System.Int32> sourceIndex

    The zero-based index position of the sheet to move within the spreadsheet's sheet collection. If the value is null, currently active sheet will be moved.

    System.Int32 destinationIndex

    The zero-based index position where the sheet should be moved to within the sheet collection. Must be a valid index within the range of existing sheets and not be a hidden sheet.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous operation.

    Remarks

    This method repositions a sheet within the spreadsheet's sheet collection without modifying the sheet's content, formatting, or properties. The sheet maintains all its data, formulas, and styling after the move operation.

    If the source index is out of range or the destination index is invalid, the operation will fail silently. Ensure both indices are within the valid range of existing sheets before calling this method. The destination index should account for the removal of the source sheet during the move operation.

    The method will not perform any action if the source and destination indexes are the same. Additionally, if the workbook is protected, this method will not work.

    Examples

    The following example demonstrates how to move sheets to different positions in a spreadsheet component:

    <SfButton OnClick="MoveActiveSheetToFirst" Content="Move Active Sheet to First"></SfButton>
    <SfButton OnClick="MoveSpecificSheet" Content="Move Second Sheet to Last"></SfButton>
    <SfSpreadsheet @ref="SpreadsheetInstance"></SfSpreadsheet>
    
    @code {
        public SfSpreadsheet SpreadsheetInstance;
    
        // Move the currently active sheet to the first position
        private async Task MoveActiveSheetToFirst()
        {
            await SpreadsheetInstance.MoveSheetAsync(null, 0);
        }
    
        // Move a specific sheet by index to a new position
        private async Task MoveSpecificSheet()
        {
            // Moves sheet at index 1 to index 2
            await SpreadsheetInstance.MoveSheetAsync(1, 2);
        }
    }

    MoveSheetAsync(String, String)

    Moves a sheet to a new position within the SfSpreadsheet component's sheet collection by sheet names.

    Declaration
    public Task MoveSheetAsync(string sourceSheetName, string destinationSheetName)
    Parameters
    Type Name Description
    System.String sourceSheetName

    The name of the sheet to move within the spreadsheet's sheet collection. The sheet name comparison is case-insensitive and not be a hidden sheet.

    System.String destinationSheetName

    The name of the sheet that will serve as the position reference. The source sheet will be moved to the position immediately after this destination sheet. The sheet name comparison is case-insensitive and not be a hidden sheet.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous operation.

    Remarks

    This method repositions a sheet within the spreadsheet's sheet collection by using sheet names instead of indices. The source sheet maintains all its data, formulas, and styling after the move operation.

    The method locates both sheets by their names and calculates the appropriate indices for the move operation. The source sheet will be positioned immediately after the destination sheet in the sheet collection.

    If either sheet name does not exist in the spreadsheet, the operation will fail silently. Sheet name comparisons are case-insensitive, so "Sheet1" will match "SHEET1" or "sheet1".

    The method will not perform any action if the source and destination sheet names refer to the same sheet. Additionally, if the workbook is protected, this method will not work.

    Examples

    The following example demonstrates how to move sheets by name in a spreadsheet component:

    <SfButton OnClick="MoveSheetByName" Content="Move Sales Sheet After Summary"></SfButton>
    <SfSpreadsheet @ref="spreadsheet"></SfSpreadsheet>
    
    @code {
        SfSpreadsheet spreadsheet;
    
        // Move a sheet by name to position after another named sheet
        private async Task MoveSheetByName()
        {
            // Moves "Sales Data" after "Summary"
            await spreadsheet.MoveSheetAsync("Sheet1", "Sheet3");
        }
    }

    OnInitializedAsync()

    Initializes the component asynchronously.

    Declaration
    protected override Task OnInitializedAsync()
    Returns
    Type
    System.Threading.Tasks.Task

    PasteCellAsync(String)

    Pastes the clipboard content into the specified cell or range asynchronously. This operation will not work if the sheet is protected or if the EnableClipboard property is set to false.

    Declaration
    public Task PasteCellAsync(string cellAddress = "")
    Parameters
    Type Name Description
    System.String cellAddress

    The address of the cell where the content will be pasted. The parameter accepts various formats:

    - Single cell reference (e.g., "A1")

    - Sheet-specific reference (e.g., "Sheet1!A1")

    - Range reference (e.g., "A1:C3")

    If no address is provided, the last selected range will be used. If no range was previously selected, the active cell will be used as the paste destination.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task that represents the asynchronous paste operation.

    Remarks

    This method will not work if the sheet is protected or if the EnableClipboard property is set to false.

    When calling without a cell address parameter, the operation uses the last selected range. If no selection exists, it defaults to the active cell.

    When pasting between sheets, the operation does not require switching to the destination sheet first. Simply specify the target sheet in the cell address parameter.

    If the copied range is larger than the specified paste range, all copied content will still be pasted, expanding beyond the specified range as needed - mimicking Excel's behavior.

    The paste operation will not execute if invalid cell references or out-of-boundary ranges are provided. Ensure all cell addresses are within the valid worksheet boundaries.

    Examples

    The following example demonstrates how to paste content in a spreadsheet:

    <SfSpreadsheet @ref="@SpreadsheetInstance"></SfSpreadsheet>
    
    @code {
        public List<Order> Orders { get; set; }
        public SfSpreadsheet SpreadsheetInstance { get; set; }
    
        public async Task PasteActiveCell()
        {
            // To paste to the current cell.
            await SpreadsheetInstance.PasteCellAsync();
        }
    
        public async Task PasteValues()
        {
            // To paste to the specified cell.
            await SpreadsheetInstance.PasteCellAsync("A2");
        }
    
        public async Task PasteCell()
        {
            // The address, along with the sheet name, to be pasted.
            await SpreadsheetInstance.PasteCellAsync("Sheet1!B2");
        }
    
        // Scenario 1: Copy from one sheet and paste to another without switching sheets
        public async Task CopyBetweenSheets()
        {
            // Copy value from Sheet1
            await SpreadsheetInstance.CopyCellAsync("Sheet1!A1:A5");
    
            // Paste to Sheet2 without switching to it
            await SpreadsheetInstance.PasteCellAsync("Sheet2!C3");
        }
    
        // Scenario 2: Copy a large range and paste to smaller range
        public async Task CopyLargerRangeThanTarget()
        {
            // Copy a 7-row range
            await SpreadsheetInstance.CopyCellAsync("F3:F9");
    
            // Paste to a smaller 3-row range
            // All 7 rows will be pasted, extending beyond the specified range
            await SpreadsheetInstance.PasteCellAsync("A5:A7");
        }
    }

    ReapplyFiltersAsync()

    Reapplies all existing filters in the active sheet.

    Declaration
    public Task ReapplyFiltersAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    A task that represents an asynchronous re-filtering operation.

    Remarks

    This method reapplies all filters that have been previously set in the active worksheet.

    It's useful when data has changed and you need to update the filter results without changing the filter criteria.

    The method performs the following operations:

    If the AllowFiltering property is set to false, this method will have no effect.

    The method has no effect when there are no active filters in the worksheet.

    This method will not work if the sheet is protected and the Filter option is disabled in sheet protection options.

    Examples
    <SfButton OnClick="ReapplyFilters" Content="Reapply Filters"></SfButton>
    <SfSpreadsheet @ref="@SpreadsheetInstance"></SfSpreadsheet>
    @code {
        public SfSpreadsheet SpreadsheetInstance { get; set; }
    
        public async Task ReapplyFilters()
        {
            await SpreadsheetInstance.ReapplyFiltersAsync();
        }
    }

    RemoveHyperlinkAsync(String)

    Removes hyperlinks from a specified cell or range of cells in the spreadsheet.

    Declaration
    public Task RemoveHyperlinkAsync(string cellAddress)
    Parameters
    Type Name Description
    System.String cellAddress

    The address of the cell or range of cells from which the hyperlinks should be removed. This can be:

    • A single cell reference, such as "A5" or "A100"
    • A cell in another sheet, for example, "Sheet3!A10"
    • A range of cells, such as "A1:A200" or "Sheet3!A10:A1000"
    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous operation of removing the hyperlinks from the specified cell or range.

    Remarks

    This method allows removing hyperlinks from a specified cell or range of cells in the spreadsheet.

    The cellAddress parameter determines the location from which hyperlinks will be removed, using standard cell notation (e.g., "A1") or an explicit sheet reference (e.g., "Sheet1!A1").

    This operation requires the AllowHyperlink property to be set to true. If AllowHyperlink is set to false, this method will not remove hyperlinks from the spreadsheet.

    Sheet protection affects hyperlink removal. If the sheet is protected, hyperlinks can only be removed if:

    • The target cell or range is in an unlocked area of the protected sheet

    The method will validate the sheet name and cell address before removing any hyperlink. If an invalid sheet name or cell address is provided, no hyperlinks will be removed, and no error will be thrown.

    After removing a hyperlink, the cell value remains unchanged - only the hyperlink functionality is removed.

    Examples
    // Example: Removing a hyperlink from a specific cell
    await spreadsheet.RemoveHyperlinkAsync("A4");
    
    // Example: Removing hyperlinks from a cell in a specific sheet
    await spreadsheet.RemoveHyperlinkAsync("Sheet2!B2");
    
    // Example: Removing hyperlinks from a range of cells
    await spreadsheet.RemoveHyperlinkAsync("A1:A5");
    
    // Example: Removing hyperlinks from a range in a specific sheet
    await spreadsheet.RemoveHyperlinkAsync("Sheet3!A10:A1000");
    
    // Example: Setting AllowHyperlink property
    spreadsheet.AllowHyperlink = true; // Enable hyperlink operations
    await spreadsheet.RemoveHyperlinkAsync("A10"); // This will work
    
    spreadsheet.AllowHyperlink = false; // Disable hyperlink operations
    // This call won't remove a hyperlink because AllowHyperlink is false
    await spreadsheet.RemoveHyperlinkAsync("A11");

    SelectRangeAsync(String)

    Selects a range of cells in the active sheet.

    Declaration
    public Task SelectRangeAsync(string cellAddress)
    Parameters
    Type Name Description
    System.String cellAddress

    The address of the range to select. The format can be a single range (e.g., "A1:B5") or multiple ranges separated by spaces (e.g., "A1:A10 B1:B10 C1:C10"). If null or empty string is provided, no cells will be selected.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A task that represents the asynchronous selection operation.

    Remarks

    This method updates the selected range of the active sheet and initializes the selection in the user interface.

    Multiple ranges can be selected by providing space-separated range addresses.

    If invalid range addresses are provided, no selection will occur.

    If null or an empty string is passed, the method will not select any cells.

    Examples
    <SfButton OnClick="SelectRangeHandler" Content="Select Range"></SfButton>
    <SfSpreadsheet @ref="@SpreadsheetInstance"></SfSpreadsheet>
    @code {
        public SfSpreadsheet SpreadsheetInstance { get; set; }
    
        public async Task SelectRangeHandler()
        {
            // Selects the range A1:C3 on the active worksheet.
            await SpreadsheetInstance.SelectRangeAsync("A1:C3");
    
            // Selects multiple ranges simultaneously
            await SpreadsheetInstance.SelectRangeAsync("A1:A10 B1:B10 C1:C10");
    
            // Passing null or empty string won't select any cells
            await SpreadsheetInstance.SelectRangeAsync(null);
        }
    }

    SortRangeAsync(String, SortDirection)

    Asynchronously sorts a range of cells on the active worksheet. This method sorts the selected range based on the first cell address of the selected range. For example, in range "B10:C10", sorting is based on column B.

    Declaration
    public Task SortRangeAsync(string selectedRange = "", SortDirection sortDirection)
    Parameters
    Type Name Description
    System.String selectedRange

    The address of the range to be sorted. If not specified, the currently selected range will be used. This must be a valid cell range address (e.g., "B2:C5").

    SortDirection sortDirection

    The direction of the sort. Must be a value from the SortDirection enum. The default value is Ascending if not specified.

    Possible values include:

    • Ascending - Sorts data in ascending order
    • Descending - Sorts data in descending order
    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous sorting operation.

    Remarks

    The sorting is performed on the active sheet based on whether the selected range contains headers or not.

    The method will not perform the operation if any of these conditions are met:

    • The worksheet is protected
    • Multiple non-contiguous ranges are selected
    • The AllowSorting property is set to false
    Examples
    <SfButton OnClick="SortHandler" Content="Sort Data"></SfButton>
    <SfSpreadsheet @ref="@SpreadsheetInstance"></SfSpreadsheet>
    @code {
        public SfSpreadsheet SpreadsheetInstance { get; set; }
    
        public async Task SortHandler()
        {
            // Sorts the range B2:D5 in ascending order based on values in column B
            await SpreadsheetInstance.SortRangeAsync("B2:D5", SortDirection.Ascending);
    
            // Sorts the currently selected range in descending order
            await SpreadsheetInstance.SortRangeAsync(sortDirection: SortDirection.Descending);
        }
    }

    UpdateCellAsync(String, Object)

    Updates the value of a specified cell in the spreadsheet.

    Declaration
    public Task UpdateCellAsync(string cellAddress, object cellValue)
    Parameters
    Type Name Description
    System.String cellAddress

    The address of the cell to update, which must include the sheet name in the format "SheetName!CellAddress" (e.g., "Sheet1!A1"). This parameter is required and must follow the proper format. This must be a valid cell addresses (e.g., "A1", "B2").

    System.Object cellValue

    The new value to assign to the cell. This can be a string, number, boolean, or any other compatible data type.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous update operation.

    Remarks

    This method enables updating a specific cell's value in a specified worksheet. The method requires the cell address to include the sheet name.

    The method performs validation to ensure the cell address is in the correct format before making any changes.

    The invalid cell address will be skipped during the update process.

    This method will not work if the sheet is protected or if the AllowEditing property is set to false.

    Even if the sheet is protected, this method will still work when targeting cells in unlocked ranges of the protected sheet.

    Examples

    The following example demonstrates how to update cells in a spreadsheet:

    <SfButton OnClick="UpdateCellValues" Content="Update Cell"></SfButton>
    <SfSpreadsheet @ref="@SpreadsheetInstance"></SfSpreadsheet>
    
    @code {
        private SfSpreadsheet SpreadsheetInstance { get; set; }
    
        public async Task UpdateCellValues()
        {
            // Update a text value in Sheet1
            await SpreadsheetInstance.UpdateCellAsync("Sheet1!A1", "New Value");
    
            // Update a numeric value in Sheet2
            await SpreadsheetInstance.UpdateCellAsync("Sheet2!B5", 42);
    
            // Update a boolean value
            await SpreadsheetInstance.UpdateCellAsync("Sheet1!C3", true);
        }
    }
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved