FormulaEngineer examples
Create, read, and style Excel workbooks in .NET.
Style workbooks as you write them — fonts, fills, borders,
number formats, alignment, and layout — using
ExcelStyledWriter. Every example below is a complete,
runnable snippet.
Group
Cells and text
10
Layout
10
Conditional formatting
6
Named styles and themes
4
Tables and notes
10
Images and shapes
4
Charts and sparklines
6
Dashboards
4
Example
4
examples
in Dashboards
Sales performance dashboard
EnableCharts EnableSparklines EnableShapesQuarterly regional sales with a per-row trend sparkline, a SUM total column, currency formatting applied at column level, and a chart plus callout shape beneath the grid.
Write.cs
using FormulaEngineer.Api;
using FormulaEngineer.Api.Styling;
var opt = new ExcelStylingOptions { EnableCharts = true, EnableSparklines = true, EnableShapes = true };
var title = ExcelStyle.Default.With(font: ExcelFontStyle.Default.With(bold: true, size: 16d, color: ExcelColor.FromRgb(255, 255, 255)), fill: ExcelFillStyle.Solid(ExcelColor.FromRgb(31, 78, 121)), alignment: ExcelAlignmentStyle.Default.With(horizontal: ExcelHorizontalAlignment.Center));
var head = ExcelStyle.Default.With(font: ExcelFontStyle.Default.With(bold: true, color: ExcelColor.FromRgb(255, 255, 255)), fill: ExcelFillStyle.Solid(ExcelColor.FromRgb(68, 114, 196)));
var money = ExcelStyle.Default.With(numberFormat: ExcelNumberFormatStyle.Custom("$#,##0"));
using (var writer = new ExcelStyledWriter("sales-performance-dashboard.xlsx", null, opt))
{
using (var sheet = writer.CreateWorksheet("Sales"))
{
sheet.MergeCells(1, 1, 1, 7);
sheet.SetColumnStyle(1, ExcelColumnStyle.Default.With(width: 14d));
sheet.SetColumnStyle(2, ExcelColumnStyle.Default.With(width: 12d, style: money));
sheet.SetColumnStyle(3, ExcelColumnStyle.Default.With(width: 12d, style: money));
sheet.SetColumnStyle(4, ExcelColumnStyle.Default.With(width: 12d, style: money));
sheet.SetColumnStyle(5, ExcelColumnStyle.Default.With(width: 12d, style: money));
sheet.SetColumnStyle(6, ExcelColumnStyle.Default.With(width: 14d, style: money));
sheet.SetColumnStyle(7, ExcelColumnStyle.Default.With(width: 16d));
sheet.AddSparklineGroup(ExcelSparklineGroup.Create(new[]
{
ExcelSparkline.Create("'Sales'!$B$4:$E$4", 4, 7),
ExcelSparkline.Create("'Sales'!$B$5:$E$5", 5, 7),
ExcelSparkline.Create("'Sales'!$B$6:$E$6", 6, 7)
}, type: ExcelSparklineType.Line, showMarkers: true, showHighPoint: true));
sheet.WriteRow(new object?[] { "Sales Performance Dashboard" }, title);
sheet.WriteRow();
sheet.WriteRow(new object?[] { "Region", "Q1", "Q2", "Q3", "Q4", "Total", "Trend" }, head);
sheet.WriteRow("North", 12000, 14800, 13200, 16900, ExcelFormula.From("SUM(B4:E4)"), null);
sheet.WriteRow("South", 9800, 10200, 11900, 14100, ExcelFormula.From("SUM(B5:E5)"), null);
sheet.WriteRow("West", 7500, 9100, 10800, 12400, ExcelFormula.From("SUM(B6:E6)"), null);
sheet.AddShape(ExcelShape.Create(ExcelShapeKind.RoundedRectangle, ExcelDrawingAnchor.OneCell(9, 2, 180d, 70d), text: ExcelShapeText.Create("Live sales view")));
sheet.AddChart(ExcelChart.Create(ExcelChartKind.ColumnClustered, ExcelDrawingAnchor.OneCell(1, 9, 560d, 280d),
new[] { ExcelChartSeries.Create("Total", "'Sales'!$A$4:$A$6", "'Sales'!$F$4:$F$6") },
title: "Regional sales total"));
}
writer.Close();
}
Style your own workbooks
Styling is part of the same package — no separate install, no Excel, no COM automation.