Help with error message

I made an automation with UI Path, which takes data from an Excel sheet and inserts it into certain apps. I encountered the following error, after executing the activity “read range workbook”.

The weird thing is that in the excel spreadsheet there si no column named 'n.carta id.

System.Data.DuplicateNameException: A column named 'n.carta id.’ already belongs to this DataTable.

but I

I would suggest that use read range and uncheck “AddHeaders” this way you would not have to worry about column names. Just refer to the columns by using column index

Show us how you have your Read Range activity configured. Post screenshots.

@Letizia_Scelzi

The error message you’re encountering, System.Data.DuplicateNameException: A column named 'n.carta id.’ already belongs to this DataTable, suggests that there’s an attempt to add a column with a name that already exists in the DataTable. This situation can arise even if the column name doesn’t appear directly in the Excel spreadsheet. Here are a few steps to troubleshoot and resolve this issue:

  • Check the Excel File Headers: Although you mentioned that there’s no column named ‘n.carta id.’ in the Excel spreadsheet, it’s possible that there’s a header row with a similar name, such as ‘n.carta id’. Ensure that the column headers in your Excel file are correctly formatted and unique.
  • Check for Hidden Columns or Rows: Sometimes, hidden columns or rows in Excel can cause issues when reading data into UiPath. Make sure that there are no hidden columns or rows containing the header ‘n.carta id’ in your Excel file.
  • Use Range Instead of Named Range: Instead of using the entire workbook as a range, try specifying a specific range that excludes any unexpected columns. This can help avoid reading data from unintended columns.
1 Like

This error indicates that a column named “n.carta id” already exists in your Excel spreadsheet, but you are trying to add it again. You will need to either rename the column in Excel to avoid naming conflicts, or change the data reading settings in UI Path so that it uses a different name for the new column. Make sure your settings match the structure of your Excel spreadsheet to avoid errors when reading the data.


thank you all for your help.
Please find attached the screenshot of the automation

thank you, I tried unchecking the add headers checkbox but I got the attached image error
image

I also tried to rename the column in Excel to avoid naming conflicts, but I get the same error.

hi @Letizia_Scelzi,

Pass a datatable variable to you read range activity based on the screenshot there is no output. Uncheck Add headers and use indexes to refer to columns. Alternatively do a Ctrl + F on your workbook to try finding the column name and then rename it to something unique

1 Like

hi @Letizia_Scelzi could you provide a screenshot of your code? regards

how can I view the code and share that?

Hey @Letizia_Scelzi ,

Create a variable of type data table which in your case is ‘var_raw2’. Assign this to the output field in the properties panel of Read Range Activity.

The exception 'Null Reference happens ’ when you don’t have value in variable which you are trying to process further on.

According to the snap shot you have shared ‘var_raw2’ hasn’t been assigned any value yet is used in for each loop.

Please assign it to the output field in the properties panel of read range activity.

Thanks,
Gautham.

hi @Letizia_Scelzi open your studio, look at the code and take a screenshot with snipping tool. does that help you? cheers

This is because you have unchecked headers now and somewhere in your code you might have reffered to those header names, for example CurrentRow(“Header/ColumnName”).ToString. This can be solved by using the column index instead like CurrentRow(0).ToString

Hi Letizia,

Try to use Modern Excel activities. Check attached workflow. In Classic experience, we are getting same error which you are facing but in Modern experience we can able to get the row data.

Excel.zip (8.7 KB)