How to convert an ODT to DOCX in C# .Net Framework

Cloudmersive
2 min readJul 29, 2020

--

While ODT has its uses, it certainly is not always the most convenient or compatible format to have around. In today’s post, we will be solving this by simple converting our ODT files into DOCX. Rather than delving into the quagmire that is format parsing, we will use an API that can get it all done for us, with very little work required.

First we are going to install our client library:

Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 3.2.8

Following that, we will call our conversion function, as shown below here:

using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;namespace Example{public class ConvertDocumentOdtToDocxExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new ConvertDocumentApi();var inputFile = new System.IO.Stream(); // System.IO.Stream | Input file to perform the operation on.try{// Convert ODT Text File to Word DOCXbyte[] result = apiInstance.ConvertDocumentOdtToDocx(inputFile);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling ConvertDocumentApi.ConvertDocumentOdtToDocx: " + e.Message );}}}}

And just like that, we are finished with our Open Document Text conversion to Word DOCX format. Pretty easy, right?

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.