Checks If a Worksheet Exists
Verb: excelWorksheetExists
Available from: <Standard>
Checks whether a spreadsheet exists in an Excel file by searching for its name or index.
Syntax
excelWorksheetExists --file(Excel) [--index(Numeric)] [--name(String)] (Boolean)=value
Inputs
| Script | Designer | Required | AcceptedTypes | Description |
|---|---|---|---|---|
| --file | Excel | Required | Excel | Excel file used for checking the existence of the worksheet. |
| --index | Index | Optional | Number | Index of the desired worksheet. |
| --name | Name | Optional | Text | Name of the desired worksheet. |
Outputs
| Script | Designer | AcceptedTypes | Description |
|---|---|---|---|
| value | Exist | Boolean | Returns "True" if the search object worksheet was found, or "False" otherwise. |
Example
The Open Excel File command opens an Excel file and returns it to the variable "excelFile", which is entered in the Excel parameter of the Checks If a Worksheet Exists command. This command checks whether the worksheet of index "1" exists in the file and returns a variable with the result "True", confirming its existence.
defVar --name excelFile --type Excel
defVar --name worsheetExists --type Boolean
excelOpen --file "cloneExcelFile.xlsx" 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.
Download File
Remarks
For the correct operation of the Get Excel Table command, an Excel file must be opened with the command Open Excel File.
The Save Excel As command can be used to save changes made to the file.