Get Excel Value

Gets the value of a cell in an Excel file, using column and row coordinates.

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.

excelGet --file(Excel) [--getfirstsheet(Boolean)] --sheet(String) [--usingcell(Boolean)] --cell(String) --row(Numeric) --column(Numeric) (Scalar)=value

Dependencies

  • 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
File file Required Excel Variable that stores the Excel instance.
Use First Sheet getfirstsheet Optional Boolean Gets the value corresponding to the entered coordinates of the first spreadsheet of the file.
Sheet sheet Required when the Use First Sheet parameter is disabled Text Name of the worksheet from which the value is obtained.
Specify Cell usingcell Optional Boolean Enable to use the complete cell coordinate in the cell parameter.
Cell cell Required when the Specify Cell parameter is enabled Text Cell to get value from.
Example: "B3".
Row row Required when the Specify Cell parameter is disabled Number Element corresponding to the row coordinate where the value must be entered.

Example: "1" in "A1"
Column column Required when the Specify Cell parameter is disabled Number Element corresponding to the column coordinate where the value must be entered.

Example: "A" in "A1"

Output parameters

Designer mode label Script mode name Accepted variable types Description
Value value Primitives Returns a variable with the value that is obtained from the cell found through the entered coordinates.

Example

The script uses the Open Excel File command to open an excel file and stores it in the "OpenExcel File" variable. The Get Excel Value command uses this variable and the Use First Sheet and Specify Cell parameters to get the value of the A1 cell. Close Excel closes the file and the Log Message command records the value obtained from the IBM RPA Studio console.

defVar --name openedExcelFile --type Excel
defVar --name obtainedValue --type String
excelOpen --file "samplefile" --savechangesopenedExcelFile=value
excelGet --file ${openedExcelFile} --getfirstsheet--usingcell--cell A1 obtainedValue=value
excelClose --file ${openedExcelFile} --save
logMessage --message "Obtained Value: ${obtainedValue}\r\n" --type "Info"

Important: To run the sample script, you must create the file and fill in the "A1" cell, then enter its path in the Open Excel File (excelopen) command.

Limitations

IBM RPA displays date values along with the time, regardless of how it is formatted.
Example: 01/14/2022 -> 01/14/2022 12:00:00AM