Creating a data table and then writing all its data to an Excel file

In this project, we will build a data table dynamically and then write all its data to an Excel file:

  1. Drag and drop a Build data table activity from the Activities panel. Double-click on this activity. A window will pop up. Two columns have been generated automatically; delete these two columns. Add your column by clicking on the + icon and specify the column name. You can also select your preferred data type. You are free to add any number of columns:
  1. In this project, we are adding two columns. The procedure for adding the second column is almost the same. You just have to specify a name and its preferred data type. We have added one more column (Roll) and set the data type to Int32 in the data table. We have also initialized this data table by giving some values to its rows.

Create a variable of type Data Table. Give it a meaningful name. Specify this data table's name in the Data Table property of the Build data table activity. We have to supply this variable in order to get the data table that we have built:

 

Our data table has been built successfully.

  1. Drag and drop the Excel application scope inside the main Designer window. Specify the Excel sheet's path or manually select it. Connect this activity to the Build Data table activity:
  1. Inside the Excel application scope activity, drag and drop the Write Range activity. Specify the data table variable name that we created earlier and set it as a Data table property inside thWrite Range activity. We can also specify the range. In this case, we have assigned it as an empty string:
  1. That's it. Hit the Run button or press F5 to see the result.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.107.90