Getting Started with the Blazor Spreadsheet in Blazor Web App
23 Jul 20269 minutes to read
This section briefly explains how to include the Blazor Spreadsheet Editor component in a Blazor Web App using Visual Studio, Visual Studio Code, and the .NET CLI.
Prerequisites
Create a New Blazor Web App in Visual Studio
Create a Blazor Web App using Visual Studio 2022 via Microsoft Templates or the Syncfusion® Blazor Extension.
NOTE
Configure the appropriate Interactive render mode and Interactivity location while creating a Blazor Web App. For detailed information, refer to the interactive render mode documentation.
Install Blazor Spreadsheet NuGet Packages
If you utilize WebAssembly or Auto render modes in the Blazor Web App, you need to install the Blazor components NuGet packages within the client project.
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 34.1.29
Install-Package Syncfusion.Blazor.Themes -Version 34.1.29Prerequisites
Create a New Blazor Web App in Visual Studio Code
Create a Blazor Web App using Visual Studio Code via Microsoft Templates or the Blazor Extension.
NOTE
Configure the appropriate Interactive render mode and Interactivity location while creating a Blazor Web App. For detailed information, refer to the interactive render mode documentation.
For example, in a Blazor Web App with the Auto interactive render mode, use the following commands.
dotnet new blazor -o BlazorWebApp -int Auto
cd BlazorWebApp
cd BlazorWebApp.ClientNOTE
For more information on creating a Blazor Web App with various interactive modes and locations, see Render interactive modes.
NOTE
If you selected the
Serverinteractive render mode (no client project is created), skip thecdn BlazorWebApp.Clientcommand and run package commands from the server project directory.
Install Blazor Spreadsheet NuGet Packages
If you utilize WebAssembly or Auto render modes in the Blazor Web App, you need to install the Blazor components NuGet packages within the client project.
- 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 34.1.29
dotnet add package Syncfusion.Blazor.Themes -v 34.1.29
dotnet restoreNOTE
After running
dotnet restore, ensure there are no error messages in the terminal. If restore fails, verify your NuGet source (https://api.nuget.org/v3/index.json) is configured, clear the local cache withdotnet nuget locals all --clear, and retry.
Prerequisites
Install the latest version of .NET SDK. If you previously installed the SDK, you can determine the installed version by executing the following command in a command prompt (Windows) or terminal (macOS) or command shell (Linux). Also, review the System requirements for Blazor components.
dotnet --versionCreate a Blazor Web App using .NET CLI
Run the following command to create a new Blazor Web App in a command prompt (Windows) or terminal (macOS) or command shell (Linux). For detailed instructions, refer to the Blazor Web App Getting Started documentation.
For example, in a Blazor Web App with the Auto interactive render mode, use the following commands:
dotnet new blazor -o BlazorWebApp -int Auto
cd BlazorWebApp
cd BlazorWebApp.ClientNOTE
If you selected the
Serverinteractive render mode (no client project is created), skip thecdn BlazorWebApp.Clientcommand and run package commands from the server project directory.
Install Syncfusion® Blazor Spreadsheet and Themes NuGet in the App
If you utilize WebAssembly or Auto render modes in the Blazor Web App, you need to install the Blazor components NuGet packages within the client project.
- Open a command prompt, terminal, or shell.
- Ensure you’re in the project root directory where your
.csprojfile is located (or the Client project if applicable). - 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 34.1.29
dotnet add package Syncfusion.Blazor.Themes -v 34.1.29
dotnet restoreNOTE
After running
dotnet restore, ensure there are no error messages in the terminal. If restore fails, verify your NuGet source (https://api.nuget.org/v3/index.json) is configured, clear the local cache withdotnet nuget locals all --clear, and retry.
Add import namespaces
After the packages are installed, open the _Imports.razor file (typically located at Components/_Imports.razor in Blazor Web App templates; in older templates or WebAssembly apps it may be at the project root) 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 Web App.
using Syncfusion.Blazor;
// Register Syncfusion Blazor service
builder.Services.AddSyncfusionBlazor();NOTE
If the Interactive Render Mode is set to
WebAssemblyorAuto, register the Blazor service in Program.cs files of both the server and client projects in your Blazor Web App. ForServerrender mode, register it in the server project’s Program.cs only.
NOTE
AddSyncfusionBlazor()accepts optional configuration options such as enabling script isolation. See the Blazor service registration topic for available configuration options.
Register Syncfusion License Key
Register the Syncfusion license key in your application startup to avoid a license warning at runtime. Add the following line in the Program.cs file of your Blazor Web App (and in the client project’s Program.cs for WebAssembly/Auto render modes), after the AddSyncfusionBlazor() call:
// Register Syncfusion license key
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR_LICENSE_KEY");NOTE
Replace
YOUR_LICENSE_KEYwith your actual Syncfusion license key. For details on generating and registering a license key, see Licensing.
Add stylesheet resource
The theme stylesheet can be accessed from NuGet through Static Web Assets. Include the stylesheet at the end of the <head> section in the Components/App.razor file to apply proper layout and theme styling.
<!-- Syncfusion Blazor components theme -->
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />Add script resource
The Spreadsheet Editor script can be accessed from NuGet through Static Web Assets. Include the required script at the end of the <body> section in the Components/App.razor file to enable component functionality.
<!-- Syncfusion Blazor Spreadsheet Editor script -->
<script src="_content/Syncfusion.Blazor.Spreadsheet/scripts/syncfusion-blazor-spreadsheet.min.js" type="text/javascript"></script>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 Components/Pages/Home.razor file (the default page template). If the interactivity location is set to Per page/component in the Web App, define a render mode at the top of the Components/Pages/Home.razor file. (For example, InteractiveServer, InteractiveWebAssembly or InteractiveAuto).
NOTE
If the Interactivity Location is set to
GlobalwithAutoorWebAssembly, the render mode is automatically configured in theApp.razorfile by default and does not need to be specified on the page.
@page "/"
@using Syncfusion.Blazor.Spreadsheet
<SfSpreadsheet>
<SpreadsheetRibbon></SpreadsheetRibbon>
</SfSpreadsheet>NOTE
SpreadsheetRibbonis the optional ribbon toolbar child component ofSfSpreadsheet. Omit it if you want to render the spreadsheet without the ribbon UI.
Press Ctrl+F5 (Windows) or ⌘+F5 (macOS) to launch the application. This will render the Syncfusion Blazor Spreadsheet in your default web browser. The output will appear as follows:

You can also experiment directly using the interactive playground below for a quick demo:
To learn how to open workbooks, bind data, or save files in the Spreadsheet component, see Open and Save.
NOTE
Video tutorial
To get started quickly with Blazor Spreadsheet, you can watch this video: