Create a column using unique column name value

Hi Developers,

How to fetch the unique value from one of the excel column and create a headers in different excel sheet using those unique value.

Thanks,
Riya

How to add headers in the data table - #5 by ppr Check this out pls …
Thank you

@Riya1

check out this reference

Hello Riya

You can read and loop the rows of the first Excel file, and then check to see if the values in the column with unique names exist in the second Excel file column names.
If not, then you can Add Data Column with the value.


Example file: Column Headers.xaml (9.2 KB)

Regards
Soren

Hi @Riya1

Try this

Uniquevalues = DT.AsEnumerable().Select(Function(row) row("YourColumnName").ToString).Distinct().ToList()

Regards,

Hi @lrtetala ,

Can you pls tell the data type of uniquevalues variable?
Also what is the type argument of for each loop? As i am getting below error:

I have used C# language.

Thanks,
Riya

Hi @SorenB ,

Given syntax is not working…As i am using C# language.Can u pls share the code in C#.

Thanks,
Riya

@Riya1

Use below query

Uniquevalues = DT.AsEnumerable().Select(row => row["YourColumnName"].ToString()).Distinct().ToList();

Regards,

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