OpenDocument
Edit on GitHubCreate, read and edit ODT, ODS and ODP files in .NET without LibreOffice, and convert them to Word, Excel, PowerPoint and PDF with a report of anything lost.
- Packages
- OfficeIMO.OpenDocument
dotnet add package OfficeIMO.OpenDocument
- OfficeIMO.OpenDocument
- Works with
- .NET
- PowerShell
Install-Module PSWriteOffice - CLI
dotnet tool install --global OfficeIMO.Tool
- Target frameworks
- netstandard2.0, net10.0, net472
- APIs
- Limits
- Arbitrary producer-specific ODF signature profiles are inspected and preserved but not created; legacy Blowfish encryption fails before content is exposed. OfficeIMO.OpenDocument support matrix
- Verified
- Examples compiled against the source on
OfficeIMO.OpenDocument creates and edits ODT, ODS, ODP and ODG files directly. It depends only on OfficeIMO.Core and never invokes LibreOffice, Microsoft Office or UNO. Install the adapter packages when a workflow crosses into Office formats or PDF; each brings only the engine it needs.
| Package | Adds |
|---|---|
OfficeIMO.OpenDocument | OdtDocument, OdsDocument, OdpPresentation, OdgDocument, flat XML variants, encryption |
OfficeIMO.Word.OpenDocument | ODT to and from DOCX, ODT page images |
OfficeIMO.Excel.OpenDocument | ODS to and from XLSX, ODS page images |
OfficeIMO.PowerPoint.OpenDocument | ODP to and from PPTX, ODP slide images |
OfficeIMO.OpenDocument.Odt.Pdf, .Ods.Pdf, .Odp.Pdf | Each format to and from PDF |
dotnet add package OfficeIMO.OpenDocument
The task guides cover creating, reading and editing files, Office conversion and PDF and image export.
Create an ODT document
C#
using OfficeIMO.OpenDocument;
using OdtDocument document = OdtDocument.Create();
document.AddHeading("Summary", 1);
document.AddParagraph("Created without LibreOffice or Office.");
document.Save("summary.odt");
PowerShell
New-OfficeOpenDocument -Path ./summary.odt {
Add-OfficeOpenDocumentHeading -Text 'Summary' -Level 1
Add-OfficeOpenDocumentParagraph -Text 'Created without LibreOffice or Office.'
}
Remove hidden data before sharing
OdfDocument.Load opens any OpenDocument kind and returns the matching document type. The engine detects annotations, tracked changes, scripts, event listeners, external links, embedded objects, encryption and signatures, and never runs active content or fetches external resources.
C#
using OfficeIMO;
using OfficeIMO.OpenDocument;
using OdfDocument document = OdfDocument.Load("Report.odt");
Console.WriteLine($"{document.GetType().Name}");
OfficeHiddenDataReport report = document.RemoveHiddenData();
foreach (OfficeHiddenDataFinding finding in report.Findings) {
Console.WriteLine($"{finding.Outcome} {finding.Kind} at {finding.Location}");
}
document.Save("Report-shared.odt");
RemoveHiddenData removes identity metadata, annotations, speaker notes, the thumbnail, printer settings and image metadata, anonymizes the authors of tracked changes you keep, and reports each item.
CLI
officeimo hidden-data inspect Report.odt
officeimo hidden-data remove Report.odt --output Report-shared.odt
Choose a format
| Format | Typical content |
|---|---|
| ODT / FODT | Reports and policies: paragraphs, headings, lists, tables, images, fields, notes, headers, footers, tracked paragraph changes |
| ODS / FODS | Typed spreadsheet data, formulas with bounded recalculation, merges, named ranges, validations, charts, print ranges |
| ODP / FODP | Presentations: text, shapes, images, tables, masters and layouts, speaker notes, transitions, basic animations |
| ODG / FODG | Drawings: shapes, paths, connectors, text boxes, images, layers |
Unknown XML, vendor extensions and embedded content are preserved when their part is not replaced. Conversions report what they could not carry, so a pipeline can enforce its own fidelity policy. The package README lists the full editing surface.