OfficeIMO.Excel
0.6.46
Prefix Reserved
dotnet add package OfficeIMO.Excel --version 0.6.46
NuGet\Install-Package OfficeIMO.Excel -Version 0.6.46
<PackageReference Include="OfficeIMO.Excel" Version="0.6.46" />
<PackageVersion Include="OfficeIMO.Excel" Version="0.6.46" />
<PackageReference Include="OfficeIMO.Excel" />
paket add OfficeIMO.Excel --version 0.6.46
#r "nuget: OfficeIMO.Excel, 0.6.46"
#:package OfficeIMO.Excel@0.6.46
#addin nuget:?package=OfficeIMO.Excel&version=0.6.46
#tool nuget:?package=OfficeIMO.Excel&version=0.6.46
OfficeIMO.Excel - Excel workbooks for .NET
OfficeIMO.Excel is the main Excel package in the OfficeIMO family. It creates, edits, reads, and saves .xlsx workbooks without COM automation and without Microsoft Excel installed.
If OfficeIMO saves you time, please consider supporting the work through GitHub Sponsors or PayPal. PowerShell users should use PSWriteOffice for the PowerShell-facing experience.
Install
dotnet add package OfficeIMO.Excel
Quick start
using OfficeIMO.Excel;
using var document = ExcelDocument.Create("report.xlsx");
var sheet = document.AddWorkSheet("Data");
sheet.CellValue(1, 1, "Name");
sheet.CellValue(1, 2, "Value");
sheet.CellValue(2, 1, "Alpha");
sheet.CellValue(2, 2, 42);
sheet.AddTable("A1:B2", hasHeader: true, name: "DataTable", style: TableStyle.TableStyleMedium9);
sheet.AutoFitColumns();
document.Save();
What it does
- Creates and edits workbooks, worksheets, cells, ranges, tables, styles, hyperlinks, formulas, names, comments, images, charts, filters, and page setup.
- Reads values through worksheet, range, row, dictionary, stream, and typed object helpers.
- Supports editable row workflows where rows can be read, changed, and saved back.
- Handles practical workbook hygiene such as table/filter conflicts, safe table names, deterministic save order, and feature inspection.
- Includes parallel execution controls for heavy export and autofit workloads while serializing the Open XML mutation phase safely.
Examples
The quick start covers the smallest workbook. These examples show common read, write, reporting, and automation workflows that belong in OfficeIMO.Excel.
Read rows by header
using var document = ExcelDocument.Load("input.xlsx");
var sheet = document["Data"];
foreach (var row in sheet.Rows()) {
Console.WriteLine(row["Name"]);
}
Map rows to objects
using var document = ExcelDocument.Load("input.xlsx");
List<Person> people = document["Data"].RowsAs<Person>("A1:C100").ToList();
public sealed class Person {
public string Name { get; set; } = "";
public int Value { get; set; }
public string Status { get; set; } = "";
}
Append to an existing table
using var document = ExcelDocument.Load("sales.xlsx");
var rows = new DataTable();
rows.Columns.Add("Revenue", typeof(decimal));
rows.Columns.Add("Region", typeof(string));
rows.Rows.Add(150m, "APAC");
document["Sales"].AppendDataTableToTable(rows, "SalesTable");
document.Save();
Validation lists and typed reads
using var document = ExcelDocument.Load("input.xlsx");
var sheet = document["Data"];
sheet.ValidationList("C2:C100", new[] { "New", "Processed", "Hold" });
sheet.Range("D2:D100").Validate.WholeNumberBetween(1, 10, errorMessage: "Use 1 through 10");
List<RowModel> rows = document.Read()
.Sheet("Data")
.Range("A1:C100")
.AsObjects<RowModel>()
.ToList();
public sealed class RowModel {
public string Name { get; set; } = "";
public string Status { get; set; } = "";
}
Charts and dashboard recipes
using OfficeIMO.Excel;
using var document = ExcelDocument.Create("dashboard.xlsx");
var sheet = document.AddWorkSheet("Summary");
sheet.CellValue(1, 1, "Quarter");
sheet.CellValue(1, 2, "Revenue");
sheet.CellValue(2, 1, "Q1");
sheet.CellValue(2, 2, 10);
sheet.CellValue(3, 1, "Q2");
sheet.CellValue(3, 2, 18);
sheet.CellValue(4, 1, "Q3");
sheet.CellValue(4, 2, 24);
sheet.CellValue(5, 1, "Q4");
sheet.CellValue(5, 2, 30);
sheet.AddTable("A1:B5", hasHeader: true, name: "RevenueTable", style: TableStyle.TableStyleMedium2);
sheet.ChartFromTable("RevenueTable")
.RevenueTrend("Revenue trend")
.Size(640, 320)
.At(row: 1, column: 5);
document.Save();
Pivot tables and pivot-backed charts
using OfficeIMO.Excel;
using System.Linq;
using var document = ExcelDocument.Create("pivot-report.xlsx");
var sheet = document.AddWorkSheet("Sales");
sheet.CellValue(1, 1, "Region");
sheet.CellValue(1, 2, "Product");
sheet.CellValue(1, 3, "Quarter");
sheet.CellValue(1, 4, "Revenue");
sheet.CellValue(2, 1, "EMEA");
sheet.CellValue(2, 2, "Alpha");
sheet.CellValue(2, 3, "Q1");
sheet.CellValue(2, 4, 125000);
sheet.CellValue(3, 1, "EMEA");
sheet.CellValue(3, 2, "Beta");
sheet.CellValue(3, 3, "Q1");
sheet.CellValue(3, 4, 94000);
sheet.CellValue(4, 1, "APAC");
sheet.CellValue(4, 2, "Alpha");
sheet.CellValue(4, 3, "Q2");
sheet.CellValue(4, 4, 141000);
sheet.AddTable("A1:D4", hasHeader: true, name: "SalesTable", style: TableStyle.TableStyleMedium4);
sheet.Pivot("A1:D4")
.Rows("Region")
.Columns("Quarter")
.Filters("Product")
.Sum("Revenue", "Total revenue", "#,##0")
.Layout(ExcelPivotLayout.Tabular)
.Style("PivotStyleMedium9")
.Captions(rowHeader: "Region", columnHeader: "Quarter", grandTotal: "Total")
.At("F2", "SalesPivot");
var pivot = sheet.GetPivotTables().Single(p => p.Name == "SalesPivot");
Console.WriteLine($"{pivot.Name}: {string.Join(", ", pivot.RowFields)}");
var chart = sheet.ChartFromTable("SalesTable")
.VarianceColumns("Revenue by region")
.At(row: 12, column: 1);
chart.SetPivotSource("SalesPivot");
document.Save();
Pivot support is useful but still marked partial in the compatibility matrix. It covers source-range pivots, row/column/page/data fields, styles, layouts, filters, calculated fields, grouping metadata, and readback. Slicers, timelines, external connections, and query-table authoring are still preserve-oriented or roadmap areas.
Formula inspection and calculation policy
using var document = ExcelDocument.Load("report.xlsx");
var formulas = document.InspectFormulas();
Console.WriteLine(formulas.ToMarkdown());
foreach (var formula in formulas.Formulas.Where(f => !f.IsSupportedByOfficeIMO)) {
Console.WriteLine($"{formula.SheetName}!{formula.CellReference}: {formula.UnsupportedReason}");
}
int calculated = document.Calculate();
document.Save("report.xlsx", openExcel: false, options: new ExcelSaveOptions {
EvaluateFormulasBeforeSave = true,
ForceFullCalculationOnOpen = true
});
CSV and JSON exchange
using System.Data;
using var document = ExcelDocument.Load("data.xlsx");
var sheet = document["Data"];
DataTable table = sheet.ToDataTable("A1:C100");
string csv = sheet.ToCsv("A1:C100");
string json = sheet.ToJson("A1:C100");
sheet.FromCsv("Name,Amount\nAlpha,10\nBeta,20", startRow: 5, startColumn: 1);
sheet.FromJson("[{\"Name\":\"Gamma\",\"Amount\":30}]", startRow: 8, startColumn: 1);
Template markers
using var document = ExcelDocument.Load("invoice-template.xlsx");
int replacements = document.ApplyTemplate(new Dictionary<string, object?> {
["Invoice.Number"] = "INV-001",
["Customer.Name"] = "Adatum",
["Total"] = 123.45m
});
var template = document.InspectTemplate(new {
Invoice = new { Number = "INV-001" },
Customer = new { Name = "Adatum" },
Total = 123.45m
});
template.EnsureAllMarkersBound();
document.Save("invoice.xlsx");
Comments and conditional formatting
using var document = ExcelDocument.Load("review.xlsx");
var sheet = document["Data"];
sheet.SetComment("A1", "Review total", author: "Alice", initials: "AA");
sheet.UpdateComments(new ExcelCommentFilter { TextContains = "total" }, "Total reviewed", author: "Carol", initials: "CC");
sheet.AddConditionalColorScale("C2:C100", "#FFF0F0", "#70AD47");
sheet.Range("D2:D100").ConditionalFormat.DataBar("#5B9BD5");
document.Save();
Tune larger exports
using var document = ExcelDocument.Create("large-report.xlsx");
document.Execution.Mode = ExecutionMode.Automatic;
document.Execution.MaxDegreeOfParallelism = Environment.ProcessorCount;
document.Execution.SaveWorksheetAfterAutoFit = false;
Fluent compose
using var document = ExcelDocument.Create("composed-report.xlsx");
document.Compose("Report", composer => {
composer.Title("Demo Report", "Generated with OfficeIMO.Excel");
composer.Callout("info", "Heads up", "Generated via the fluent API");
composer.Section("Summary");
composer.PropertiesGrid(new (string, object?)[] {
("Author", "OfficeIMO"),
("Date", DateTime.Today.ToString("yyyy-MM-dd"))
});
var items = new[] {
new { Name = "Alice", Score = 90, Status = "OK" },
new { Name = "Bob", Score = 80, Status = "Warning" }
};
composer.TableFrom(items, title: "Scores", visuals: visuals => {
visuals.NumericColumnDecimals["Score"] = 0;
visuals.TextBackgrounds["Status"] = new Dictionary<string, string> {
["Warning"] = "#FFF3CD"
};
});
composer.HeaderFooter(header => header.Center("Demo Report").FooterRight("Page &P of &N"));
composer.Finish(autoFitColumns: true);
});
document.Save();
Adjacent packages
| Package | Use it for |
|---|---|
| OfficeIMO.Excel.Pdf | Excel to PDF export through OfficeIMO.Pdf, plus PDF table import to Excel. |
| OfficeIMO.Excel.GoogleSheets | Planning and exporting Excel content to Google Sheets. |
| OfficeIMO.Excel.Benchmarks | Benchmark harness for Excel workloads. |
Boundaries
OfficeIMO.Excelowns workbook modeling and Open XML read/write behavior.- PDF layout belongs in
OfficeIMO.Excel.PdfandOfficeIMO.Pdf. - Google Sheets export orchestration belongs in
OfficeIMO.Excel.GoogleSheets. - Long benchmark results and compatibility matrices belong in
Docs/, not this README.
Deeper docs
Targets and license
- Targets:
netstandard2.0,net8.0,net10.0;net472is included when building on Windows. - License: MIT.
- Repository: EvotecIT/OfficeIMO
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.7.2
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.8)
- OfficeIMO.Drawing (>= 1.0.20)
- System.Text.Json (>= 10.0.7 && < 11.0.0)
-
.NETStandard 2.0
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.8)
- OfficeIMO.Drawing (>= 1.0.20)
- System.Text.Json (>= 10.0.7 && < 11.0.0)
-
net10.0
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
- OfficeIMO.Drawing (>= 1.0.20)
-
net8.0
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
- OfficeIMO.Drawing (>= 1.0.20)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on OfficeIMO.Excel:
| Package | Downloads |
|---|---|
|
OfficeIMO.Reader
Unified, read-only document extraction facade for OfficeIMO (Word/Excel/PowerPoint/Markdown/PDF) intended for AI ingestion. |
|
|
OfficeIMO.Excel.Pdf
PDF converter for OfficeIMO.Excel - Export Excel workbooks to PDF using the first-party OfficeIMO.Pdf engine. |
|
|
OfficeIMO.Excel.GoogleSheets
Google Sheets planning and export scaffolding for OfficeIMO.Excel. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on OfficeIMO.Excel:
| Repository | Stars |
|---|---|
|
EvotecIT/PSWriteOffice
PowerShell Module to create and edit Microsoft Word, Microsoft Excel, and Microsoft PowerPoint documents without having Microsoft Office installed.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 0.6.46 | 204 | 6/16/2026 |
| 0.6.45 | 325 | 6/16/2026 |
| 0.6.44 | 525 | 6/15/2026 |
| 0.6.43 | 623 | 6/13/2026 |
| 0.6.42 | 617 | 6/12/2026 |
| 0.6.41 | 544 | 6/9/2026 |
| 0.6.40 | 678 | 6/5/2026 |
| 0.6.39 | 1,389 | 5/27/2026 |
| 0.6.38 | 529 | 5/26/2026 |
| 0.6.37 | 451 | 5/26/2026 |
| 0.6.36 | 780 | 5/23/2026 |
| 0.6.35 | 482 | 5/22/2026 |
| 0.6.34 | 451 | 5/21/2026 |
| 0.6.33 | 449 | 5/21/2026 |
| 0.6.32 | 448 | 5/20/2026 |
| 0.6.31 | 462 | 5/19/2026 |
| 0.6.30 | 438 | 5/18/2026 |
| 0.6.29 | 704 | 5/16/2026 |
| 0.6.28 | 453 | 5/14/2026 |
| 0.6.27 | 647 | 5/14/2026 |