Get column name(header) and value sametime

An excel file I read as Excel application scope… then Read Rang output as (dtExcel)
An for each row activity…
Reading all the columns value and putting into variables and using those variable into a typeinto box to the webpage.

I figured out… that if i give a new excel file which has some more columns then old file and some columns have not the same columns name means then the value is 0…

Now i need to change this … so that i read row data and then add column name of that row to it… so that no hardcoaded column name to the inputfiled and that i can easly manage to give a new excel file.

Example:
test d, notest E, best F
input filed
columnsName(d) + vlaue
columnsName(e) + vlaue
columnsName(f) + vlaue

First you use Read Range
image

then For Each Row

inside for each use if activity and put condition like if you can check column name is test (If test column header in first column then use 0 ) or not .
Ex: out_dt_TransactionData.Columns(0).ToString.Contains(“test”)
This give you true or false

I do not want to give column name… thats the problem… bec column name is different from file to file… and that way i need to create a methord.

First 2 column is always same on each file… id and name…
rest can be different from file to file… and that way i want to output column name with value for the perticular row…

@Palaniyappan @ppr
can you help me on that…

when im getting row data through (for each row loop) I need each column name and its data… is it possible?

1 Like

Hi

In this situation instead of columnname we can use columnindex isn’t it
That is column index usually starts from 0 for the first column and instead of columnname within double quotes you can just mention as a number starting from 0 for the first column

By this way we don’t need to mention the columnname even we know it

And in general to get the columnname

The expression in assign activity
str_columnname = dt.Columns(columnindex).ColumnName.ToString

For example
str_columnname = dt.Columns(0).ColumnName.ToString

This gives the columnname of the first column name

And to get the value at the same time without columnname
Str_value = dt.Rows(rowindex)(columnindex).ToString

Both rowindex and columnindex starts with 0 for the first row and first columnname

Cheers @Latif

3 Likes

i agree with you
but problem is I know only first 2 columns with there name is it can not be change from excel file to excel file but rest how many columns exist in file i do not know and that it why i needed a solution…
how can i define index when i do not know how many index file have…

i did the soluton that i putted each column value in variable and I hardcoded the column name… in input filed…
but when i changed the file i figured out that some files did not had same column so it gave error first and then it shows the hardcoded column name but no value…

so that perticular thing i want to avoide.

Use dt.Columns.Count to get how many index each file have

1 Like

Thanks… for the help I choose anotherway to solv this solution. Thanks to all.

Hi @Palaniyappan

may i ask you one thing…

I have different Excel files and they have different columns w values… but some columns and value are same in each excel.

1’st option is:
user “Get Row Item” to get each columns value out by defining column name and put that value into variable.
2nd is same as get row item…
assign variable = row(“Column name”).ToString

Is there another way to solve this…

I have to put all this columns value into a text file after getting it later in flow… Så what it the good way to do this…
when Excel files columns are different from file to file.
And same I also want the column header before i insert the column value…
so can you help on that question

Is there another way
lots og 10 column’s with value i want to get from Excel from 1 Ex.

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