Importing Data from a DataTable to Grid
Contents
[
Hide
]
Since the release of the .NET Framework, Microsoft has provided an excellent way to store data in offline mode in the form of a DataTable object. Understanding the needs of developers, Aspose.Cells.GridDesktop also supports importing data from a data table. This topic discusses how to do this.
Example
To import the contents of a data table using Aspose.Cells.GridDesktop control:
- Add Aspose.Cells.GridDesktop control to a form.
- Create a DataTable object that contains the data to be imported.
- Get the reference of a desired worksheet.
- Import the data table contents to the worksheet.
- Set the column headers of the worksheet according to column names of the data table.
- Set the width of the columns, if desired/
- Display the worksheet.
In the example given below, we have created a DataTable object and filled it with some data fetched from a database table named Products. Finally, we have imported data from that DataTable object to a desired worksheet using Aspose.Cells.GridDesktop.