How to handle "Sheet Not found" in Excel

I am facing a scenario, where I need to create multiple sheets in an excel file… based on some data. If those data don’t exist, the sheets will not be created. I need to take the data from all the created sheets and do some operations thenafter. But as the sheets have not created, the workflow is failing in between.

Is there any way out or exception type through which I can catch the Read Range : Sheet Not Found. ?

Thank You :slight_smile:

Hi @Onkar_Nath_Sharma,

If you are using excel application scope, you can get all the sheet names using below code
Workbook.GetSheets

If you are not going to use excel application scope, you can use workbook read range but here you need to handle the exception scenario to find the sheet name is available or not using try catch block

Regards,
Arivu

2 Likes

Hi @arivu96

What will be the exception type for it to catch?

Hi @Onkar_Nath_Sharma,

Declare one Boolean variable
BSheetName= false

Use try catch block, in exception block make BSheetName as true.

After that you can check the Boolean name is true or not…
If yes-> sheet name available
No-> sheet name not available

Regards,
Arivu

1 Like

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