Using the DataTableFormatProvider
The DataTableFormatProvider allows you to convert an existing DataTable 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.
Starting with Q1 2026, the
DataTableFormatProvidersupports the timeout mechanism 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 DataTable
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 DataTable to an Existing Worksheet
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 Worksheet to a DataTable
Workbook workbook = GetWorkbook();
DataTableFormatProvider provider = new DataTableFormatProvider();
DataTable table = provider.Export(workbook.ActiveWorksheet, TimeSpan.FromSeconds(10));