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
Budget vs actual dashboard
EnableCharts EnableConditionalFormattingA departmental budget sheet where variance and utilisation are live formulas, utilisation carries data bars, and a two-series column chart compares budget against actual.
Write.cs
using FormulaEngineer.Api;
using FormulaEngineer.Api.Styling;
var opt = new ExcelStylingOptions { EnableCharts = true, EnableConditionalFormatting = 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(0, 112, 160)), 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(31, 78, 121)));
var money = ExcelStyle.Default.With(numberFormat: ExcelNumberFormatStyle.Custom("$#,##0"));
var pct = ExcelStyle.Default.With(numberFormat: ExcelNumberFormatStyle.Custom("0.0%"));
using (var writer = new ExcelStyledWriter("budget-vs-actual-dashboard.xlsx", null, opt))
{
using (var sheet = writer.CreateWorksheet("Budget"))
{
sheet.MergeCells(1, 1, 1, 5);
sheet.WriteRow(new object?[] { "Budget vs Actual Dashboard" }, title);
sheet.WriteRow();
sheet.WriteRow(new object?[] { "Department", "Budget", "Actual", "Variance", "Used %" }, head);
sheet.WriteRow(new object?[] { "Engineering", 50000, 47250, ExcelFormula.From("B4-C4"), ExcelFormula.From("C4/B4") }, new ExcelStyle?[] { null, money, money, money, pct });
sheet.WriteRow(new object?[] { "Marketing", 25000, 26890, ExcelFormula.From("B5-C5"), ExcelFormula.From("C5/B5") }, new ExcelStyle?[] { null, money, money, money, pct });
sheet.WriteRow(new object?[] { "Operations", 30000, 29110, ExcelFormula.From("B6-C6"), ExcelFormula.From("C6/B6") }, new ExcelStyle?[] { null, money, money, money, pct });
sheet.WriteRow(new object?[] { "Support", 18000, 16400, ExcelFormula.From("B7-C7"), ExcelFormula.From("C7/B7") }, new ExcelStyle?[] { null, money, money, money, pct });
sheet.AddConditionalFormat("E4:E7", ExcelConditionalFormat.DataBar(ExcelColor.FromRgb(68, 114, 196)));
sheet.AddChart(ExcelChart.Create(ExcelChartKind.ColumnClustered, ExcelDrawingAnchor.OneCell(1, 10, 560d, 280d),
new[]
{
ExcelChartSeries.Create("Budget", "'Budget'!$A$4:$A$7", "'Budget'!$B$4:$B$7"),
ExcelChartSeries.Create("Actual", "'Budget'!$A$4:$A$7", "'Budget'!$C$4:$C$7")
},
title: "Budget vs actual"));
}
writer.Close();
}
Style your own workbooks
Styling is part of the same package — no separate install, no Excel, no COM automation.