# Using the DataTableFormatProvider

The `DataTableFormatProvider` allows you to convert an existing [DataTable](https://learn.microsoft.com/en-us/dotnet/api/system.data.datatable?view=net-5.0) to a worksheet and vice versa. The following sections show how to use this format provider to import and export data tables.

To use the `DataTableFormatProvider`, reference the `Telerik.Windows.Documents.Spreadsheet` package.

> note Starting with Q1 2026, the `DataTableFormatProvider` supports the [timeout mechanism](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/timeout-mechanism-in-dpl) that was previously introduced for the rest of the providers.

## Import

The following example shows how to import a `DataTable`. The sample creates a `DataTableFormatProvider` instance and passes the table to its `Import` method.

**Example 1: Import a DataTable and create a new workbook from it**

```C#
DataTable table = GetTable();
DataTableFormatProvider provider = new DataTableFormatProvider();

Workbook workbook = provider.Import(table, TimeSpan.FromSeconds(10));
```

You can also import the data from a `DataTable` to an existing worksheet.

**Example 2: Import a DataTable into an existing worksheet**

```C#
DataTable table = GetTable();
DataTableFormatProvider provider = new DataTableFormatProvider();

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets.Add();

provider.Import(table, worksheet, TimeSpan.FromSeconds(10));
```

## Export

The following example demonstrates how to export an existing worksheet to a `DataTable`. The snippet assumes that you already have a workbook with some data.

**Example 3: Export the active worksheet from an existing workbook to a DataTable**

```C#
Workbook workbook = GetWorkbook();
			DataTableFormatProvider provider = new DataTableFormatProvider();

			DataTable table = provider.Export(workbook.ActiveWorksheet, TimeSpan.FromSeconds(10));
```

## See Also

* [Data Table Format Provider Settings](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadprocessing/formats-and-conversion/data-table/settings)
* [Populate Worksheet from DataTable Without DataTableFormatProvider](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/populate-worksheet-from-datatable-without-datatableformatprovider)
* [Generating Excel Documents from IEnumerable Collections](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/generate-excel-files-from-ienumerable-collections)
* [Converting PDF Table Content to DataTable](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/convert-pdf-table-to-datatable)
* [Timeout Mechanism](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/timeout-mechanism-in-dpl)
* [Processing Decimal Columns as Double when Importing a DataTable into a Workbook using RadSpreadProcessing](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/processing-decimal-columns-as-double-from-datatable)
