Class SpreadsheetGrid
Represents a class which is used for displaying the data of IWorksheet.
Inherited Members
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
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
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
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
InitializeCellRendererCollection()
Initializes the CellRenderer Collection in the SpreadsheetGrid.
Declaration
protected override void InitializeCellRendererCollection()
Overrides
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
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
OnContainerKeyDown(KeyEventArgs)
Declaration
protected override bool OnContainerKeyDown(KeyEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Input.KeyEventArgs | e |
Returns
| Type |
|---|
| System.Boolean |
Overrides
OnCreateCopyPaste()
Initialize the SpreadsheetCopyPaste when the SpreadsheetGrid is loaded.
Declaration
protected override GridCopyPaste OnCreateCopyPaste()
Returns
| Type | Description |
|---|---|
| GridCopyPaste | An instance of SpreadsheetCopyPaste. |
Overrides
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
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
OnCreateModel()
Creates a new instance of the SpreadsheetGridModel for the grid.
Declaration
protected override GridModel OnCreateModel()
Returns
| Type | Description |
|---|---|
| GridModel | null. |
Overrides
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
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
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
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
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
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
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
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
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
UnWireEvents()
Unwires or unloads the events in SpreadsheetGrid.
Declaration
protected override void UnWireEvents()
Overrides
WireEvents()
Wires or loads the events in SpreadsheetGrid.
Declaration
protected override void WireEvents()
Overrides
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;
}