Hi,
I want to remove multiple columns for an existing datatable from an excel. Is there any way to do this??
Thanks in advance.
Hi,
I want to remove multiple columns for an existing datatable from an excel. Is there any way to do this??
Thanks in advance.
Hi @sans.12,
You can use Remove Data Column activity to delete the datatable column by its index number or by its column name.
Regards,
Ranjith.
Thank you for the solution @ranjith. It worked.
Hi @ranjith,
Can I put multiple columns into the ColumnIndex field as I have too many columns to remove ?
Many thanks
Snowman
Instead of that i would prefer to use Dataview.
For more information look into this thread:
Regards…!!
Aksh
@Snowman, You can’t give multiple column Index/Name in Remove Data Column activity.
Whereas we have an alternate with the combination of LINQ->Datatable
Assign → String Array arrayOfColumnsToBeRemoved = {“Column1”,“Column2”}
Assign → Select a Array of ColumnNames without these columns from the datatable dt with the query
string Array arrayOfColumnsToBeSelected = (From col in dt.Columns.Cast(of System.Data.DataColumn) where not(arrayOfColumnsToBeRemoved.Contains(col.ColumnName)) Select CStr(col.ColumnName)).ToArray()
Assign → Datatable dt = dt.DefaultView.ToTable(false,arrayOfColumnsToBeSelected)
Regards,
Dom
Dear @aksh1yadav, @Dominic,
Very glad to have the advice promptly !! Thank you very much
Would you mind explaining this a little bit more? I am trying to delete some columns from an Excel file. Is this is 3 different “Assign” activities?
Thank you in advance!