Spreadsheet Tools
The Telerik Blazor Spreadsheet organizes all its tools in a tool set with one or more tool set items. This article describes the built-in Spreadsheet tools and how to define custom tools.
In this article:
- The building blocks of the Spreadsheet tool set
- The built-in Spreadsheet tools
- How to customize a built-in tool set
- How to define a custom tool set from scratch
- How to create a custom tool
Tool Set
The top of the Spreadsheet component displays a Menu and a ToolBar:
- The Menu and the ToolBar make up the Spreadsheet tool set (
SpreadsheetToolSet). - The tool set has an
Itemsproperty and includes one or more tool set items (SpreadsheetToolSetItem). Each Menu item points to one tool set item. - Each tool set item includes one or more tools (
SpreadsheetTool).
The SpreadsheetToolSetItem class has the following properties:
| Property Name | Type | Description |
|---|---|---|
Title | string | The tool set name. Regard this as a single Menu item. |
Tools | List<SpreadsheetTool> | The collection of tools in the tool set item. Regard this collection as one TooBar instance. |
The Spreadsheet provides ready-to-use SpreadsheetToolSet objects, for example, SpreadsheetToolSets.All. A tool set provides a specific distribution and order of tools across tool set items. However, each tool can exist in any tool set item.
Built-in Tools
The following table lists all Spreadsheet tools, sorted by their default tool set and order index.
| Tool Name | Class Name | Default Tool Set |
|---|---|---|
| Open | SpreadsheetOpenFileTool | File |
| Download | SpreadsheetDownloadFileTool | File |
| Undo | SpreadsheetUndoTool | Home |
| Redo | SpreadsheetRedoTool | Home |
| Font Family | SpreadsheetFontFamilyTool | Home |
| Font Size | SpreadsheetFontSizeTool | Home |
| Bold | SpreadsheetBoldTool | Home |
| Italic | SpreadsheetItalicTool | Home |
| Underline | SpreadsheetUnderlineTool | Home |
| Text Color | SpreadsheetTextColorTool | Home |
| Background Color | SpreadsheetBackgroundColorTool | Home |
| Horizontal Align | SpreadsheetHorizontalAlignTool | Home |
| Vertical Align | SpreadsheetVerticalAlignTool | Home |
| Text Wrap | SpreadsheetTextWrapTool | Home |
| Number and Date Format | SpreadsheetNumberFormatTool | Format |
| Decrease Decimals | SpreadsheetDecreaseDecimalTool | Format |
| Increase Decimals | SpreadsheetIncreaseDecimalTool | Format |
| Insert Link | SpreadsheetInsertLinkTool | Insert |
| Insert Image | SpreadsheetInsertImageTool | Insert |
| Merge Cells | SpreadsheetMergeCellsTool | View |
| Toggle Grid Lines | SpreadsheetGridLinesTool | View |
The Spreadsheet component provides a few tools that have no specific action:
| Tool Name | Class Name | Description |
|---|---|---|
| Separator | SpreadsheetToolSeparator | The Separator tool inserts a visible border between other tools in the same tool set. |
| Custom | SpreadsheetCustomTool | The Custom tool allows you to add custom content to a Spreadsheet tool set. |
Customize Built-in Tool Sets
The Spreadsheet uses Telerik Blazor components to create its built-in tool sets and tools. You can add, remove, and reorder tools in the built-in tool sets. You can also customize the exposed tool properties.
The example below shows how to:
- Get the File and Home tool set items. The built-in tool set items are distinguishable by their index or
Title. The title can change in localized applications, so you may need to use theITelerikStringLocalizerservice to search for the localizedTitlestring. - Change the label of the File tool set item.
- Obtain reference to a few built-in tools inside the Home tool set item. You can find tools by their type or order index. Using order index is not future-proof, as the built-in tool sets can change.
- Set the
Dataproperty of the Font Family and Font Size tools to change the available drop down options. - Set the
Colorsproperty of the Text Color and Background Color tools to change the available color palettes. - Disable or remove the Text Wrap tool.
Customizing tools from the default Spreadsheet tool set
Create a Custom Tool Set
Here is how to define a custom tool set from scratch. You can also set the available properties of each tool, such as Class, Enabled, Icon, and Title.
- Set the Spreadsheet
Toolsparameter to a newSpreadsheetToolSetinstance, for example,SpreadsheetTools. - Set the
Itemsproperty ofSpreadsheetToolsto anew List<SpreadsheetToolSetItem>(). - Add one or more
SpreadsheetToolSetItemobjects to theItemslist. - Populate each
SpreadsheetToolSetItemobject with built-in tools or custom tools.
Creating a custom tool set collection from scratch
Define Custom Tools
The SpreadsheetCustomTool type has a Template property that is a RenderFragment. Generally, custom tools can do one of the following:
- Perform actions that relate to the Spreadsheet component, loaded Excel document, or app business logic.
- Modify the Excel document programmatically with the help of RadSpreadProcessing.
Creating custom Spreadsheet tools