I need to create a excel file . I need to add different column names to that file. After that I need to use write range activity to write datatable to excel file…
My question is how to add column names to a new created blank excel file.
Hi
Being a blank excel we won’t get any datatable out of it
So rather reading a blank excel file
We can directly create a datatable with BUILD DATATABLE activity with n number of columns we want
Then we can add records with ADD DATAROW activity and then write back to the same blank excel file with WRITE RANGE activity
Another option without using a datatable is to open one Excel file using Excel Application Scope. If you require a format or template in the origin sheet (sheet to be copied) this can also come in handy. After that use Copy Sheet activity and provide destination path and sheet name of the target excel file. With this, you have full control on what sheetname to use. You can use a For Each loop to automate the sheet creation in the target file.
To populate the contents of the target excel file and sheet, just open the file and use Write Range.
Fine
Add Datarow activity has two ways of giving input
One is like array or values (which is equal to number of columns) and another one is as a DataRow variable
So for the first we can pass the value as array like this {“value1”,”value2”,…”valuen”} and here the number of elements we mention must b equal to number of columns
And in another way it’s DataRow variable that is of type System.Data.DataRow
We usually see row variable in FOR EACH ROW activity right…it’s of that type variable only
So that can be either passed as input
And input datatable to which we want to add the row
Here is my file. Before writing data table EmpSort to excel (i.e before using WRITE RANGE activity), I need to add three column names to my excel file.How is it possible? sample.xaml (7.0 KB)