New to Telerik Document ProcessingStart a free 30-day trial

Settings

Updated on Jun 16, 2026

The DataTableFormatProvider exposes import and export settings that allow you to control how data is converted between DataTable and spreadsheet formats.

Import Settings

  • PreferredDateTimeFormat: Gets or sets the default format string when importing DateTime columns.
  • ShouldImportColumnHeaders: Controls whether the column headers are imported.
  • StartCellIndex: Gets or sets the index where the table starts in the Worksheet.

The CellImported Event

The CellImported event is fired for each cell and allows you to change the cell properties.

The CellImportedEventArgs contains information about the current cell:

  • dataTableRowIndex: The index of the row in the DataTable containing the cell for which the event occurs.
  • dataTableColumnIndex: The index of the column in the DataTable containing the cell for which the event occurs.
  • worksheetRowIndex: The index of the row in the Worksheet containing the cell for which the event occurs.
  • worksheetColumnIndex: The index of the column in the Worksheet containing the cell for which the event occurs.
  • worksheet: The worksheet where the data is imported.

Example 1: Using the CellImported Event to Format the Cells

C#
DataTable table = GetTable();
DataTableFormatProvider provider = new DataTableFormatProvider();
provider.ImportSettings.CellImported += (s, e) =>
{
    if (e.DataTableColumnIndex == 1 && e.WorksheetRowIndex > 1)
    {
        e.Worksheet.Cells[e.WorksheetRowIndex, e.WorksheetColumnIndex].SetForeColor(new ThemableColor(Colors.Red));
    }
};

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

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

radSpreadsheet.Workbook = workbook;

Export Settings

  • HasHeaderRow: Gets or sets whether the header row of the worksheet is exported.
  • ShouldSetDataTypes: Gets or sets whether the exporter tries to parse the data types from the spreadsheet. If false, only objects are exported.
  • DataTableCulture: Gets or sets the DataTable culture. By default, the culture of the workbook is used.
  • RangeToExport: Gets or sets the cell range for which the data is exported.

The ColumnExporting Event

The ColumnExporting event is fired for each column before the column is added to the table and allows you to change its properties.

The ColumnExportingEventArgs object contains the current column instance and its index:

  • DataColumn: Gets the DataColumn that is being exported.
  • ColumnIndex: Gets the index of the exported column.

Example 2: Using the ColumnExporting Event to Set the AllowDBNull Property

C#
DataTableFormatProvider provider = new DataTableFormatProvider();
provider.ExportSettings.ColumnExporting += (s, e) =>
{
    if (e.ColumnIndex == 3)
    {
        e.DataColumn.AllowDBNull = true;
    }
};
var table = provider.Export(radSpreadsheet.Workbook.ActiveWorksheet, TimeSpan.FromSeconds(10));

See Also