Importing Data from a DataTable to Grid
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.