Handling Excel Column Headers Not in the First Row for 'Select' Queries in UiPath

Context: I was working on a UiPath automation where I needed to use the ‘Select’ method on a DataTable. This DataTable was created by reading an Excel sheet where I intended to filter data based on a specific column.

Issue: I encountered an unexpected error stating “Assign: Cannot find column [ColumnName].” Despite confirming the presence of the specified column in Excel, the error persisted.

Discovery: Upon further investigation, I realized that the root cause was related to the placement of the column headers in the Excel file. In my case, the headers were not in the first row. Even though I specified in the ‘Read Range’ activity that the sheet contains headers, UiPath automatically inserted a new row at the beginning with default column names like ‘Column1’, ‘Column2’, etc., before the actual header row.

Solution: The key to resolving this issue was to delete the extra row that UiPath had added. After adjusting the range in the ‘Read Range’ activity to start from the actual headers and removing the additional row, the ‘Select’ method worked as expected.

The issue here isn’t the Select. It’s the Read Range. You should set the range to the first cell that contains the first header. In other words, if the headers are in Excel row 2 and start in column A, then set the range in Read Range to “A2” and make sure to check “use headers” in the Read Range activity.

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