menu

WPF

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

    Show / Hide Table of Contents

    Class SpreadsheetGrid

    Represents a class which is used for displaying the data of IWorksheet.

    Inheritance
    System.Object
    SfCellGrid
    SpreadsheetGrid
    Implements
    System.ComponentModel.INotifyPropertyChanged
    System.IDisposable
    ICalcData
    Inherited Members
    SfCellGrid.AllowColumnResize
    SfCellGrid.AllowEditing
    SfCellGrid.AllowEditorsContextMenu
    SfCellGrid.AllowExcelLikeKeyNavigation
    SfCellGrid.AllowFloatingCell
    SfCellGrid.AllowFloatingCellInEdit
    SfCellGrid.AllowHiddenColumnResize
    SfCellGrid.AllowHiddenRowResize
    SfCellGrid.AllowRowResize
    SfCellGrid.AllowSelection
    SfCellGrid.ArrangeOverride(Size)
    SfCellGrid.AutoScroller
    SfCellGrid.CellClick
    SfCellGrid.CellCommentOpening
    SfCellGrid.CellContextMenu
    SfCellGrid.CellContextMenuOpening
    SfCellGrid.CellRequestNavigate
    SfCellGrid.CellTooltipOpening
    SfCellGrid.ColumnCount
    SfCellGrid.ColumnResizingController
    SfCellGrid.ColumnWidths
    SfCellGrid.CopyPaste
    SfCellGrid.CoveredCells
    SfCellGrid.CreateGridColumn
    SfCellGrid.currentCell
    SfCellGrid.CurrentCellActivated
    SfCellGrid.CurrentCellActivating
    SfCellGrid.CurrentCellBeginEdit
    SfCellGrid.CurrentCellEndEdit
    SfCellGrid.CurrentCellValidated
    SfCellGrid.CurrentCellValidating
    SfCellGrid.CurrentCellValueChanged
    SfCellGrid.DefaultColumnWidth
    SfCellGrid.DefaultRowHeight
    SfCellGrid.Dispose()
    SfCellGrid.EditorSelectionBehavior
    SfCellGrid.EditTrigger
    SfCellGrid.FooterColumns
    SfCellGrid.FooterRows
    SfCellGrid.FormulaEngine
    SfCellGrid.FrozenColumns
    SfCellGrid.FrozenRows
    SfCellGrid.GetValueRowCol(Int32, Int32)
    SfCellGrid.GridLineColor
    SfCellGrid.HeaderCellBorderBrush
    SfCellGrid.HeaderCellBorderBrushProperty
    SfCellGrid.HeaderColumns
    SfCellGrid.HeaderRows
    SfCellGrid.InvalidateCell(GridRangeInfo, Boolean)
    SfCellGrid.InvalidateCell(Int32, Int32)
    SfCellGrid.InvalidateCellBorders(GridRangeInfo)
    SfCellGrid.InvalidateCells(Boolean)
    SfCellGrid.InvalidateSelection()
    SfCellGrid.InvalidateVisual()
    SfCellGrid.InvalidateVisual(Boolean)
    SfCellGrid.InvalidateVisual(Boolean, GridRangeInfo)
    SfCellGrid.IsDisposed
    SfCellGrid.MeasureOverride(Size)
    SfCellGrid.OnManipulationBoundaryFeedback(ManipulationBoundaryFeedbackEventArgs)
    SfCellGrid.OnValueChanged(Int32, Int32, String)
    SfCellGrid.OnVisualContainerPointerExited(Object, MouseEventArgs)
    SfCellGrid.PointToCellRowColumnIndex(Point)
    SfCellGrid.PointToCellRowColumnIndexOutsideCells(Point, Boolean)
    SfCellGrid.PropertyChanged
    SfCellGrid.RecalculateCell(Int32, Int32, Boolean)
    SfCellGrid.ResizingColumns
    SfCellGrid.ResizingRows
    SfCellGrid.RowCount
    SfCellGrid.RowHeights
    SfCellGrid.RowResizingController
    SfCellGrid.ScrollColumns
    SfCellGrid.ScrollInView(RowColumnIndex)
    SfCellGrid.ScrollRows
    SfCellGrid.SelectedRanges
    SfCellGrid.SelectionBorderBrush
    SfCellGrid.SelectionBorderBrushProperty
    SfCellGrid.SelectionBorderThickness
    SfCellGrid.SelectionBrush
    SfCellGrid.SelectionChanged
    SfCellGrid.SelectionChanging
    SfCellGrid.SelectionController
    SfCellGrid.SetValueRowCol(Object, Int32, Int32)
    SfCellGrid.ShowComment
    SfCellGrid.ShowGridLines
    SfCellGrid.ShowTooltip
    SfCellGrid.ValueChanged
    SfCellGrid.WireParentObject()
    Namespace: Syncfusion.UI.Xaml.Spreadsheet
    Assembly: Syncfusion.SfSpreadsheet.WPF.dll
    Syntax
    public class SpreadsheetGrid : SfCellGrid, INotifyPropertyChanged, IDisposable, ICalcData
    Remarks

    The data will be displayed in the form of rows and columns. This class also includes the selection and editing operations in grid that allow the users to easily manage the data.

    Constructors

    SpreadsheetGrid()

    Initializes a new instance of the SpreadsheetGrid class.

    Declaration
    public SpreadsheetGrid()

    Fields

    ActiveHeaderBackgroundProperty

    The Dependency property for ActiveHeaderBackground

    Declaration
    public static readonly DependencyProperty ActiveHeaderBackgroundProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    ActiveHeaderForegroundProperty

    The Dependency property for ActiveHeaderForeground

    Declaration
    public static readonly DependencyProperty ActiveHeaderForegroundProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    HeaderBackgroundProperty

    The Dependency property for HeaderBackground

    Declaration
    public static readonly DependencyProperty HeaderBackgroundProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    HeaderForegroundProperty

    The Dependency property for HeaderForeground

    Declaration
    public static readonly DependencyProperty HeaderForegroundProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    Properties

    ActiveHeaderBackground

    Gets or sets the background color for selected header cell(s).

    Declaration
    public Brush ActiveHeaderBackground { get; set; }
    Property Value
    Type
    System.Windows.Media.Brush

    ActiveHeaderForeground

    Gets or sets the text color for selected header cell(s).

    Declaration
    public Brush ActiveHeaderForeground { get; set; }
    Property Value
    Type
    System.Windows.Media.Brush

    CellRenderers

    Gets a value indicating the instance of SpreadsheetCellRendererCollection which holds the collection of cellrenderer objects.

    Declaration
    public SpreadsheetCellRendererCollection CellRenderers { get; }
    Property Value
    Type Description
    SpreadsheetCellRendererCollection

    An instance of SpreadsheetCellRendererCollection.

    CurrentCell

    Gets the value indicating the instance of the SpreadsheetCurrentCell which maintains the current cell in SpreadsheetGrid.

    Declaration
    public SpreadsheetCurrentCell CurrentCell { get; }
    Property Value
    Type Description
    SpreadsheetCurrentCell

    An instance of SpreadsheetCurrentCell.

    FillSeriesController

    Gets or sets the value indicating the instance of FillSeriesController which provides support to autofill the data.

    Declaration
    public FillSeriesController FillSeriesController { get; set; }
    Property Value
    Type Description
    FillSeriesController

    An instance of FillSeriesController.

    GraphicModel

    Gets the value indicating the instance of GraphicModel which holds all the information about graphic cells.

    Declaration
    public GraphicModel GraphicModel { get; }
    Property Value
    Type Description
    GraphicModel

    An instance of GraphicModel.

    HeaderBackground

    Gets or sets the text color for header cells.

    Declaration
    public Brush HeaderBackground { get; set; }
    Property Value
    Type
    System.Windows.Media.Brush

    HeaderForeground

    Gets or sets the background color for header cells.

    Declaration
    public Brush HeaderForeground { get; set; }
    Property Value
    Type
    System.Windows.Media.Brush

    Model

    Gets the value indicating the instance of SpreadsheetGridModel which holds the operation on rows and columns in SpreadsheetGrid.

    Declaration
    public SpreadsheetGridModel Model { get; }
    Property Value
    Type Description
    SpreadsheetGridModel

    An instance of SpreadsheetGridModel

    SheetName

    Gets the value indicating the name of the worksheet in the Workbook.

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

    Name of the worksheet.

    Worksheet

    Gets the value indicating the instance of IWorksheet in the Workbook.

    Declaration
    public IWorksheet Worksheet { get; }
    Property Value
    Type Description
    IWorksheet

    An instance of IWorksheet.

    Methods

    Dispose(Boolean)

    Releases all resources used by the. SpreadsheetGrid.

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing
    Overrides
    SfCellGrid.Dispose(Boolean)

    GetCalculatedValue(IRange)

    Returns the calculated value (without formatting) for a formula cell.

    Declaration
    public string GetCalculatedValue(IRange range)
    Parameters
    Type Name Description
    IRange range

    IRange.

    Returns
    Type
    System.String
    Remarks

    If the passed range is not a formula cell, then it returns null.

    GetCellValue(Int32, Int32)

    Used to get the value of the cell.

    Declaration
    public override object GetCellValue(int rowIndex, int colIndex)
    Parameters
    Type Name Description
    System.Int32 rowIndex

    RowIndex of the cell.

    System.Int32 colIndex

    ColumnIndex of the cell.

    Returns
    Type Description
    System.Object

    Returns the cell value.

    Overrides
    SfCellGrid.GetCellValue(Int32, Int32)

    GetDependentCellValue(Int32, Int32)

    This method gets the dependent cell value of the corresponding row and column index of the SpreadsheetGrid.

    Declaration
    public override string GetDependentCellValue(int rowIndex, int colIndex)
    Parameters
    Type Name Description
    System.Int32 rowIndex

    Index of the corresponding cell's row.

    System.Int32 colIndex

    Index of the corresponding cell's column.

    Returns
    Type Description
    System.String

    An instance of IRange.

    Overrides
    SfCellGrid.GetDependentCellValue(Int32, Int32)

    GetDisplayText(Int32, Int32)

    Used to get the display text of the cell.

    Declaration
    public override string GetDisplayText(int rowIndex, int colIndex)
    Parameters
    Type Name Description
    System.Int32 rowIndex

    RowIndex of the cell.

    System.Int32 colIndex

    ColumnIndex of the cell.

    Returns
    Type Description
    System.String

    Returns the display text.

    Overrides
    SfCellGrid.GetDisplayText(Int32, Int32)

    InitializeCellRendererCollection()

    Initializes the CellRenderer Collection in the SpreadsheetGrid.

    Declaration
    protected override void InitializeCellRendererCollection()
    Overrides
    SfCellGrid.InitializeCellRendererCollection()

    OnApplyTemplate()

    When overridden in a derived class, is invoked whenever application code or internal processes call System.Windows.FrameworkElement.ApplyTemplate.

    Declaration
    public override void OnApplyTemplate()
    Overrides
    SfCellGrid.OnApplyTemplate()
    Remarks

    Builds a visual tree for the VisualContainerExt, when a new template is applied and initialize the Grouping elements and cellrenderer collection.

    OnCellRequestNavigateEvent(CellRequestNavigateEventArgs)

    Provides support for hyperlink navigation between different cells in SpreadsheetGrid.

    Declaration
    protected override bool OnCellRequestNavigateEvent(CellRequestNavigateEventArgs e)
    Parameters
    Type Name Description
    CellRequestNavigateEventArgs e

    An instance of CellRequestNavigateEventArgs

    Returns
    Type Description
    System.Boolean

    True, if the navigation can be done in cell; otherwise, false.

    Overrides
    SfCellGrid.OnCellRequestNavigateEvent(CellRequestNavigateEventArgs)

    OnContainerKeyDown(KeyEventArgs)

    Declaration
    protected override bool OnContainerKeyDown(KeyEventArgs e)
    Parameters
    Type Name Description
    System.Windows.Input.KeyEventArgs e
    Returns
    Type
    System.Boolean
    Overrides
    SfCellGrid.OnContainerKeyDown(KeyEventArgs)

    OnCreateCopyPaste()

    Initialize the SpreadsheetCopyPaste when the SpreadsheetGrid is loaded.

    Declaration
    protected override GridCopyPaste OnCreateCopyPaste()
    Returns
    Type Description
    GridCopyPaste

    An instance of SpreadsheetCopyPaste.

    Overrides
    SfCellGrid.OnCreateCopyPaste()

    OnCreateCurrentCell()

    Creates a new instance of the GridCurrentCell which maintains the current cell in the grid.

    Declaration
    protected override GridCurrentCell OnCreateCurrentCell()
    Returns
    Type Description
    GridCurrentCell

    An instance of SpreadsheetColumn.

    Overrides
    SfCellGrid.OnCreateCurrentCell()

    OnCreateGridColumn(SfCellGrid)

    Creates a new instance of the GridColumn which holds the information of the every cells in the grid.

    Declaration
    protected override GridColumn OnCreateGridColumn(SfCellGrid grid)
    Parameters
    Type Name Description
    SfCellGrid grid

    An instance of SfCellGrid.

    Returns
    Type Description
    GridColumn

    An instance of SpreadsheetColumn.

    Overrides
    SfCellGrid.OnCreateGridColumn(SfCellGrid)

    OnCreateModel()

    Creates a new instance of the SpreadsheetGridModel for the grid.

    Declaration
    protected override GridModel OnCreateModel()
    Returns
    Type Description
    GridModel

    null.

    Overrides
    SfCellGrid.OnCreateModel()

    OnCurrentCellEndEdit(CurrentCellEndEditEventArgs)

    Commits and ends the edit operation on the current cell in SfSpreadsheet.

    Declaration
    protected override void OnCurrentCellEndEdit(CurrentCellEndEditEventArgs e)
    Parameters
    Type Name Description
    CurrentCellEndEditEventArgs e

    An CurrentCellEndEditEventArgs that contains the event data.

    Overrides
    SfCellGrid.OnCurrentCellEndEdit(CurrentCellEndEditEventArgs)

    OnKeyUp(KeyEventArgs)

    Invoked when an unhandled System.Windows.Input.Keyboard.KeyUp attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

    Declaration
    protected override void OnKeyUp(KeyEventArgs e)
    Parameters
    Type Name Description
    System.Windows.Input.KeyEventArgs e

    The System.Windows.Input.KeyEventArgs that contains the event data.

    OnPreviewKeyDown(KeyEventArgs)

    Occurs before the KeyDown event when a key is pressed while focus is on this control.

    Declaration
    protected override void OnPreviewKeyDown(KeyEventArgs e)
    Parameters
    Type Name Description
    System.Windows.Input.KeyEventArgs e

    An System.Windows.Input.KeyEventArgs that contains the event data.

    Overrides
    SfCellGrid.OnPreviewKeyDown(KeyEventArgs)

    OnTextInput(TextCompositionEventArgs)

    Occurs when the current cell gets the input text.

    Declaration
    protected override void OnTextInput(TextCompositionEventArgs e)
    Parameters
    Type Name Description
    System.Windows.Input.TextCompositionEventArgs e

    An System.Windows.Input.TextCompositionEventArgs that contains the event data.

    Overrides
    SfCellGrid.OnTextInput(TextCompositionEventArgs)

    OnVisualContainerPointerMoved(Object, MouseEventArgs)

    Occurs when the pointer moved over the VisualContainer.

    Declaration
    protected override void OnVisualContainerPointerMoved(object sender, MouseEventArgs args)
    Parameters
    Type Name Description
    System.Object sender

    The source of the event.

    System.Windows.Input.MouseEventArgs args

    An System.Windows.Input.MouseEventArgs that contains the event data.

    Overrides
    SfCellGrid.OnVisualContainerPointerMoved(Object, MouseEventArgs)

    OnVisualContainerPointerPressed(Object, MouseButtonEventArgs)

    Occurs when the pointer is pressed on VisualContainer.

    Declaration
    protected override void OnVisualContainerPointerPressed(object sender, MouseButtonEventArgs e)
    Parameters
    Type Name Description
    System.Object sender

    The source of the event.

    System.Windows.Input.MouseButtonEventArgs e

    An System.Windows.Input.MouseButtonEventArgs that contains the event data.

    Overrides
    SfCellGrid.OnVisualContainerPointerPressed(Object, MouseButtonEventArgs)

    OnVisualContainerPointerReleased(Object, MouseButtonEventArgs)

    Occurs when the pointer is released on VisualContainer.

    Declaration
    protected override void OnVisualContainerPointerReleased(object sender, MouseButtonEventArgs e)
    Parameters
    Type Name Description
    System.Object sender

    The source of the event.

    System.Windows.Input.MouseButtonEventArgs e

    An System.Windows.Input.MouseButtonEventArgs that contains the event data.

    Overrides
    SfCellGrid.OnVisualContainerPointerReleased(Object, MouseButtonEventArgs)

    SetCellValue(IRange, String)

    Sets the value or formula to the given IRange in the Workbook

    Declaration
    public void SetCellValue(IRange currentExcelRange, string cellValue)
    Parameters
    Type Name Description
    IRange currentExcelRange

    An instance of IRange

    System.String cellValue

    Value to be displayed

    SetColumnWidth(Int32, Int32, Double)

    Used to set the column width in the SpreadsheetGrid.

    Declaration
    public override void SetColumnWidth(int startIndex, int endIndex, double width)
    Parameters
    Type Name Description
    System.Int32 startIndex

    Start column index.

    System.Int32 endIndex

    End column index.

    System.Double width

    Width of the column to expand.

    Overrides
    SfCellGrid.SetColumnWidth(Int32, Int32, Double)

    SetRowHeight(Int32, Int32, Double)

    Used to set the row height in the SpreadsheetGrid.

    Declaration
    public override void SetRowHeight(int startIndex, int endIndex, double height)
    Parameters
    Type Name Description
    System.Int32 startIndex

    Start row's index.

    System.Int32 endIndex

    End row's index.

    System.Double height

    Height of the row to resize.

    Overrides
    SfCellGrid.SetRowHeight(Int32, Int32, Double)

    ShowHidePopup(Boolean)

    To show and hide popup's when moved to another application

    Declaration
    public override void ShowHidePopup(bool show)
    Parameters
    Type Name Description
    System.Boolean show

    True, if the popup is displayed; otherwise false

    Overrides
    SfCellGrid.ShowHidePopup(Boolean)

    UnWireEvents()

    Unwires or unloads the events in SpreadsheetGrid.

    Declaration
    protected override void UnWireEvents()
    Overrides
    SfCellGrid.UnWireEvents()

    WireEvents()

    Wires or loads the events in SpreadsheetGrid.

    Declaration
    protected override void WireEvents()
    Overrides
    SfCellGrid.WireEvents()

    Events

    QueryRange

    Occurs when grid queries for IRange information about a specifc cell while rendering.

    Declaration
    public event SpreadsheetQueryRangeEventHandler QueryRange
    Event Type
    Type
    SpreadsheetQueryRangeEventHandler
    Examples
    var grid = spreadsheet.ActiveGrid;
    grid.QueryRange+=grid_QueryRange;
    void grid_QueryRange(object sender, SpreadsheetQueryRangeEventArgs e)
    {
       if (e.Cell.ColumnIndex == 5)
           e.ExcelStyle.ColorIndex = ExcelKnownColors.Blue;
    }

    Implements

    System.ComponentModel.INotifyPropertyChanged
    System.IDisposable
    ICalcData

    Extension Methods

    SelectionHelper.GetGridRow(SfCellGrid, Int32)
    SelectionHelper.GetVisibleRowColumnIndex(SfCellGrid, Int32, Int32)
    SelectionHelper.GetPreviousVisibleRowColumnIndex(SfCellGrid, Int32, Int32)
    SelectionHelper.GetPreviousVisibleRowIndex(SfCellGrid, Int32)
    SelectionHelper.GetPreviousVisibleColumnIndex(SfCellGrid, Int32)
    SelectionHelper.GetFirstVisibleRowIndex(SfCellGrid)
    SelectionHelper.GetFirstVisibleColumnIndex(SfCellGrid)
    ExcelImportExtension.ImportFromExcel(SfCellGrid, Stream)
    ExcelImportExtension.ImportFromExcel(SfCellGrid, Stream, ExcelImportingOptions)
    ExcelImportExtension.ImportFromExcel(SfCellGrid, String)
    ExcelImportExtension.ImportFromExcel(SfCellGrid, String, ExcelImportingOptions)
    ExcelImportExtension.ImportFromExcel(SfCellGrid, IWorksheet)
    ExcelImportExtension.ImportFromExcel(SfCellGrid, IWorksheet, ExcelImportingOptions)
    GridTextBoxPaint.DrawText(SfCellGrid, DrawingContext, String, Rect, GridStyleInfo, Object)
    SpreadsheetImportExtension.ImportWorksheetToGrid(SpreadsheetGrid, IWorksheet)
    GridExcelHelper.InvalidateCellRange(SpreadsheetGrid)
    GridExcelHelper.IsRangeContainsComment(SpreadsheetGrid, GridRangeInfo)
    RichTextBoxHelper.ConvertRichTextToFlowDocument(SpreadsheetGrid, IStyle, IRichTextString)
    SpreadsheetTextBoxPaint.MeasureText(SpreadsheetGrid, String, SpreadsheetColumn, Double, Boolean, Int32, out Object)
    SpreadsheetTextBoxPaint.DrawText(SpreadsheetGrid, RowColumnIndex, DrawingContext, Rect, SpreadsheetColumn, Object)
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved