# Using DocxFormatProvider

DOCX is part of Office Open XML, a zipped, XML-based format that Microsoft uses for word-processing documents. `RadWordsProcessing` supports this format. DOCX is the default format in Microsoft Word starting with Microsoft Office 2007.

`DocxFormatProvider` follows the Office Open XML `ECMA-376` specification. Use it to import DOCX documents into `RadFlowDocument` instances and export `RadFlowDocument` instances to DOCX files. The provider preserves the document structure and formatting that both `RadWordsProcessing` and DOCX support.

To use `DocxFormatProvider`, add references to these packages:

* `Telerik.(Windows).Documents.Core`
* `Telerik.(Windows).Documents.Flow`

> note Starting with **Q2 2025**, Telerik Document Processing no longer uses the [Zip Library](https://www.telerik.com/document-processing-libraries/documentation/libraries/radziplibrary/overview) as an internal dependency in PdfProcessing, WordsProcessing, SpreadProcessing, and SpreadStreamProcessing. The libraries use `System.IO.Compression` instead. Telerik Zip Library still ships as a standalone library.

## Import

To import a DOCX document, use the `Import()` method of `DocxFormatProvider`.

The following code shows how to use `DocxFormatProvider` to import a DOCX document from a file.

**Example 1: Open a Sample.docx file stream and import it into a RadFlowDocument**

```C#
Telerik.Documents.Flow.Model.RadFlowDocument document;

Telerik.Documents.Flow.FormatProviders.Docx.DocxFormatProvider provider = new Telerik.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();

using (Stream input = File.OpenRead("Sample.docx"))
{
    document = provider.Import(input, TimeSpan.FromSeconds(10));
}
```

You can also import a document from a byte array that contains the DOCX file:

**Example 2: Read a Sample.docx file into a byte array and import it into a RadFlowDocument**

```C#
Telerik.Documents.Flow.FormatProviders.Docx.DocxFormatProvider provider = new Telerik.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();
byte[] input = File.ReadAllBytes("Sample.docx");
Telerik.Documents.Flow.Model.RadFlowDocument document = provider.Import(input, TimeSpan.FromSeconds(10));
```

The resulting `RadFlowDocument` can be modified like any document that you create in code.

## Export

To export a document to DOCX, use the `Export()` method of `DocxFormatProvider`.

The following code shows how to use `DocxFormatProvider` to export a `RadFlowDocument` to a file.

**Example 3: Export a RadFlowDocument to a Sample.docx file stream**

```C#
Telerik.Documents.Flow.Model.RadFlowDocument document;

Telerik.Documents.Flow.FormatProviders.Docx.DocxFormatProvider provider = new Telerik.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();

using (Stream output = File.OpenWrite("Sample.docx"))
{
    document = CreateRadFlowDocument(); // CreateRadFlowDocument() is a custom method that creates a simple instance of RadFlowDocument. You can replace it with the instance you would like to export.

    provider.Export(document, output, TimeSpan.FromSeconds(10));
}
```

You can also export the document to a byte array and store it in a database.

**Example 4: Export a RadFlowDocument directly to a DOCX byte array**

```C#
Telerik.Documents.Flow.FormatProviders.Docx.DocxFormatProvider provider = new Telerik.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();

Telerik.Documents.Flow.Model.RadFlowDocument document = CreateRadFlowDocument(); // CreateRadFlowDocument() is a custom method that creates a simple instance of RadFlowDocument. You can replace it with the instance you would like to export.

byte[] output = provider.Export(document, TimeSpan.FromSeconds(10));
```

The resulting documents can be opened in applications that support DOCX files.

## See Also

* [Review DOCX settings](https://www.telerik.com/document-processing-libraries/documentation/libraries/radwordsprocessing/formats-and-conversion/word-file-formats/docx/settings)
* [Check supported DOCX features](https://www.telerik.com/document-processing-libraries/documentation/libraries/radwordsprocessing/formats-and-conversion/word-file-formats/docx/features)
* [Learn about timeout handling](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/timeout-mechanism-in-dpl)
* [Understand output stream clearing on export](https://www.telerik.com/document-processing-libraries/documentation/common-information/clear-output-stream-on-export)
