Available for: UI for ASP.NET MVC | UI for ASP.NET AJAX | UI for Blazor | UI for WPF | UI for WinForms | UI for Silverlight | UI for Xamarin | UI for WinUI | UI for ASP.NET Core

New to Telerik Document Processing? Download free 30-day trial

Import Settings

  • PreferredDateTimeFormat: This property gets or sets the default format string when importing DateTime columns.
  • ShouldImportColumnHeaders: Controls whether the column headers should be imported.
  • StartCellIndex: Get or sets the index where the table should start 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 that the event occurs for.
  • dataTableColumnIndex: The index of the column in the DataTable containing the cell that the event occurs for.
  • worksheetRowIndex: The index of the row in the Worksheet containing the cell that the event occurs for.
  • worksheetColumnIndex: The index of the column in the Worksheet containing the cell that the event occurs for.
  • worksheet: The worksheet where the data is imported.

Example 1: Using the CellImported event to format the cells

private void ImportTable() 
{ 
    DataTable table = GetTable(); 
    DataTableFormatProvider provider = new DataTableFormatProvider(); 
    provider.ImportSettings.CellImported += ImportSettings_CellImported; 
 
    Workbook workbook = new Workbook(); 
    Worksheet worksheet = workbook.Worksheets.Add(); 
 
    provider.Import(table, worksheet); 
 
    this.radSpreadsheet.Workbook = workbook; 
} 
private void ImportSettings_CellImported(object sender, CellImportedEventArgs e) 
{ 
    if (e.DataTableColumnIndex == 1 && e.WorksheetRowIndex > 1) 
    { 
        e.Worksheet.Cells[e.WorksheetRowIndex, e.WorksheetColumnIndex].SetForeColor(new ThemableColor(Colors.Red)); 
    } 
} 

Export Settings

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

See Also

In this article
Not finding the help you need? Improve this article