Skip to content

Convert binary documents

Manfredi Marceca edited this page Apr 7, 2026 · 3 revisions

Convert Office 97-2003 documents

Convert DOC to DOCX

  1. Install the DocSharp.Binary.Doc package from NuGet

  2. Use the following code:

using WordprocessingDocument = DocSharp.Binary.OpenXmlLib.WordprocessingML.WordprocessingDocument;
using DocSharp.Binary.DocFileFormat;
using DocSharp.Binary.StructuredStorage.Reader;
// ...
using (var reader = new StructuredStorageReader(inputFile))
{
    var outputType = DocSharp.Binary.OpenXmlLib.WordprocessingDocumentType.Document; // Use Template type for .dot files
    var doc = new WordDocument(reader);
    using (var docx = WordprocessingDocument.Create(outputFile, outputType))
    {
        DocSharp.Binary.WordprocessingMLMapping.Converter.Convert(doc, docx);
    }
}

Input and output can be file paths or streams.

Convert XLS to XLSX

  1. Install the DocSharp.Binary.Xls package from NuGet

  2. Use the following code:

using SpreadsheetDocument = DocSharp.Binary.OpenXmlLib.SpreadsheetML.SpreadsheetDocument;
using DocSharp.Binary.Spreadsheet.XlsFileFormat;
using DocSharp.Binary.StructuredStorage.Reader;
// ...
using (var reader = new StructuredStorageReader(inputFile))
{
    var outputType = DocSharp.Binary.OpenXmlLib.SpreadsheetDocumentType.Workbook; // Use Template type for .xlt files
    var xls = new XlsDocument(reader);
    using (var xlsx = SpreadsheetDocument.Create(outputFile, outputType))
    {
        DocSharp.Binary.SpreadsheetMLMapping.Converter.Convert(xls, xlsx);
    }
}

Convert PPT to PPTX

  1. Install the DocSharp.Binary.Ppt package from NuGet

  2. Use the following code:

using PresentationDocument = DocSharp.Binary.OpenXmlLib.PresentationML.PresentationDocument;
using DocSharp.Binary.PptFileFormat;
using DocSharp.Binary.StructuredStorage.Reader;
// ...
using (var reader = new StructuredStorageReader(inputFile))
{
    var outputType = DocSharp.Binary.OpenXmlLib.PresentationDocumentType.Presentation; // Use Template type for .pot files, and Slideshow for .pps files
    var ppt = new PowerpointDocument(reader);
    using (var pptx = PresentationDocument.Create(outputFile, outputType))
    {
        DocSharp.Binary.PresentationMLMapping.Converter.Convert(ppt, pptx);
    }
}

Clone this wiki locally