How to get column and save it in DataTable?

Hi all,

I’m trying to pass the data from two columns to a new DataTable object But when I get these columns with ’ Read column ', I obtain an IEnumerable object so I can’t save it in the DataTable.

I have looked at the previous publications to see if they could help me but I can not find something to guide me.

Could someone help me? Thank you.

Hi @joseluisgomez82

I think it might be better if you read your columns with a Read Range activity. If they are next to each other, then you only need one Read Range activity and then you can work with Data Table variables rather than IEnumerable.
Merging two Data Tables should not be a problem then.

Have you tried using add data column activity?

Hello @loginerror , sorry for not answering before, the columns are not together, they are separate, which would be worth to get the data from a single column and then take the next one I would like.

The way you tell me already try but I can not get a column in a DataTable variable, thanks.

Hello @Divyashreem,

If I try but that activity if I’m not wrong is to create a new Column and I do not want to create a new column, I want to take the data from one column of an excel, then take another and both put them in a DataTable to be able to paint it in an excel sheet Thank you

dt test.xaml (6.4 KB)

@joseluisgomez82 Try this component.
dtMasterData is your original Datatable.
In the second assign you have this statement

dtFinalData = view.ToTable(“TableName”,false, “ColumnName1”, “ColumnName2”).
Simply replace ColumnName1 and ColumnName2 with the names of the columns in your original DT and they will be created in your dtFinalData.

You can easily add new columns to the same statement like: view.ToTable(“TableName”,false, “ColumnName1”, “ColumnName2”, “Column3”, “Column4”, etc…).


@PaulKis It served Me, thank you very much.