How to add only a particular column using LINQ

So i have an excel and i have to read a particular column only and copy that column data into datatable
How do i do this

(From row in dt.AsEnumerable
Select dt.Clone.Rows.Add({row(“ColumnName”)})).CopyToDataTable

Then use invoke code and remove unnecessary column names where target object is dt2.Columns and method is RemoveAt

1 Like

Hi @Goku

Check out this thread:

Regards,

@Goku

  1. Read range activity…into datatable dt
  2. Filter datatable activity and in columns tab give only the column you want to retain

Cheers

HI @Goku

Try like this

  • Read Range whole data and store them in the datatable and store them in a variable called DT
DT.DefaultView.ToTable(true,"Columnname")

This will get only that column

If you give true → It will remove duplicated and keep only the unique
False → It will keep the rows as it is

Regards
Sudharsan

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.