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
Operations health dashboard
EnableSparklines EnableConditionalFormatting EnableShapesSeven days of uptime per service, each row ending in a trend sparkline and an AVERAGE health figure graded by traffic-light icons — a status board that recalculates itself.
Write.cs
using FormulaEngineer.Api;
using FormulaEngineer.Api.Styling;
var opt = new ExcelStylingOptions { EnableSparklines = true, EnableConditionalFormatting = 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(112, 48, 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(68, 68, 68)));
var pct = ExcelStyle.Default.With(numberFormat: ExcelNumberFormatStyle.Custom("0.0%"));
using (var writer = new ExcelStyledWriter("operations-health-dashboard.xlsx", null, opt))
{
using (var sheet = writer.CreateWorksheet("Operations"))
{
sheet.MergeCells(1, 1, 1, 10);
sheet.AddSparklineGroup(ExcelSparklineGroup.Create(new[]
{
ExcelSparkline.Create("'Operations'!$B$4:$H$4", 4, 9),
ExcelSparkline.Create("'Operations'!$B$5:$H$5", 5, 9),
ExcelSparkline.Create("'Operations'!$B$6:$H$6", 6, 9)
}, type: ExcelSparklineType.Line, showMarkers: true, showHighPoint: true, showLowPoint: true));
sheet.WriteRow(new object?[] { "Operations Health Dashboard" }, title);
sheet.WriteRow();
sheet.WriteRow(new object?[] { "Service", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "Trend", "Health" }, head);
sheet.WriteRow(new object?[] { "Formula API", 0.98, 0.99, 0.97, 0.99, 1.00, 0.98, 0.99, null, ExcelFormula.From("AVERAGE(B4:H4)") }, new ExcelStyle?[] { null, pct, pct, pct, pct, pct, pct, pct, null, pct });
sheet.WriteRow(new object?[] { "Import Worker", 0.91, 0.88, 0.94, 0.89, 0.93, 0.90, 0.92, null, ExcelFormula.From("AVERAGE(B5:H5)") }, new ExcelStyle?[] { null, pct, pct, pct, pct, pct, pct, pct, null, pct });
sheet.WriteRow(new object?[] { "Export Worker", 0.82, 0.79, 0.85, 0.81, 0.78, 0.84, 0.80, null, ExcelFormula.From("AVERAGE(B6:H6)") }, new ExcelStyle?[] { null, pct, pct, pct, pct, pct, pct, pct, null, pct });
sheet.AddConditionalFormat("J4:J6", ExcelConditionalFormat.IconSet(ExcelIconSet.ThreeTrafficLights1, new[]
{
ExcelConditionalFormatValue.Percent(0),
ExcelConditionalFormatValue.Percent(50),
ExcelConditionalFormatValue.Percent(80)
}));
sheet.AddShape(ExcelShape.Create(ExcelShapeKind.RoundedRectangle, ExcelDrawingAnchor.OneCell(2, 9, 260d, 70d), text: ExcelShapeText.Create("Weekly service health")));
}
writer.Close();
}
Style your own workbooks
Styling is part of the same package — no separate install, no Excel, no COM automation.