# RadzenSpreadsheet Class

A spreadsheet component that allows users to view and edit workbooks. It supports features like cell selection, editing, and keyboard shortcuts. The component can display a workbook with multiple sheets and allows users to navigate through cells using keyboard shortcuts. It also supports mouse interactions for selecting and editing cells, rows, and columns.

Namespace: [Radzen.Blazor](https://blazor.radzen.com/docs/api/Radzen.Blazor.md)

Assembly: Radzen.Blazor.dll

## Inheritance

- Object
- ComponentBase
- [RadzenComponent](https://blazor.radzen.com/docs/api/Radzen.RadzenComponent.md)
- RadzenSpreadsheet

## Implements

- IComponent
- IHandleEvent
- IHandleAfterRender
- [ISpreadsheet](https://blazor.radzen.com/docs/api/Radzen.Blazor.ISpreadsheet.md)

## Syntax

```csharp
public class RadzenSpreadsheet : RadzenComponent, IComponent, IHandleEvent, IHandleAfterRender, ISpreadsheet
```

## Constructors

| Constructor | Description |
|-------------|-------------|
| `public RadzenSpreadsheet()` | A spreadsheet component that allows users to view and edit workbooks. It supports features like cell selection, editing, and keyboard shortcuts. The component can display a workbook with multiple sheets and allows users to navigate through cells using keyboard shortcuts. It also supports mouse interactions for selecting and editing cells, rows, and columns. |

## Properties

| Property | Type | Description |
|------|------|-------------|
| AllowAutofill | `bool` | Allows drag-to-fill (autofill) gestures. |
| AllowCellFormatting | `bool` | Allows font, color, alignment, and border formatting commands. |
| AllowCharts | `bool` | Allows inserting, editing, moving, resizing, and deleting charts. |
| AllowClipboard | `bool` | Allows cut, copy, and paste through the system clipboard. Independent of ReadOnly, so view-only users can still copy unless this is set to false. Cut and paste also require AllowEditing. |
| AllowConditionalFormatting | `bool` | Allows adding and clearing conditional formatting rules. |
| AllowDataValidation | `bool` | Allows adding and clearing data-validation rules. |
| AllowEditing | `bool` | Allows direct cell editing (type-to-edit, double-click, paste-into-cell, delete-key, autoaccept). |
| AllowFiltering | `bool` | Allows filter and auto-filter commands and the filter UI affordances. |
| AllowHyperlinks | `bool` | Allows inserting, editing, and following hyperlinks. |
| AllowImages | `bool` | Allows inserting, moving, resizing, and deleting images. |
| AllowMerge | `bool` | Allows cell merge and unmerge commands. |
| AllowResizing | `bool` | Allows row and column resize gestures. |
| AllowSorting | `bool` | Allows single- and multi-key sort commands. |
| AllowTables | `bool` | Allows creating, editing, and removing structured tables. |
| AllowUndoRedo | `bool` | Allows undo and redo of previously executed commands. |
| AriaLabel | `string` | Gets or sets the accessible label (aria-label) announced for the spreadsheet's role="application" region. Defaults to a localized "Spreadsheet". |
| CanRedo | `bool` |  |
| CanUndo | `bool` |  |
| CellTypes | `Dictionary<string, Spreadsheet.SpreadsheetCellType>` | Gets or sets the custom cell type definitions. Maps cell type names to their renderer and editor component types. |
| Change | `EventCallback<Spreadsheet.SpreadsheetChangeEventArgs>` | Fires after the workbook has been mutated: a command executed, undone, or redone, or a sheet added, removed, renamed, or moved. Loading a different workbook raises WorkbookChanged instead. |
| ChildContent | `RenderFragment` | Replaces the built-in toolsets. When set, the supplied content sits inside the toolbar's Tabs slot — each child should be a [RadzenTabsItem](https://blazor.radzen.com/docs/api/Radzen.Blazor.RadzenTabsItem.md). Add [RadzenSpreadsheetTableDesignToolset](https://blazor.radzen.com/docs/api/Radzen.Blazor.RadzenSpreadsheetTableDesignToolset.md) to keep the contextual "Table Design" toolset. |
| CommandExecuting | `EventCallback<Spreadsheet.SpreadsheetCommandEventArgs>` | Fires before a command is pushed onto the undo stack. Call PreventDefault from the handler to veto the command. Fires after ReadOnly, the matching Allow* flag, and the sheet's Protection have already approved the command. |
| CsvExportOptions | [`Documents.Spreadsheet.CsvExportOptions`](https://blazor.radzen.com/docs/api/Radzen.Documents.Spreadsheet.CsvExportOptions.md) | Options applied when the user exports the workbook as CSV. When null, defaults are used (comma separator, UTF-8 with BOM, CRLF line endings, RFC 4180 minimal quoting, active sheet only). |
| CsvImportOptions | [`Documents.Spreadsheet.CsvImportOptions`](https://blazor.radzen.com/docs/api/Radzen.Documents.Spreadsheet.CsvImportOptions.md) | Options applied when the user opens a CSV file. When null, defaults are used (comma separator, UTF-8, value and formula auto-detection on). |
| ExportFileName | `string` | The name of the file to export the workbook to when using the export functionality. When the user picks "Save as CSV" the extension is replaced with .csv. |
| ReadOnly | `bool` | When true, the spreadsheet rejects every command that mutates the workbook. The user can still select cells, scroll, and copy. Defaults to false. |
| SelectedSheetIndex | `int` | The zero-based index of the active sheet. Supports two-way binding via @bind-SelectedSheetIndex. Values outside the sheet range are clamped. Setting it selects the matching sheet even when ShowSheetTabs is false; loading a different Workbook resets it to the bound value (or 0 when unbound). |
| SelectedSheetIndexChanged | `EventCallback<int>` | Fired when the active sheet changes. Used by @bind-SelectedSheetIndex. |
| SelectedToolsetIndex | `int` | The index of the active toolset in the toolbar. Defaults to 1 so the Home toolset is shown first. Supports two-way binding via @bind-SelectedToolsetIndex. |
| SelectedToolsetIndexChanged | `EventCallback<int>` | Fired when the active toolset changes. Used by @bind-SelectedToolsetIndex. |
| ShowColumnHeaders | `bool` | When true (the default) the column headers (A, B, C, ...) are rendered above the grid. Set to false to hide them together with their resize handles and the whole-column selection they provide. The space they occupy is released as well. |
| ShowFormulaBar | `bool` | When true (the default) the formula bar is rendered between the toolbar and the grid. |
| ShowRowHeaders | `bool` | When true (the default) the row headers (1, 2, 3, ...) are rendered to the left of the grid. Set to false to hide them together with their resize handles and the whole-row selection they provide. The space they occupy is released as well. |
| ShowSheetTabs | `bool` | When true (the default) the sheet tab strip is rendered below the grid. |
| ShowToolbar | `bool` | When true (the default) the toolbar is rendered above the grid. Set to false for kiosk or view-only embeds. |
| Workbook | [`Documents.Spreadsheet.Workbook`](https://blazor.radzen.com/docs/api/Radzen.Documents.Spreadsheet.Workbook.md) | The workbook to display in the spreadsheet. |
| WorkbookChanged | `EventCallback<Documents.Spreadsheet.Workbook>` | Event callback that is invoked when the workbook changes. |

## Methods

| Method | Returns | Description |
|------|---------|-------------|
| `AcceptAsync()` | `Task<bool>` | Accepts the current edit in the spreadsheet. |
| `BuildRenderTree(Rendering.RenderTreeBuilder __builder)` | `void` |  |
| `ExecuteAsync(Spreadsheet.ICommand command)` | `Task<bool>` |  |
| `GetComponentCssClass()` | `string` |  |
| `IsFeatureAllowed(Spreadsheet.SpreadsheetFeature feature)` | `bool` | Returns true when the given feature is enabled. ReadOnly forces every feature off except Clipboard, which stays governed solely by AllowClipboard so view-only users can still copy data unless the host explicitly opts out. Parameters: `feature`: The feature to check. |
| `LoadWorkbookAsync(Documents.Spreadsheet.Workbook workbook)` | `Task` |  |
| `OnAfterRenderAsync(bool firstRender)` | `Task` |  |
| `OnAutofillPointerDownAsync(PointerEventArgs args)` | `void` | Invoked by JS interop when the autofill handle is pressed. |
| `OnAutofillPointerMoveAsync(PointerEventArgs args)` | `void` | Invoked by JS interop when the pointer moves during an autofill drag. |
| `OnAutofillPointerUpAsync(PointerEventArgs args)` | `Task` | Invoked by JS interop when the pointer is released after an autofill drag. |
| `OnCellContextMenuAsync(Spreadsheet.CellEventArgs args)` | `Task` | Invoked by JS interop when a cell is right-clicked. |
| `OnCellDoubleClickAsync(Spreadsheet.CellEventArgs args)` | `Task` | Invoked by JS interop when a cell is double-clicked with the pointer. |
| `OnCellPointerDownAsync(Spreadsheet.CellEventArgs args)` | `Task<bool>` | Invoked by JS interop when a cell is clicked with the pointer. |
| `OnCellPointerMoveAsync(PointerEventArgs args)` | `Task` | Invoked by JS interop when the pointer moves over a cell. |
| `OnColumnContextMenuAsync(Spreadsheet.CellEventArgs args)` | `Task` | Invoked by JS interop when a column header is right-clicked. |
| `OnColumnPointerDownAsync(Spreadsheet.CellEventArgs args)` | `Task<bool>` | Invoked by JS interop when a column header is clicked with the pointer. |
| `OnColumnPointerMoveAsync(PointerEventArgs args)` | `Task` | Invoked by JS interop when the pointer moves over a column header. |
| `OnColumnResizeDoubleClickAsync(Spreadsheet.CellEventArgs args)` | `Task` | Invoked by JS interop when a column resize handle is double-clicked. Auto fits the column width to its displayed content. Parameters: `args`: The column event arguments containing the target column index. |
| `OnColumnResizePointerDownAsync(Spreadsheet.CellEventArgs args)` | `Task<bool>` | Invoked by JS interop when the column resize handle is pressed. |
| `OnColumnResizePointerMoveAsync(PointerEventArgs args)` | `Task` | Invoked by JS interop when the pointer moves while resizing a column. |
| `OnColumnResizePointerUpAsync(PointerEventArgs args)` | `Task` | Invoked by JS interop when the pointer is released after resizing a column. |
| `OnCopyAsync()` | `Task` | Invoked by JS interop to copy the current selection to the clipboard. |
| `OnDrawingMovePointerDownAsync(PointerEventArgs args)` | `Task` | Invoked by JS interop when a drawing body is pressed to start a move. |
| `OnDrawingMovePointerMoveAsync(PointerEventArgs args)` | `Task` | Invoked by JS interop when the pointer moves while dragging a drawing. |
| `OnDrawingMovePointerUpAsync(PointerEventArgs args)` | `Task` | Invoked by JS interop when the pointer is released after moving a drawing. |
| `OnDrawingResizePointerDownAsync(Spreadsheet.ImageResizeEventArgs args)` | `Task<bool>` | Invoked by JS interop when a drawing resize handle is pressed. |
| `OnDrawingResizePointerMoveAsync(PointerEventArgs args)` | `Task` | Invoked by JS interop when the pointer moves while resizing a drawing. |
| `OnDrawingResizePointerUpAsync(PointerEventArgs args)` | `Task` | Invoked by JS interop when the pointer is released after resizing a drawing. |
| `OnInitialized()` | `void` |  |
| `OnKeyDownAsync(KeyboardEventArgs args, bool isGridContext)` | `Task` | Invoked by JS interop when a key is pressed down. |
| `OnParametersSet()` | `void` |  |
| `OnPasteAsync(string text)` | `Task` | Invoked by JS interop to paste text from the clipboard into the current selection. |
| `OnRowContextMenuAsync(Spreadsheet.CellEventArgs args)` | `Task` | Invoked by JS interop when a row header is right-clicked. |
| `OnRowPointerDownAsync(Spreadsheet.CellEventArgs args)` | `Task<bool>` | Invoked by JS interop when a row header is clicked with the pointer. |
| `OnRowPointerMoveAsync(PointerEventArgs args)` | `Task` | Invoked by JS interop when the pointer moves over a row header. |
| `OnRowResizePointerDownAsync(Spreadsheet.CellEventArgs args)` | `Task<bool>` | Invoked by JS interop when the row resize handle is pressed. |
| `OnRowResizePointerMoveAsync(PointerEventArgs args)` | `Task` | Invoked by JS interop when the pointer moves while resizing a row. |
| `OnRowResizePointerUpAsync(PointerEventArgs args)` | `Task` | Invoked by JS interop when the pointer is released after resizing a row. |
| `OnSelectionPointerUpAsync()` | `Task` | Invoked by JS interop when the user releases the pointer after a cell, row, or column selection gesture. Fires RangeFinalized so subscribers (such as the range picker) can commit the user's pick. |
| `Redo()` | `void` |  |
| `ScrollToAsync(Documents.Spreadsheet.CellRef address)` | `Task` | Scrolls the spreadsheet to the specified cell address. |
| `SetParametersAsync(ParameterView parameters)` | `Task` |  |
| `Undo()` | `void` |  |

## Inherited Members

- From [RadzenComponent](https://blazor.radzen.com/docs/api/Radzen.RadzenComponent.md): AddContextMenu, Attributes, ContextMenu, Culture, CurrentStyle, Debounce, DefaultCulture, DefaultUICulture, Dispose, Element, GetCssClass, GetId, GetIdAttribute, IsJSRuntimeAvailable, JSRuntime, Localize, MouseEnter, MouseLeave, OnBecameInvisible, OnContextMenu, OnMouseEnter, OnMouseLeave, RaiseContextMenu, RaiseMouseEnter, RaiseMouseLeave, Reference, Style, UICulture, UniqueID, Visible
- From ComponentBase: Assets, AssignedRenderMode, DispatchExceptionAsync, InvokeAsync, OnAfterRender, OnInitializedAsync, OnParametersSetAsync, RendererInfo, ShouldRender, StateHasChanged

