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?

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?

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

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

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)

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

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

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.

@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.

1 Like

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.

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