# General Information

The `RadSpreadProcessing` document model allows you to open and save files of different formats. The following sections provide more details on the [supported formats](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadprocessing/formats-and-conversion/general-information#supported-formats), [available format providers](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadprocessing/formats-and-conversion/general-information#format-providers), the [additional package references](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadprocessing/formats-and-conversion/general-information#additional-package-references) each provider requires, and the [Format Providers Manager](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadprocessing/formats-and-conversion/general-information#format-providers-manager).

## Supported Formats

The following table lists the supported formats:

| Format                    | Description                                                                                                                                                                                                             |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Xlsx`                    | Rich text format that exports the whole content of a workbook: worksheets, formula values, formatting, hyperlinks, and more.                                                                                            |
| `Xls`                     | Rich text format that exports the content of a workbook: worksheets, formula values, formatting, hyperlinks, and more. Supported in older applications.                                                                 |
| `Xlsm`                    | Rich text format that exports all that is included in the Xlsx format with the addition of macro instructions.                                                                                                          |
| `Pdf` *(export only)*     | Fixed format that preserves the content of a workbook in a manner independent from software or hardware.                                                                                                                |
| `Csv` *(comma separated)* | Plain text format that saves the content of the cell in the active worksheet. The format strips all formatting and keeps only the result values of cells. These values are separated by a culture-dependent delimiter.  |
| `Txt` *(tab delimited)*   | Plain text format that preserves only the content of the cells in the active worksheet. The format does not save any formatting and keeps only the result values of the cells. These values are delimited through tabs. |
| `Json` *(export only)*    | Structured text format that serializes worksheet data and metadata (values, number formats, named ranges, charts, active sheet info) to JSON. Styling is not preserved fully as in XLSX.                                |
| `DataTable`               | Allows you to convert a `DataTable` from your database to a spreadsheet and vice versa.                                                                                                                                 |

> note In **Q4 2024** Telerik Document Processing Libraries introduced a new timeout mechanism for importing and exporting documents. The **Import** and **Export** methods of all FormatProviders have a mandatory *TimeSpan?* timeout parameter after which the operation is cancelled.

## Format Providers

The document model exposes separate format providers that work with each of the formats listed previously:

* [XlsxFormatProvider](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadprocessing/formats-and-conversion/import-and-export-to-excel-file-formats/xlsx/xlsxformatprovider) for `.xlsx` files
* [XlsFormatProvider](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadprocessing/formats-and-conversion/import-and-export-to-excel-file-formats/xls/xlsformatprovider) for `.xls` files
* [XlsmFormatProvider](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadprocessing/formats-and-conversion/import-and-export-to-excel-file-formats/xlsm/xlsmformatprovider) for `.xlsm` files
* [PdfFormatProvider](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadprocessing/formats-and-conversion/pdf/pdfformatprovider) for `.pdf` files (export only)
* [CsvFormatProvider](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadprocessing/formats-and-conversion/csv/csvformatprovider) for comma separated `.csv` files
* [TxtFormatProvider](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadprocessing/formats-and-conversion/txt/txtformatprovider) for tab delimited `.txt` files
* [DataTableFormatProvider](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadprocessing/formats-and-conversion/data-table/using-data-table-format-provider) for `DataTable` objects
* [JsonFormatProvider](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadprocessing/formats-and-conversion/json/jsonformatprovider) for `.json` files (export only)

> Some FormatProviders require additional package references. Check them out in the [Additional Package References](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadprocessing/formats-and-conversion/general-information#additional-package-references) section.

## Import and Export Methods

All of the listed providers implement the `IWorkbookFormatProvider` and `IBinaryWorkbookFormatProvider` interfaces and share a common API that enables import and export of files. To conform to the interfaces, each of the providers implements two methods that turn a `Stream` or `byte[]` into a workbook and save the contents of the workbook into a `Stream` or `byte[]`. In the [IWorkbookFormatProvider interface methods](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadprocessing/formats-and-conversion/general-information#iworkbookformatprovider-interface-methods) and [IBinaryWorkbookFormatProvider interface methods](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadprocessing/formats-and-conversion/general-information#ibinaryworkbookformatprovider-interface-methods) sections you can see the interface declarations and an example usage of the Import and Export methods.

### IWorkbookFormatProvider Interface Methods

**IWorkbookFormatProvider: Stream-based import and export members**

```C#
public interface IWorkbookFormatProvider
{
    string Name { get; }
    string FilesDescription { get; }
    IEnumerable<string> SupportedExtensions { get; }
    bool CanImport { get; }
    bool CanExport { get; }

    //Import and Export methods with Stream support
    void Export(Workbook workbook, Stream output, TimeSpan? timeout = null);
    Workbook Import(Stream input, TimeSpan? timeout = null);
}
```

**Example: Import a workbook from a stream and export it back to XLSX**

```C#
string path = "MyWorkbook.xlsx";
Telerik.Documents.Spreadsheet.Model.Workbook workbook;
var formatProvider = new Telerik.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.XlsxFormatProvider();

//Import
using (Stream input = new FileStream(path, FileMode.Open))
{
    workbook = formatProvider.Import(input, TimeSpan.FromSeconds(10));
}

//Export
using (Stream output = new FileStream(path, FileMode.Create))
{
    formatProvider.Export(workbook, output, TimeSpan.FromSeconds(10));
}
```

### IBinaryWorkbookFormatProvider Interface Methods

**IBinaryWorkbookFormatProvider: byte\[] import and export members**

```C#
public interface IBinaryWorkbookFormatProvider : IWorkbookFormatProvider
{
    //Overloading IWorkbookFormatProvider's Import and Export methods to support byte[]
    byte[] Export(Workbook workbook);
    Workbook Import(byte[] input);
}
```

**Example: Import a workbook from a byte array and export it back to byte\[]**

```C#
var path = "MyWorkbook.xlsx";
Telerik.Documents.Spreadsheet.Model.Workbook workbook;
var formatProvider = new Telerik.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx.XlsxFormatProvider();

//Import
byte[] fileAsByteArray = File.ReadAllBytes(path);
workbook = formatProvider.Import(fileAsByteArray, TimeSpan.FromSeconds(10));

//Export
byte[] workbookAsByteArray = formatProvider.Export(workbook, TimeSpan.FromSeconds(10));
```

> note For more examples of importing and exporting workbooks, check out the [Import/Load and Export/Save RadSpreadProcessing Workbook](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/import-export-save-load-workbook) knowledge base article.

## Additional Package References

Unlike the `CsvFormatProvider`, `TxtFormatProvider`, and `DataTableFormatProvider` classes, the other RadSpreadProcessing format providers require references to additional packages:

| Format Provider                               | Required Package                                                |
| --------------------------------------------- | --------------------------------------------------------------- |
| `XlsxFormatProvider` and `XlsmFormatProvider` | `Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml` |
| `PdfFormatProvider` *(export only)*           | `Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf`     |
| `XlsFormatProvider`                           | `Telerik.Windows.Documents.Spreadsheet.FormatProviders.Xls`     |
| `JsonFormatProvider` *(export only)*          | `Telerik.Windows.Documents.Spreadsheet.FormatProviders.Json`    |

> note \*Starting with **Q2 2025** the Zip Library will no longer be used as an internal dependency in the rest of the Document Processing Libraries - PdfProcessing, WordsProcessing, SpreadProcessing, SpreadStreamProcessing. It will be replaced by the System.IO.Compression. The Telerik Zip Library will continue to ship as a standalone library so clients can still use it separately.

## Format Providers Manager

The document model of RadSpreadProcessing also contains a `WorkbookFormatProvidersManager` class, which exposes a whole set of useful static methods. The manager also allows you to specify a set of format providers you want to use. Then you can import and export a file and let the manager choose the appropriate format provider. You only need to specify the extension of the file that you open or save.

More information on the Format Providers Manager and the `WorkbookFormatProvidersManager` class can be found in the dedicated [Format Providers Manager](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadprocessing/formats-and-conversion/import-export-format-providers-manager) article.

## See Also

* [Activate a Worksheet](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadprocessing/working-with-worksheets/activate-worksheet)
* [Timeout Mechanism](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/timeout-mechanism-in-dpl)
