Check If a Worksheet Exists

Checks if a worksheet exists in an Excel file by looking up its name or index.

Command availability: IBM RPA SaaS and IBM RPA on premises

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

excelWorksheetExists --file(Excel) [--index(Numeric)] [--name(String)] (Boolean)=value


  • To use this command, open an Excel file with the Open Excel file (excelopen) command.

Input parameters

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Excel file Required Excel Variable that stores the Excel instance.
Index index Optional Number Index of the wanted worksheet.
Name name Optional Text Name of the wanted worksheet.

Output parameters

Designer mode label Script mode name Accepted variable types Description
Exist value Boolean Returns True if the search is successful, or False otherwise.


The following code example demonstrates how to use the Check If a Worksheet Exists command to check whether the worksheet of index "1" exists in the file.

// Enter your excel file into the *Open excel file* command
defVar --name excelFile --type Excel
defVar --name worsheetExists --type Boolean
excelOpen --file "sample file" excelFile=value
excelWorksheetExists --file ${excelFile} --index 1 worksheetExists=value
logMessage --message "${worksheetExists}" --type "Info"
excelClose --file ${excelFile} --save
// Result: True 
// Index worksheet "1" exists in excel file.

Important: To run the example script, use a sample file and enter its path in the Open Excel File (excelOpen) command.