Back to Devexpress

How to: Export a Worksheet Range to a DataTable

officefileapi-118161-spreadsheet-document-api-examples-data-import-and-export-how-to-export-a-worksheet-range-to-a-data-table.md

latest1.3 KB
Original Source

How to: Export a Worksheet Range to a DataTable

  • Sep 19, 2023
  • 4 minutes to read

You can export data from a worksheet cell range to a DataTable. In this case, worksheet columns are transformed into DataTable columns. Cell values are used to populate the DataTable, and you can specify conversion methods and control the conversion process for every cell (analyze data and modify values as required).

To export cell values to a data table, perform the following steps.

  1. Create an empty DataTable that will be able to hold data of the worksheet range.

  2. Create a DataTableExporter instance using the WorksheetExtensions.CreateDataTableExporter method.

  3. Implement a custom converter for a specific DataTable column if required.

  4. Specify export options.

  5. Call the DataTableExporterExtensions.Export method.