Converting Word to ODT format
28 Aug 20242 minutes to read
The OpenDocument format (ODF) is an open file format for office documents originally developed for Open Office suite by Sun Microsystems. OpenDocument Text (ODT) is the file format for Word processing documents and currently for an OASIS and ISO standard.
Assemblies and NuGet packages required
Refer to the following links for assemblies and NuGet packages required based on platforms to convert a Word document to ODT file using the .NET Word Library (DocIO).
The Essential DocIO supports converting the Word document into ODT file. The following code example shows how to convert the Word document into ODT file.
NOTE
Refer to the appropriate tabs in the code snippets section: C# [Cross-platform] for ASP.NET Core, Blazor, Xamarin, UWP, .NET MAUI, and WinUI; C# [Windows-specific] for WinForms and WPF; VB.NET [Windows-specific] for VB.NET applications.
FileStream fileStreamPath = new FileStream("Template.docx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
//Opens an existing document from file system through constructor of WordDocument class
using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx))
{
//Saves the Word document to MemoryStream
MemoryStream stream = new MemoryStream();
document.Save(stream, FormatType.Odt);
//Closes the Word document
document.Close();
}
//Loads the existing Word document
WordDocument document = new WordDocument("Template.docx");
//Saves the document as ODT file
document.Save("WordToODT.odt", FormatType.Odt);
//Closes the document
document.Close();
'Loads the existing Word document
Dim document As New WordDocument("Template.docx")
'Saves the document as ODT file
document.Save("WordToODT.odt", FormatType.Odt)
'Closes the document
document.Close()
You can download a complete working sample from GitHub.
Supported Document elements
Document Element | Attribute | Support Status | Notes |
---|---|---|---|
Bookmark |
Id |
Yes |
- |
Border |
Color |
Yes |
- |
Distance from text |
No |
- |
|
Line style |
Yes |
- |
|
Line width |
Yes |
- |
|
Document Properties |
|
No |
- |
Field |
|
Partial |
For some of the fields, the field results have been preserved as span text. |
Footnotes and Endnotes |
|
No |
- |
Form Field |
|
No |
- |
Header / Footer |
Different per section |
Yes |
- |
Hyperlink |
External URL |
Yes |
- |
Local |
Yes |
- |
|
Image |
Inline |
Yes |
- |
Scale |
Yes |
- |
|
List |
Custom bullets |
No |
- |
Multi-level |
Yes |
- |
|
Numbered |
Yes |
- |
|
Restart numbering |
No |
- |
|
Standard bullets |
Yes |
- |
|
Comment |
|
No |
|
Symbols |
|
Yes |
|
Paragraph |
Alignment |
Yes |
|
|
Borders |
Yes |
See Borders, for more details. |
|
Keep lines and paragraphs together |
Yes |
- |
|
Paragraph Indents |
Yes |
- |
|
Line spacing |
Yes |
- |
|
Page break before |
No |
- |
|
Shading |
No |
|
|
Spacing before and after |
Yes |
- |
Shading |
Background color |
Yes |
|
|
Foreground color |
No |
|
Styles |
Paragraph styles |
Yes |
- |
|
Character styles |
Yes |
- |
|
List styles |
Yes |
- |
Table |
Alignment |
Yes |
- |
|
Cell margins |
Yes |
- |
|
Column widths |
Yes |
- |
|
Indent from left |
No |
- |
|
Preferred width |
No |
- |
|
Spacing between cells |
Yes |
- |
|
Borders |
Yes |
See Borders, for more details. |
|
Shading |
No |
|
Nested Table |
|
Yes |
|
Table Cell |
Borders |
Yes |
See Borders, for more details. |
|
Cell margins |
Yes |
- |
|
Horizontal merge |
No |
- |
|
Shading |
No |
|
|
Vertical alignment |
Yes |
- |
|
Vertical merge |
No |
- |
Table Row |
Height |
Yes |
- |
|
Padding |
Yes |
- |
Text |
All caps |
Yes |
- |
|
Bold |
Yes |
- |
|
Character spacing |
Yes |
- |
|
Color |
Yes |
- |
|
Emboss |
Yes |
Rendered as bold. |
|
Engrave |
No |
|
|
Font |
Yes |
- |
|
Hidden |
No |
- |
|
Highlighting |
Yes |
- |
|
Italic |
Yes |
- |
|
Line breaks |
Yes |
- |
|
Outline |
Yes |
Rendered as bold. |
|
Page breaks |
Yes |
- |
|
Shading |
No |
|
|
Small caps |
Yes |
- |
|
Special symbols |
Yes |
- |
|
Strike out |
Yes |
- |
|
Subscript / Superscript |
Yes |
- |
|
Underline |
Yes |
Online Demo
- Explore how to convert the Word document to ODT using the .NET Word Library (DocIO) in a live demo here.