How to read specific column by header columnname from an excel downloaded from SAP if the column has dynamic position and in the header are duplicate column names?


#1

I’ve tried reading the range but I get the DuplicateNameException and I don’t want to use hardcoded column range (e.g “B1”, C1") because the header is dependent of the layout chosen in SAP and the column I need to read is not always in the same position.
Is there any activity in uipath that I can get cell position (like “D1” for example) based on text?
Thanks!


#2

Is Name of column always the same (not position, just name)?


#3

Yes, it’s always the same. I don’t want to open the excel to find the text…


#4

You can always read excel file ( you do not have to open in foreground) and use for each activity, next lets say write line (row(“Columnname”).toString)


#5

For each activity on what? Because I can’t get the excel into a datatable due to the DuplicateNameException.


#6

Do you know which column names is duplciated? So you could replace the name to different one and then try to read as dataTable.


#7

I have also encountered a similar case. its because one of your column names is repeated by the same name in the header section and uipath expects header column names to be unique. You can try unchecking “Add headers” so that Uipath does not consider it as header or rename the duplicate column before attempting to read the excel.


#8

@Deebiga is he uncheck column names he will not be able to use column names option.
Remember that the columns is not always in the fixed place.


#9

Thank you, but then I don’t know which column to read because the column that I need to read can be the first one, the 13th or n-th column depending on the layout chosen before downloading the excel.


#10

For now I know which column is duplicated, but since the file is downloaded from SAP I cannot change it without manual intervention…