Blazor Spreadsheet Overview
The Spreadsheet for Blazor enables users to view and edit tabular data with an Excel-like user experience. The component supports cell styling, value formatting, links, images, formulas, and a rich collection of mathematical functions.
The Spreadsheet component is part of Telerik UI for Blazor, a
professional grade UI library with 110+ native components for building modern and feature-rich applications. To try it out sign up for a free 30-day trial.
Creating Blazor Spreadsheet
To use the Telerik Spreadsheet for Blazor:
- Add the
TelerikSpreadsheet
tag. - (optional) Set the
Data
parameter to a byte array to load an existing Excel file.
<TelerikSpreadsheet Data="@SpreadsheetData">
</TelerikSpreadsheet>
@code {
private byte[]? SpreadsheetData { get; set; }
protected override async Task OnInitializedAsync()
{
SpreadsheetData = Convert.FromBase64String(SampleExcelFile);
await base.OnInitializedAsync();
}
private const string SampleExcelFile = "UEsDBAoAAAAAALhgfVgAAAAAAAAAAAAAAAAJAAAAZG9jUHJvcHMvUEsDBAoAAAAIALhgfVgsQoJDPAEAAIECAAARAAAAZG9jUHJvcHMvY29yZS54bWylkl1LwzAYhe8H/oeQ+zb9mGOWtgOVgehAsEPxLiTvtmLzQRLt9u9Nu62suDsvk3PyvO85JF/sRYN+wNhayQLHYYQRSKZ4LbcFXlfLYI6RdVRy2igJBT6AxYvyZoJypjOmDLwapcG4GizyKGkzpgu8c05nhFi2A0Ft6B3SixtlBHX+aLZEU/ZFt0CSKJoRAY5y6ijpgIEeiHiC0InK2UDV36bpGZwRaECAdJbEYUzw4HVghL36oFfICCxqd9Bw1X0WB/Te1oOxbduwTXurTxGTj9XLWx84qGVXGQNcdnNyzjJmgDplymeQXKH1U04uLnuTr7Oh1q189Zsa+P3hwvtXO3H7NEcOcOSXy45Rzsp7+vBYLXGZRMk0iNIguaviJItus+k8TKezz26NEWMMFqeB/yKfIeWkDzL+M+UvUEsDBAoAAAAIALhgfViVsis4iQEAAF0DAAAQAAAAZG9jUHJvcHMvYXBwLnhtbJ1TwW7bMAy9B+g/CLo3srtiGAJZxdCu2GHDAiRtz5pMx0IVyRBZI9nXT7LrJFuQS2/Se+Qj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ADQAAAAAAAAAAAAAAAADbCwAAeGwvc3R5bGVzLnhtbFBLAQIUAAoAAAAIALhgfViscmVU2QAAACQCAAAUAAAAAAAAAAAAAAAAAL4OAAB4bC9zaGFyZWRTdHJpbmdzLnhtbFBLAQIUAAoAAAAIALhgfVh4lwyVegEAAEgFAAATAAAAAAAAAAAAAAAAAMkPAABbQ29udGVudF9UeXBlc10ueG1sUEsFBgAAAAARABEACgQAAHQRAAAAAA==";
}
Tools
The Spreadsheet provides built-in tools that perform various actions such as:
- Style the cells
- Format the cell values
- Insert images and links
- Merge cells or toggle the visibility of the cell borders.
You can also add custom tools. Learn how to configure and customize the Blazor Spreadsheet tools.
Functions and Formulas
The Blazor Spreadsheet component supports formulas and a large variety of Excel functions. See the complete list of available Spreadsheet functions.
Events
The Spreadsheet events allow you to implement custom functionality and handle user interactions with the component.
Spreadsheet Parameters
The table below lists the Spreadsheet parameters. For a full list of the ListBox API members (parameters, methods, and events), check the Spreadsheet API Reference.
Parameter | Type and Default Value | Description |
---|---|---|
Class |
string |
The custom CSS classes to render for the <div class="k-spreadsheet"> element. Use the parameter to override the theme styles of some or all Spreadsheet instances. |
ColumnHeaderHeight |
double ( 20 ) |
The pixel height of the column headers that display the letters A, B, C, and so on. |
ColumnsCount |
int ( 50 ) |
The initial number of columns to render. Users can add and delete columns at runtime. |
ColumnWidth |
double ( 64 ) |
The initial pixel width of the columns. |
Data |
byte[] |
The Excel file to display in the Spreadsheet component. |
EnableLoaderContainer |
bool ( true ) |
Defines if the component will show a built-in LoaderContainer while loading Excel files. |
Height |
string |
The height style of the <div class="k-spreadsheet"> element. The built-in themes apply "600px" by default. |
RowHeaderWidth |
double ( 32 ) |
The pixel width of the row headers that display the row numbers. The default width fits up to 3 digits comfortably. |
RowHeight |
double ( 20 ) |
The initial pixel height of the rows. |
RowsCount |
int ( 200 ) |
The initial number of rows to render. Users can add and delete rows at runtime. |
Tools |
SpreadsheetToolSet ( SpreadsheetToolSets.All ) |
The available tabs and tools that users can use to manipulate the Excel file content. The Spreadsheet renders all its tools by default, so the resulting Spreadsheet UI will change in the future. |
Width |
string |
The width style of the <div class="k-spreadsheet"> element. The built-in CSS themes apply "100%" by default. |
Spreadsheet Reference and Methods
The Blazor Spreadsheet component exposes methods for programmatic operation. To use them, define a reference to the component instance with the @ref
directive attribute.
Method | Description |
---|---|
ExportToExcelAsync |
Returns the current Spreadsheet Excel file content as byte[] . The application can save the file or pass it to Telerik Document Processing for further manipulation. You can also get the Spreadsheet cell values programmatically. |
Rebind |
Refreshes the Spreadsheet and ensures it displays the current Data . Rebind is necessary when the Blazor framework cannot re-render components automatically. |
Refresh |
Calls StateHasChanged() for the Spreadsheet component. |
<TelerikSpreadsheet @ref="@SpreadsheetRef">
</TelerikSpreadsheet>
<TelerikButton ThemeColor="@ThemeConstants.Button.ThemeColor.Primary"
OnClick="@OnSaveButtonClick">Save Excel File</TelerikButton>
@code {
private TelerikSpreadsheet? SpreadsheetRef { get; set; }
private async Task OnSaveButtonClick()
{
if (SpreadsheetRef !=null)
{
byte[] excelFileToSave = await SpreadsheetRef.ExportToExcelAsync();
Console.WriteLine($"The Excel file size is {excelFileToSave.Length} bytes.");
}
}
}
Next Steps
- Customize the Spreadsheet tools
- Learn about the supported Spreadsheet functions and formulas
- Handle Spreadsheet events