Reading Excel file as Preserving formatting giving issue as Excel containes 2 columns with same header

HI,

My Excel file have 2 colums with same header and the file is generated form a finance system.

like.
Column C header is = “Item Type”
Column D header is also = “Item Type”
But the values in column C is number and value in columns D is description.

I can not read this file as preserve format how to solv this…

Act im reading the file first and save data to an output variable then i use the same output data to edit the columns names.

1 Like

Hi @Latif if the headers are same , then u can retrive values by using their rowindex

Lets say

Lets say Item Type having values in in first column and other in second

So First one had rowindex 0 and other had rowindex 1 so based on rowindex u can retrive values
like this

row(0).ToString like that

1 Like

Hi @Latif,
you can use @NIVED_NAMBIAR, Method.

if your excel column indexs keep changing you can just refer the below method

so, you can change the column name and try like this dataTable.Columns(“Item Type”).ColumnName = "Description"

Now you can use different headers to fetch the details.

Cheers
@Latif

1 Like

thanks …
but i have still not solved this issue as its keep saying me the column name exist.

Hi @Latif did u tried by using rowindex method I specified ?

First I read the file as preservformat and getting an output file.

Then I read the file again and doing 2 column name changes,

image
image

Now tell me what i do wrong and do i need to read the file and take an output file or not?