I have an Excel sheet with a number of columns. For one of the columns I would like to split the data and write each split item into a new sheet, with an item on a new row, so there would only be one column.
I try the following but cant get it to work:
Read Range to get data in the worksheet into a DataTable
For Each row in DataTable
2.1 WriteLine to output for the column to split so I can see the data
2.2 Condition if column contains ; it shoud be splitted
2.2.1 Split the column data into an array String, variable stringSplitted
2.2.2 For Each item in stringSplitted
2.2.2.1 WriteLine item.ToSting() to output to see each item
2.2.2.2 Add Data Row item - !!! but this I cant get to work.
How can I item to the datatable with Add Data Row ?
Let us take you are having a datatable dta
You take new data table with out the column which you want to split. let us take it as dtb
dtc=dtb.Clone()
Add new Columns to the dataTable dtc by using Add DataColumn Activity based on the values.
dtc= (From p In dtb.Select
Let x= string.Join(",",p.ItemArray)+","+string.Join(",",dta(dta.Rows.IndexOf(p))("ColumnName").ToString.Split({"Split Parameter"},StringSplitOptions.None))
Select dtc.Rows.Add(x.Split({","},stringSplitOptions.None))).ToArray.CopyToDataTable
Column Name- Name of the column whose value you have to split. Split Parameter- Parameter based on which you have to split the value