OfficeIMO.Word
1.0.41
Prefix Reserved
See the version list below for details.
dotnet add package OfficeIMO.Word --version 1.0.41
NuGet\Install-Package OfficeIMO.Word -Version 1.0.41
<PackageReference Include="OfficeIMO.Word" Version="1.0.41" />
<PackageVersion Include="OfficeIMO.Word" Version="1.0.41" />
<PackageReference Include="OfficeIMO.Word" />
paket add OfficeIMO.Word --version 1.0.41
#r "nuget: OfficeIMO.Word, 1.0.41"
#:package OfficeIMO.Word@1.0.41
#addin nuget:?package=OfficeIMO.Word&version=1.0.41
#tool nuget:?package=OfficeIMO.Word&version=1.0.41
OfficeIMO.Word — .NET Word Utilities
OfficeIMO.Word is a cross‑platform .NET library for creating and editing Microsoft Word (.docx) documents on top of Open XML.
- Targets: netstandard2.0, net472, net8.0, net9.0
- License: MIT
- NuGet:
OfficeIMO.Word - Dependencies: DocumentFormat.OpenXml, SixLabors.ImageSharp
AOT / Trimming notes
- Core Word APIs avoid private reflection; converters are AOT‑aware.
- Macro removal uses OpenXmlPackage reflection and is annotated for trimming.
Quick starts and runnable samples live in OfficeIMO.Examples/Word/*.
Install
dotnet add package OfficeIMO.Word
Hello, Word
using OfficeIMO.Word;
using var doc = WordDocument.Create("example.docx");
var p = doc.AddParagraph("Hello OfficeIMO.Word");
p.SetBold();
doc.Sections[0].Headers.Default.AddParagraph("Header");
doc.Sections[0].Footers.Default.AddParagraph("Page ");
doc.Sections[0].Footers.Default.AddPageNumber();
doc.Save();
Common Tasks by Example
Paragraphs and runs
var p = doc.AddParagraph("Title");
p.SetBold();
p = doc.AddParagraph("Body text");
p.AddText(" with italic").SetItalic();
p.AddText(" and code").SetFontFamily("Consolas");
Tables
var t = doc.AddTable(3, 3);
t[1,1].Text = "Header 1"; t[1,2].Text = "Header 2"; t[1,3].Text = "Header 3";
t.HeaderRow = true; t.Style = WordTableStyle.TableGrid;
t.MergeCells(2,1, 2,3); // row 2, col 1..3
Images
var imgP = doc.AddParagraph();
imgP.AddImage("logo.png", width: 96, height: 32);
Headers, footers, and page numbers
var sec = doc.Sections[0];
sec.Headers.Default.AddParagraph("Report");
var f = sec.Footers.Default;
f.AddParagraph().AddText("Page ");
f.AddPageNumber();
Hyperlinks
doc.AddParagraph().AddHyperLink("OpenAI", new Uri("https://openai.com/"));
Append another document
using var destination = WordDocument.Load("report-main.docx");
using var appendix = WordDocument.Load("report-appendix.docx");
destination.AppendDocument(appendix);
destination.SaveAs("report-merged.docx");
Sample: OfficeIMO.Examples/Word/MergeDocuments/MergeDocuments.Basic.cs
Fields
var para = doc.AddParagraph();
var field = para.AddField(WordFieldType.Date, wordFieldFormat: WordFieldFormat.ShortDate);
Mail Merge (MERGEFIELD)
var para2 = doc.AddParagraph();
// Simple MERGEFIELD with a custom format
para2.AddField(WordFieldType.MergeField, customFormat: "CustomerName");
// Advanced builder for complex instructions/switches
var builder = new WordFieldBuilder(WordFieldType.MergeField)
.CustomFormat("OrderTotal")
.Format(WordFieldFormat.Numeric);
para2.AddField(builder);
Footnotes / Endnotes
var r = doc.AddParagraph("See note").AddText(" ");
r.AddFootNote("This is a footnote.");
Content controls
var sdtPara = doc.AddParagraph("Name: ");
var dd = sdtPara.AddDropDownList(new[]{"Alpha","Beta","Gamma"});
Shapes and charts (basic)
var shp = doc.AddShape(ShapeTypeValues.Rectangle, 150, 50);
shp.FillColorHex = "#E7FFE7"; shp.StrokeColorHex = "#008000";
var ch = doc.AddChart(ChartType.Bar, 400, 250);
ch.AddSeries("S1", new[]{1,3,2});
ch.AddLegend(LegendPositionValues.Right);
ch.SetXAxisTitle("Categories");
ch.SetYAxisTitle("Values");
Watermarks
doc.SetTextWatermark("CONFIDENTIAL", opacity: 0.15);
Protection
doc.ProtectDocument(enforce: true, password: "secret");
Table of Contents (TOC)
// Add headings (styles must map to heading levels)
doc.AddParagraph("Chapter 1").SetStyle("Heading1");
doc.AddParagraph("Section 1.1").SetStyle("Heading2");
// Insert TOC near the top (field will update on open)
doc.Paragraphs[0].AddField(WordFieldType.TOC);
Converters — HTML / Markdown / PDF
// HTML
using OfficeIMO.Word.Html;
var html = WordHtmlConverter.ToHtml(doc);
var doc2 = WordHtmlConverter.FromHtml("<h1>Hi</h1><p>Generated</p>");
// Markdown
using OfficeIMO.Word.Markdown;
var md = WordMarkdownConverter.ToMarkdown(doc);
var doc3 = WordMarkdownConverter.FromMarkdown("# Title\nBody");
// PDF
using OfficeIMO.Word.Pdf;
doc.SaveAsPdf("out.pdf");
HTML via Markdown (OfficeIMO.Markdown)
using OfficeIMO.Word.Markdown; // also uses OfficeIMO.Markdown under the hood
// Full HTML document or embeddable fragment produced via Markdown pipeline
var htmlDoc = doc.ToHtmlViaMarkdown();
var htmlFrag = doc.ToHtmlFragmentViaMarkdown();
// Save to file (supports external CSS sidecar via HtmlOptions)
doc.SaveAsHtmlViaMarkdown("report.html");
Fluent API Shortcuts
Common shortcuts for composing content:
H1..H6(string)— adds styled heading paragraphsP(string)— adds a plain paragraphUl(Action<ListBuilder>)— bulleted list; supports.Item,.ItemLink,.ItemTaskOl(Action<ListBuilder>)— numbered list; supports.Item,.ItemLinkParagraph(pb => pb.Text/Link/Bold/Italic/Underline/Strike/Code/InlineImage(...))— inline helpersTable(tb => tb.Headers(...).Row(...).Rows(...))— convenience wrappers
Example
using OfficeIMO.Word.Fluent;
var fluent = new WordFluentDocument(doc)
.H1("Report")
.P("All‑in‑one DNS/TLS report.")
.Ul(ul => ul.Item("SPF/DKIM/DMARC").ItemLink("Docs", "https://evotec.xyz"))
.Ol(ol => ol.Item("Step one").Item("Step two"))
.Paragraph(p => p.Bold("Note:").Text(" Works with Markdown too."));
Feature Highlights
- Document: create/load/save, clean/repair, compatibility settings, protection, append/merge other
.docxfiles - Sections: margins, size/orientation, columns, headers/footers (first/even/odd)
- Paragraphs/Runs: bold/italic/underline/strike, shading, tabs, breaks, justification
- Tables: create, merge/split, borders/shading, widths, header row repeat, page breaks
- Images: add from file/stream/base64/URL, wrap/layout, crop/opacity/flip/rotate, position
- Hyperlinks: internal/external with tooltip/target
- Fields: add/read/remove/update (DATE, TOC, PAGE, MERGEFIELD, etc.)
- Footnotes/Endnotes: add/read/remove
- Bookmarks/Cross‑references: add/read/remove
- Content controls (SDT): checkbox/date/dropdown/combobox/picture/repeating section
- Shapes/SmartArt: basic shapes with fill/stroke; SmartArt detection
- Charts: pie/bar/line/combo/scatter/area/radar with axes, legends, multiple series
- Styles: paragraph/run styles, borders, shading
Explore
OfficeIMO.Examples/Word/*for complete scenarios.
Detailed Feature Matrix
- 📄 Documents
- ✅ Create/Load/Save, SaveAs (sync/async); clean & repair
- ✅ Compatibility settings; document variables; protection (read‑only recommended/final/enforced)
- ⚠️ Digital signatures (basic scenarios); ✅ macros (add/extract/remove modules)
- 📑 Sections & Page Setup
- ✅ Orientation, paper size, margins, columns
- ✅ Headers/footers (default/even/first), page breaks, repeating table header rows, background color
- ✍️ Paragraphs & Runs
- ✅ Styles (paragraph/run); bold/italic/underline/strike; shading; alignment; indentation; line spacing; tabs/tab stops
- ✅ Find/replace helpers
- 🧱 Tables
- ✅ Create/append; built‑in styles (105); borders/shading; widths; merge/split (H/V); nested tables
- ✅ Row heights and page‑break control; merged‑cell detection
- 🖼️ Images
- ✅ From file/stream/base64/URL; alt text
- ✅ Size (px/pt/EMU); wrap/layout; crop; transparency; flip/rotate; position; read/write EMU sizes
- 🔗 Links & Bookmarks
- ✅ External/internal hyperlinks (tooltip/target); bookmarks; cross‑references
- 🧾 Fields
- ✅ Add/read/remove/update (DATE, PAGE, NUMPAGES, TOC, MERGEFIELD, …)
- ✅ Simple and advanced representations; custom formats
- 📝 Notes
- ✅ Footnotes and endnotes: add/read/remove
- 🧩 Content Controls (SDT)
- ✅ Checkbox, date picker, dropdown, combobox, picture, repeating section
- 📊 Charts
- ✅ Pie/Bar/Line/Combo/Scatter/Area/Radar; axes/legends/series; axis titles
- ⚠️ Formatting depth varies by chart type
- 🔷 Shapes/SmartArt
- ✅ Basic AutoShapes with fill/stroke; ⚠️ SmartArt detection/limited operations
Dependencies & Versions
- DocumentFormat.OpenXml: 3.3.x (range [3.3.0, 4.0.0))
- SixLabors.ImageSharp: 2.1.x
- License: MIT
Converters (adjacent packages)
- HTML:
OfficeIMO.Word.Html(AngleSharp) — convert to/from HTML - Markdown:
OfficeIMO.Word.Markdown— convert to/from Markdown using OfficeIMO.Markdown - PDF:
OfficeIMO.Word.Pdf(QuestPDF/SkiaSharp) — export to PDF
Note: Converters are in active development and will be released to NuGet once they meet quality and test coverage goals. Until then, they ship in‑repo for early evaluation.
Notes on Versioning
- Minor releases may include additive APIs and perf improvements.
- Patch releases fix bugs and compatibility issues without breaking APIs.
Notes
- Cross‑platform: no COM automation, no Office required.
- Deterministic save order to keep Excel/Word “file repair” dialogs at bay.
- Nullable annotations enabled; APIs strive to be safe and predictable.
| 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)
- SixLabors.ImageSharp (>= 2.1.11)
-
.NETStandard 2.0
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
- SixLabors.ImageSharp (>= 2.1.11)
-
net10.0
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
- SixLabors.ImageSharp (>= 2.1.11)
-
net8.0
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
- SixLabors.ImageSharp (>= 2.1.11)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on OfficeIMO.Word:
| Package | Downloads |
|---|---|
|
OfficeIMO.Word.Html
HTML converter for OfficeIMO.Word - Convert Word documents to/from HTML using AngleSharp |
|
|
OfficeIMO.Word.Markdown
Markdown converter for OfficeIMO.Word - Convert Word documents to/from Markdown using OfficeIMO.Markdown |
|
|
OfficeIMO.Reader
Unified, read-only document extraction facade for OfficeIMO (Word/Excel/PowerPoint/Markdown/PDF) intended for AI ingestion. |
|
|
OfficeIMO.Word.Pdf
PDF converter for OfficeIMO.Word - Export Word documents to PDF using QuestPDF |
|
|
NTI.Toolkit.Reports
Create Html-, Txt-, Docx- and Xlsx-Reports. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on OfficeIMO.Word:
| Repository | Stars |
|---|---|
|
EvotecIT/PSWriteOffice
Experimental PowerShell Module to create and edit Microsoft Word, Microsoft Excel, and Microsoft PowerPoint documents without having Microsoft Office installed.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.43 | 3,458 | 4/10/2026 |
| 1.0.42 | 245 | 4/9/2026 |
| 1.0.41 | 763 | 4/3/2026 |
| 1.0.40 | 321 | 4/1/2026 |
| 1.0.39 | 1,254 | 3/23/2026 |
| 1.0.38 | 360 | 3/19/2026 |
| 1.0.37 | 231 | 3/18/2026 |
| 1.0.36 | 270 | 3/18/2026 |
| 1.0.35 | 572 | 3/16/2026 |
| 1.0.34 | 312 | 3/15/2026 |
| 1.0.33 | 625 | 3/13/2026 |
| 1.0.32 | 2,314 | 2/21/2026 |
| 1.0.31 | 973 | 2/19/2026 |
| 1.0.30 | 483 | 2/18/2026 |
| 1.0.29 | 256 | 2/18/2026 |
| 1.0.28 | 255 | 2/17/2026 |
| 1.0.27 | 306 | 2/16/2026 |
| 1.0.26 | 447 | 2/15/2026 |
| 1.0.25 | 165 | 2/15/2026 |
| 1.0.24 | 120 | 2/15/2026 |