Bot reading the non existing excel sheet

Hi ,

Our bot is throwing an error where in its reading non existing excel sheet.

Below is the error:

“An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.Exception: There isn’t a worksheet named ‘Approvers_List’.
at ClosedXML.Excel.XLWorksheets.Worksheet(String sheetName) in C:\Projects\ClosedXML\ClosedXML\Excel\XLWorksheets.cs:line 70
at ClosedXML.Excel.XLWorkbook.Worksheet(String name) in C:\Projects\ClosedXML\ClosedXML\Excel\XLWorkbook.cs:line 596
at ClosedXML.Excel.XLWorkbook.LoadSpreadsheetDocument(SpreadsheetDocument dSpreadsheet) in C:\Projects\ClosedXML\ClosedXML\Excel\XLWorkbook_Load.cs:line 448
at ClosedXML.Excel.XLWorkbook.LoadSheets(String fileName) in C:\Projects\ClosedXML\ClosedXML\Excel\XLWorkbook_Load.cs:line 45
at UiPath.Excel.WorkbookFile…ctor(String workbookPath, String password, Boolean createNew)
at UiPath.Excel.Activities.WorkbookActivity1.ConstructWorkbook(String path, String password, Boolean createNew) at UiPath.Excel.Activities.WorkbookActivity1.BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, Object state)
at System.Activities.AsyncCodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)”

Please help us on this issue

1 Like

Please follow below exception handling-

  1. Check specified file exists in the system.
  2. Use Excel Application scope. Capture workbook in Output Workbook property.
  3. Use Get Workbook sheets activity to get all the sheet names in the excel. The output will be the list of strings.
  4. Check the sheet you are trying to access exists in the retrieved sheet name. list.contains(sheetname) => returns boolean value
  5. If sheet exists, use read range or read cell to read the data from the sheet.

Hope this is helpful. Let me know if this doesn’t solve your problem

Hi Madhavi,

the given above steps is already followed in the code but still issue exist.

@Farha Is it possible to share the code? I would like to review once.
The exception clearly says that there is no sheet with the name ‘Approvers_List’.
If the about exception scenarios are handled, BOT should not throw this error.

Also check is there any space or special characters included in the sheet names