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
10
examples
in Cells and text
Date and time number formats
Writes DateTime and TimeSpan values with yyyy-mm-dd, hh:mm, and the [h]:mm elapsed-hours format — the last of which keeps durations past 24 hours from wrapping back to zero.
Write.cs
using FormulaEngineer.Api;
using FormulaEngineer.Api.Styling;
using FormulaEngineer.Licensing;
var headerStyle =
ExcelStyle.Default.With(
font: ExcelFontStyle.Default.With(
bold: true,
color: ExcelColor.FromRgb(255, 255, 255)),
fill: ExcelFillStyle.Solid(
ExcelColor.FromRgb(31, 78, 121)));
var dateStyle =
ExcelStyle.Default.With(
numberFormat: ExcelNumberFormatStyle.Custom("yyyy-mm-dd"));
var timeStyle =
ExcelStyle.Default.With(
numberFormat: ExcelNumberFormatStyle.Custom("hh:mm"));
var durationStyle =
ExcelStyle.Default.With(
numberFormat: ExcelNumberFormatStyle.Custom("[h]:mm"));
using (var writer = new ExcelStyledWriter("date-time-formats.xlsx"))
{
using (var sheet = writer.CreateWorksheet("Schedule"))
{
sheet.WriteRow(
new object?[] { "Task", "Start date", "Start time", "Duration" },
headerStyle);
sheet.WriteRow(
new object?[]
{
"Import",
new DateTime(2026, 7, 22),
new DateTime(2026, 7, 22, 9, 30, 0),
TimeSpan.FromHours(2.5)
},
new ExcelStyle?[] { null, dateStyle, timeStyle, durationStyle });
sheet.WriteRow(
new object?[]
{
"Review",
new DateTime(2026, 7, 23),
new DateTime(2026, 7, 23, 14, 0, 0),
TimeSpan.FromHours(1.25)
},
new ExcelStyle?[] { null, dateStyle, timeStyle, durationStyle });
}
writer.Close();
}
Style your own workbooks
Styling is part of the same package — no separate install, no Excel, no COM automation.