How can I help you?
Getting Started with Blazor Spreadsheet Component
28 Apr 20264 minutes to read
This section briefly explains how to include Blazor Spreadsheet component in your Blazor WebAssembly App using Visual Studio and Visual Studio Code.
Prerequisites
Create a new Blazor App in Visual Studio
You can create a Blazor WebAssembly App using Visual Studio via Microsoft Templates or the Syncfusion® Blazor Extension.
Install Syncfusion® Blazor Spreadsheet NuGet Packages
To add Syncfusion Blazor Spreadsheet component in the app, open the NuGet package manager in Visual Studio (Tools → NuGet Package Manager → Manage NuGet Packages for Solution), search and install:
Alternatively, you can utilize the following package manager command to achieve the same.
Install-Package Syncfusion.Blazor.Spreadsheet -Version 33.2.3
Install-Package Syncfusion.Blazor.Themes -Version 33.2.3Prerequisites
Create a new Blazor App in Visual Studio Code
You can create a Blazor WebAssembly App using Visual Studio Code via Microsoft Templates or the Syncfusion® Blazor Extension.
Alternatively, you can create a WebAssembly application using the following command in the terminal(Ctrl+`).
dotnet new blazorwasm -o BlazorApp
cd BlazorAppInstall Syncfusion® Blazor Spreadsheet NuGet Packages
- Press Ctrl+` to open the integrated terminal in Visual Studio Code.
- Ensure you’re in the project root directory where your
.csprojfile is located. - Run the following command to install a Syncfusion.Blazor.Spreadsheet and Syncfusion.Blazor.Themes NuGet package and ensure all dependencies are installed.
dotnet add package Syncfusion.Blazor.Spreadsheet -v 33.2.3
dotnet add package Syncfusion.Blazor.Themes -v 33.2.3
dotnet restoreAdd import namespaces
After the packages are installed, open the ~/_Imports.razor file and import the Syncfusion.Blazor and Syncfusion.Blazor.Spreadsheet namespaces.
@using Syncfusion.Blazor
@using Syncfusion.Blazor.SpreadsheetRegister Syncfusion® Blazor Service
Register the Syncfusion Blazor service in the ~/Program.cs file of your Blazor WebAssembly App.
....
using Syncfusion.Blazor;
....
builder.Services.AddSyncfusionBlazor();
....Add stylesheet and script resources
The theme stylesheet and script can be accessed from NuGet through Static Web Assets. Include the stylesheet and script references in the <head> section of the ~/index.html file.
<head>
....
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />
<script src="_content/Syncfusion.Blazor.Spreadsheet/scripts/syncfusion-blazor-spreadsheet.min.js" type="text/javascript"></script>
</head>NOTE
Check out the Blazor Themes topic to explore supported ways (such as static assets, CDN, and CRG) to apply themes in your Blazor application. Also, check out the Adding Script Reference topic to learn different approaches for adding script references in your Blazor application.
Add Blazor Spreadsheet component
Add the Syncfusion® Blazor Spreadsheet component in the ~/Pages/Index.razor file.
Note: Due to WebAssembly (WASM) browser restrictions, File.ReadAllBytes is not supported. Therefore, the samples use a Base64‑encoded Excel file, which is decoded at runtime to load data without direct file system access.
<SfSpreadsheet DataSource="DataSourceBytes">
<SpreadsheetRibbon></SpreadsheetRibbon>
</SfSpreadsheet>
@code {
public byte[] DataSourceBytes { get; set; }
protected override void OnInitialized()
{
// Replace with your base64-encoded Excel file
string base64File = "YourBase64EncodedExcelFileHere";
DataSourceBytes = Convert.FromBase64String(base64File);
}
}- Press Ctrl+F5 (Windows) or ⌘+F5 (macOS) to launch the application. This will render the Syncfusion Blazor Spreadsheet in your default web browser.