Master professional Pivot Table customization with Syncfusion Blazor components. Learn how to apply cell templates, conditional formatting rules, and programmatic styling for enterprise-grade business intelligence dashboards.
- 🎯 Quick Overview
- ✨ Key Features
- 🛠 Technology Stack
- 📋 Prerequisites
- 🚀 Quick Start Guide
- 🗂 Project Structure
- 💡 Core Concepts
- 🎨 Usage Examples
- ⚙️ Configuration & Customization
- ❓ FAQ & Troubleshooting
- 📖 Resources
- 🤝 Contributing
- 📄 License
This repository provides a production-ready reference implementation for building customizable Syncfusion Pivot Tables in Blazor WebAssembly applications. It demonstrates best practices for:
- Cell Template Customization — Apply custom HTML, icons, colors, and interactive elements
- Conditional Formatting — Dynamically style cells based on data values
- Programmatic Styling — Leverage C# logic for complex formatting rules
- Performance Optimization — Client-side rendering with WebAssembly efficiency
- Enterprise Reporting — Build professional dashboards for BI and analytics
- 📊 Energy sector analytics and reporting dashboards
- 💼 Business intelligence and KPI dashboards
- 📈 Financial analysis and risk reporting
- 🏢 Enterprise data visualization
- 🎓 Educational and training applications
| Feature | Description | Benefits |
|---|---|---|
| 🎨 Cell Templates | Custom HTML rendering in pivot table cells | Create rich, interactive data visualizations |
| 📊 Conditional Formatting | Dynamic color rules and styling based on values | Instantly highlight trends and anomalies |
| 💻 C# Integration | Server-side logic for complex formatting | Business rule engine for sophisticated analytics |
| ⚡ WebAssembly | Client-side rendering with optimal performance | Smooth interactions and reduced server load |
| 🔧 Syncfusion Components | Enterprise-grade UI controls | Professional appearance and consistent UX |
| 📦 Production-Ready | Best practices and clean architecture | Deploy with confidence to production |
| 🎯 Multi-Dimensional Analysis | Rows, columns, values, and filter configuration | Flexible data exploration and pivoting |
| 🌐 Cross-Browser Support | Works on all modern browsers | Universal compatibility and accessibility |
| Component | Version | Purpose |
|---|---|---|
| .NET | 8.0+ | Runtime framework |
| Blazor WebAssembly | 8.0 | Client-side framework |
| Syncfusion Blazor | Latest | UI component library |
| C# 12 | Latest | Programming language |
| Razor Components | 8.0 | UI markup language |
Ensure the following are installed on your development machine:
- Visual Studio 2022 (17.0+) or Visual Studio Code with C# support
- .NET 8.0 SDK or later (Download)
- Modern Web Browser (Chrome, Firefox, Edge, Safari) with WebAssembly support
- Git (optional, for version control)
- ✅ Windows 10/11, macOS 10.15+, or Ubuntu 18.04+
- ✅ 4GB RAM minimum (8GB recommended)
- ✅ 500MB free disk space
- ✅ Internet connection for NuGet package restoration
git clone https://github.com/SyncfusionExamples/Customize-the-appearance-of-a-Blazor-Pivot-Table-Using-Templates-and-Conditional-Formatting
cd Customize-the-appearance-of-a-Blazor-Pivot-Table-Using-Templates-and-Conditional-Formatting- Launch Visual Studio 2022
- Select File → Open → Project/Solution
- Navigate to
ConditionalFormatSample.sln - Wait for NuGet package restoration
Using Visual Studio:
- Press
Ctrl+Shift+Bor select Build → Build Solution
Using CLI:
dotnet buildUsing Visual Studio:
- Press
F5or click Debug → Start Debugging
Using CLI:
dotnet run --project ConditionalFormatSampleOpen your browser and navigate to:
https://localhost:7XXX
The pivot table will load with:
- Energy sector data visualization
- Conditional formatting applied to power units and revenue
- Interactive cell templates with custom styling
ConditionalFormatSample/
├── ConditionalFormatSample.sln # Solution file
├── README.md # Documentation
│
├── ConditionalFormatSample/ # Server project
│ ├── Program.cs # Application startup
│ ├── appsettings.json # Configuration
│ ├── Components/
│ │ ├── App.razor # Root component
│ │ ├── Routes.razor # Routing configuration
│ │ └── Layout/
│ │ └── MainLayout.razor # Master layout
│ └── wwwroot/
│ └── bootstrap/ # CSS frameworks
│
└── ConditionalFormatSample.Client/ # WebAssembly client
├── Program.cs # Client startup
├── _Imports.razor # Global imports
├── Data/
│ └── EnergyDetails.cs # Data model & sample data
└── Pages/
└── Counter.razor # Sample component
EnergyDetails.cs— Data model containing energy sector metricsProgram.cs— Blazor WebAssembly initialization and Syncfusion service registrationApp.razor— Root Blazor component with routing configuration
Cell templates allow you to render custom HTML in pivot table cells:
<CellTemplate>
@{
var data = context as EnergyDetails;
if (data != null)
{
<div style="background-color: #f0f0f0; padding: 5px;">
<strong>@data.Revenue</strong>
</div>
}
}
</CellTemplate>Apply dynamic formatting based on data values:
<ConditionalFormatSettings>
<ConditionalFormatRules>
<ConditionalFormatRule
Measure="Revenue"
Condition="GreaterThan"
Value1="100"
Style="HighValue" />
</ConditionalFormatRules>
</ConditionalFormatSettings>Use C# logic to dynamically apply formatting:
private string GetCellStyle(double value)
{
if (value > 150) return "background-color: green; color: white;";
if (value > 100) return "background-color: yellow; color: black;";
return "background-color: red; color: white;";
}@using Syncfusion.Blazor.PivotView
@using ConditionalFormatSample
<SfPivotView TValue="EnergyDetails"
Height="600px"
Width="100%">
<PivotViewDataSourceSettings TValue="EnergyDetails"
ExpandAll="false">
<PivotViewRows>
<PivotViewRow Name="Sector"></PivotViewRow>
</PivotViewRows>
<PivotViewColumns>
<PivotViewColumn Name="EnergyType"></PivotViewColumn>
</PivotViewColumns>
<PivotViewValues>
<PivotViewValue Name="PowerUnits" Type="SummaryTypes.Sum"></PivotViewValue>
<PivotViewValue Name="Revenue" Type="SummaryTypes.Sum"></PivotViewValue>
</PivotViewValues>
</PivotViewDataSourceSettings>
</SfPivotView><SfPivotView TValue="EnergyDetails" Height="600px">
<!-- Data source configuration -->
<ConditionalFormatSettings>
<ConditionalFormatRules>
<ConditionalFormatRule
Measure="Revenue"
Condition="GreaterThan"
Value1="150"
BackgroundColor="#00FF00"
FontColor="#000000" />
<ConditionalFormatRule
Measure="Revenue"
Condition="LessThan"
Value1="50"
BackgroundColor="#FF0000"
FontColor="#FFFFFF" />
</ConditionalFormatRules>
</ConditionalFormatSettings>
</SfPivotView>Register Syncfusion license in Program.cs:
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR_LICENSE_KEY");Replace sample data by modifying EnergyDetails.cs:
public static List<EnergyDetails> GetCustomData()
{
return new List<EnergyDetails>
{
new EnergyDetails
{
Sector = "Custom Sector",
PowerUnits = 100,
Revenue = 150
}
};
}Define custom CSS for formatting:
.high-value {
background-color: #2ecc71;
color: white;
font-weight: bold;
}
.low-value {
background-color: #e74c3c;
color: white;
}Q: Why is the pivot table not displaying?
A: Ensure Syncfusion services are registered in Program.cs:
builder.Services.AddSyncfusionBlazor();Q: How do I apply formatting to specific cells?
A: Use ConditionalFormatRules with appropriate Measure, Condition, and styling properties.
Q: Can I use external data sources?
A: Yes, replace the EnergyDetails model with your own data model and populate from databases or APIs.
Q: What's the performance impact of templates?
A: WebAssembly rendering is performant. For large datasets (10,000+ rows), consider virtual scrolling.
- 🔗 Syncfusion Blazor Pivot Table Docs: https://blazor.syncfusion.com/documentation/pivot-table/
- 🔗 Official Demo: https://blazor.syncfusion.com/demos/pivot-table/overview
Contributions are welcome! To contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/my-feature) - Open a Pull Request
This project is licensed under the Syncfusion Community License. See Syncfusion License for details.
For assistance and inquiries:
- 📧 Syncfusion Support: https://www.syncfusion.com/support
- 💬 Community Forum: https://www.syncfusion.com/forums
- 🐛 Report Issues: https://github.com/SyncfusionExamples/customize-blazor-pivot-table/issues