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.
Combined business report styles
Everything in this group applied to one sheet — merged title banner, styled header, highlighted inputs, currency columns, and a bold total row — including a style derived from another style with With(...).
using FormulaEngineer.Api;
using FormulaEngineer.Api.Styling;
using FormulaEngineer.Licensing;
var titleStyle =
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 headerStyle =
ExcelStyle.Default.With(
font: ExcelFontStyle.Default.With(
bold: true,
color: ExcelColor.FromRgb(255, 255, 255)),
fill: ExcelFillStyle.Solid(
ExcelColor.FromRgb(68, 114, 196)),
alignment: ExcelAlignmentStyle.Default.With(
horizontal: ExcelHorizontalAlignment.Center));
var inputStyle =
ExcelStyle.Default.With(
fill: ExcelFillStyle.Solid(
ExcelColor.FromRgb(255, 242, 204)));
var moneyStyle =
ExcelStyle.Default.With(
numberFormat: ExcelNumberFormatStyle.Custom("$#,##0.00"),
alignment: ExcelAlignmentStyle.Default.With(
horizontal: ExcelHorizontalAlignment.Right));
var totalStyle =
moneyStyle.With(
font: ExcelFontStyle.Default.With(
bold: true,
color: ExcelColor.FromRgb(255, 255, 255)),
fill: ExcelFillStyle.Solid(
ExcelColor.FromRgb(31, 78, 121)));
using (var writer = new ExcelStyledWriter("combined-business-report-styles.xlsx"))
{
using (var sheet = writer.CreateWorksheet("Report"))
{
sheet.MergeCells(1, 1, 1, 5);
sheet.WriteRow(
new object?[] { "Styled Business Report" },
titleStyle);
sheet.WriteRow();
sheet.WriteRow(
new object?[] { "Item", "Qty", "Unit price", "Net", "Tax" },
headerStyle);
sheet.WriteRow(
new object?[] { "License", 2, 499m, ExcelFormula.From("B4*C4"), ExcelFormula.From("D4*18%") },
new ExcelStyle?[] { null, inputStyle, inputStyle, moneyStyle, moneyStyle });
sheet.WriteRow(
new object?[] { "Support", 1, 275m, ExcelFormula.From("B5*C5"), ExcelFormula.From("D5*18%") },
new ExcelStyle?[] { null, inputStyle, inputStyle, moneyStyle, moneyStyle });
sheet.WriteRow(
new object?[] { "TOTAL", "", "", ExcelFormula.From("SUM(D4:D5)"), ExcelFormula.From("SUM(E4:E5)") },
new ExcelStyle?[] { totalStyle, totalStyle, totalStyle, totalStyle, totalStyle });
}
writer.Close();
}
Style your own workbooks
Styling is part of the same package — no separate install, no Excel, no COM automation.