If you ever need to add functionality to your application to enable you to export an excel file as a Dataset, instead of coding it by yourself, use this control. Using this you can let the user select the column names of the datatable in the exported Dataset. You can also restrict the user to select column names from a list of specified column names.
This control uses
System.Data.OleDbClient namespace to connect to the excel file as a data store. It doesn't need MS Excel to be installed on the computer.
Using the code
- Copy Gopal.Data.Transform.dll to your application folder. Right click on the toolbox and select 'Add/Remove components' as shown below.
- Now select '
ExcelExportControl' from 'Gopal.Data.Transform' assembly and press 'OK' as shown below.
- The '
ExcelExportControl' has now been added to the toolbox and can be used.
- This control will now allow you to load an excel file. You can select the first row as the column names by checking the checkbox which says so.
- The first tabpage lets you preview all the sheets in the excel file.
- The second tabpage lets you select an output dataset name, datatable name and column names too.
The download package has the source code, assembly and a demo form using the assembly.