Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
This article explains how to export your Worksheet data to a DataTable using C#. It covers the following topics
Format: Excel
Format: XLS
Format: XLSX
Format: ODS
Aspose.Cells not only facilitates its users to import data to worksheets from external data sources but also allows them to export their worksheet data to a DataTable. As we know that DataTable is part of ADO.NET and is used to hold data. Once the data is stored in a DataTable, it can be used in any way according to the requirements of users. Developers can also store this data (stored in DataTable) directly to a database if they wish. So, we can see that it becomes easier for the developers to manipulate worksheet data if it is exported to a DataTable.
Developers can easily export their worksheet data to a DataTable object by calling either ExportDataTable or ExportDataTableAsString method of the Cells class. Both methods are used in different scenarios, which are discussed below in more detail.
We know that a spreadsheet stores data as a sequence of rows and columns. If all values in the columns of a worksheet are strongly typed (that means all values in a column must have the same data type) then we can export the worksheet content by calling the ExportDataTable method of the Cells class. The ExportDataTable method takes the following parameters to export worksheet data as a DataTable object:
Steps: Exporting Data to DataTable
Code Steps:
If all values in the columns of a worksheet are not strongly typed (that means the values in a column may have different data types) then we can export the worksheet content by calling the ExportDataTableAsString method of the Cells class. The ExportDataTableAsString method takes the same set of parameters as that of the ExportDataTable method to export worksheet data as a DataTable object.
Data from a range can be exported to a DataTable where a flag is available to skip the header row in the exported data. The following code exports a range of data to a DataTable with an argument ExportTableOptions, which contains the ExportColumnName flag. It is set to true if header information is present, in which case the header will be excluded from the data, and set to false if no header is present and all rows are considered data.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.