Datatable.DefaultView Segmented Column Name

Hi,

I want to take half of columns in an excel sheet which have 10 columns.

I’m using the method dt.defaultView. There is a column name;
“MY
COLUMN
NAME”

I tried Assign like;

dt_1.DefaultView.ToTable(False,“COL1”, “MY” + System.Environment.NewLine + “COLUMN” + System.Environment.NewLine + “NAME”, “COL2”, “COL3”, “COL4”, “COL5”)

But it says there is no column name
“MY
COLUMN
NAME”

How can i take that segmented column with DefaultView?

Any help appreciated.

Fine
Let’s do one thing
Use a assign activity like this
str_colName = Datatable.Columns(columnindex).ColumnName.ToString

Where mention the column index of that column to get the exact column name
Usually column index starts from 0 for the first column

Then use DefaultView method like this
dt_1.DefaultView.ToTable(False,“COL1”, str_colName, “COL2”, “COL3”, “COL4”, “COL5”)

Cheers @ercanebiler

1 Like

Yeah I tried that it works. But lets think a case;

Indexes can change. That’s why i want to move on with column names. Do you suggest anything?

1 Like

May I know why it changes
Actually for a solid process the datatable structure should not or won’t change buddy

@ercanebiler

Sometimes we can’t develope the dream work :slight_smile: Our robots mostly depends to humans. We are saying you can’t change anything, they know that but they change it :slight_smile: Can’t trust humans.

Hehe :slight_smile:
Cheers @ercanebiler

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