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 Named styles and themes
Theme colours and font schemes
EnableThemes EnableRichTextSets a workbook theme and references its accent colours and major font scheme by name rather than by RGB, so the sheet restyles itself if the theme is changed in Excel.
Write.cs
using FormulaEngineer.Api;
using FormulaEngineer.Api.Styling;
var stylingOptions =
new ExcelStylingOptions
{
EnableThemes = true,
EnableRichText = true
};
using (var writer = new ExcelStyledWriter("theme-colors-rich-report.xlsx", null, stylingOptions))
{
writer.SetTheme(ExcelTheme.Office);
var titleStyle =
ExcelStyle.Default.With(
font: ExcelFontStyle.Default.With(
bold: true,
size: 16d,
color: ExcelColor.FromTheme(ExcelThemeColor.Accent1),
scheme: ExcelFontScheme.Major));
var richStatus =
ExcelRichText.From(
new ExcelRichTextRun("Workbook theme: "),
new ExcelRichTextRun(
"Office",
ExcelFontStyle.Default.With(
bold: true,
color: ExcelColor.FromTheme(ExcelThemeColor.Accent2))));
using (var sheet = writer.CreateWorksheet("Theme"))
{
sheet.WriteRow(
new object?[] { "Theme-aware report" },
titleStyle);
sheet.WriteRow(richStatus);
sheet.WriteRow("Accent colors and theme font schemes are stored in the workbook theme part.");
}
writer.Close();
}
Style your own workbooks
Styling is part of the same package — no separate install, no Excel, no COM automation.