A file with the .ODT file extension is an OpenDocument Text document file. These files are most often created by the free OpenOffice Writer word processor program. ODT files are similar to the popular DOCX file format used with Microsoft Word. Both of the two file types can hold things like text, images, objects, and styles.
However, when you open an ODT document in Microsoft Word, the formatting of the ODT document may differ as a result of the two programs not sharing the same features. When converting ODT to DOCX or vice versa, the data and content will be converted successfully, but may not including the original formatting.
Following code snippets introduce how to convert ODT to DOC or DOCX and vice versa using Spire.Doc.
ODT to DOCX
To convert ODT to DOC, change the file extension and file format to .Doc in SaveToFile method.
using Spire.Doc; namespace ODTtoDOCX { class Program { static void Main(string[] args) { Document doc = new Document(); doc.LoadFromFile("SampleODTFile.odt"); doc.SaveToFile("output.docx", FileFormat.Docx) } } }
Imports Spire.Doc Namespace ODTtoDOCX Class Program Private Shared Sub Main(args As String()) Dim doc As New Document() doc.LoadFromFile("SampleODTFile.odt") doc.SaveToFile("output.docx", FileFormat.Docx) End Sub End Class End Namespace
DOCX to ODT
To convert Doc to ODT, load a .Doc file format document when loading the source file.
using Spire.Doc; namespace DOCXtoODT { class Program { static void Main(string[] args) { Document doc = new Document(); doc.LoadFromFile("SampleODTFile.odt"); doc.SaveToFile("output.docx", FileFormat.Docx); } } }
Imports Spire.Doc Namespace DOCXtoODT Class Program Private Shared Sub Main(args As String()) Dim doc As New Document() doc.LoadFromFile("SampleODTFile.odt") doc.SaveToFile("output.docx", FileFormat.Docx) End Sub End Class End Namespace