var_columnNames = {"Name"}
dt_new = new DataView(dt_input).ToTable(false, var_columnNames)
But it seems three consecutive columns have the same name as Payment in and UiPath shows an error for duplicated Column Names. So I am trying with Add Headers as unchecked.
Can you suggest me if I am on the right track or a better approach?
If you just want to remove some columns, you can just delete from the DataTable variable and write back to excel using methods like DataTable.Columns.Remove(“columnName”) or by index DataTable.Columns.RemoveAt(columnIndex).
ok, since the only way will be remove the columns you dont want, see attached solution that you can invoke passing the columns to keep as easy parameter: CleanDataTable.xaml (5.4 KB)
Thanks @bcorrea your shared workflow looks promising. So this VB code will remove the columns with respect to columnNames. Now before I ask, how to pass the columnNames which I want to keep, can we tweak the code block to keep the columns with respect to the column index e.g. column1, column5, column17, column3?
Thanks again @bcorrea I think this workflow will solve my issue but before applying it I have to ensure the DataTable gets populated properly (which was an initial barrier due to duplicate column name within the downloaded excel from SAP) . Please bear with me.