Get specific columns from excel

Hello my dear friends,

I have this INSANE issue. But first of all let me explain:

  1. I have and excel sheet with 88 columns
  2. I want to extract 6 columns from it with the specific names, because the order of the columns changes every time
  3. I have tried multiple methods method:
    3.1. dt.Select(“[CN]” + “” + “[CN1]” + “” + …
    3.2 . dt.Select(“CN” + “” + “CN1” + “” + …
    3.3. dt.Select(“CN” + “CN1” + …
    3.4 And all the other tipes with ’ and “”

If you can please help me.

Apologies for the tag, because my version is 2018.2.3, but I didn’t find more relevant topic.

Regards,
Phoenix

Hi @Phoenixxx

U can use dtout.Select(“[Id]=”+customerid.ToString+“”).CopyToDatatable()

Instead of spaces and blanks

Thanks
Ashwin S

Hey @AshwinS2

Thank you for the fast reply.

customerid is the name of the second column. it is not a variable.
I am missing something basic, I think?

BR,
Phoenix

Hi @Phoenixxx

You can use DataView to achieve this.
Sample code is attached for your reference.

SelectColumn.xaml (10.4 KB)

Thanks,
pratik

1 Like

@Phoenixxx per my understanding you want to extract only those 6 columns into 1 dt. If yes then
You can use the below :slight_smile:
Dt.defaultview.Totable(False,“ColumnName1”,“ColumnName2”)
If not then can you explain it

1 Like

Much appreciated @ImPratham45 . Thank you a lot!

Welcome:blush::blush::blush:

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