获取单元格值

获取网格单元格中包含的值。

命令可用性: 本地 IBM RPA SaaS 和 IBM RPA

脚本语法

IBM RPA 的专有脚本语言具有类似于其他编程语言的语法。 该脚本语法在脚本文件中定义命令的语法。 您可以在 IBM RPA Studio的 脚本 方式下使用此语法。

getGridValue --cultureformat(String) --ocrprovider(Nullable<OpticalCharacterRecognitionProvider>) [--googlevisionclientsecret(String)] --grid(ImageGrid) --row(Numeric) --column(Numeric) (String)=value

依赖关系

使用 映射图像网格 (mapGrid) 或 获取图像网格 (getGrid) 命令来获取 grid 参数中所需的变量。

输入参数

下表显示了此命令中提供的输入参数的列表。 在表中,您可以看到在 IBM RPA Studio的脚本方式及其 Designer 方式等效标签中工作时的参数名称。

设计器方式标签 脚本方式名称 必需的 接受的变量类型 Description
OCR 提供程序 ocrprovider Required OpticalCharacterRecognitionProvider 要使用的文本识别方法。

请参阅 ocrprovider 参数选项
清除尾部换行符 sanitize Optional when the OCR Provider parameter is Abbyy Boolean 修剪所生成的文本,移除尾部 Unicode 换行符。
API 参数 googlevisionclientsecret Optional Text 这是包含 API 参数的 JSON 文件的绝对路径。 请参阅 Google Cloud Vision™外部链接 文档,以获取有关 JSON 格式的详细信息。
网格 grid Required Image Grid 从中获取值的已映射网格。
row Required number 要在其中获取值的行。
column Required number 包含要获取的值的列。
语言 cultureformat Required Text, Culture 编写要获取的值所用的语言。

ocrprovider 参数选项

下表显示了可用于 ocrprovider 输入参数的选项。 该表显示了在脚本方式下工作时的可用选项以及在设计器方式下的等效标签。

设计器方式标签 脚本方式名称 Description
Abbyy Abbyy Abbyy OCR 提供程序。
Google Google Google Tesseract OCR 提供程序。
Google Cloud Vision GoogleVision Google Cloud Vision API。

输出参数

设计器方式标签 脚本方式名称 接受的变量类型 Description
text Text 返回从网格单元格获取的值。

示例

以下示例显示了 getGridValue 命令从先前使用映射图像网格命令映射的表中的单元格返回值。

defVar --name mappedImageGrid --type ImageGrid
defVar --name valueObtained --type String
// Open an Excel file and use the recorder to enter the commands waitWindow and mapGrid.
waitWindow --title "tableExcelCompanyCity.xlsx - Excel" --classname XLMAIN --processname EXCEL
mapGrid --columnmappings "27-141;141-281;281-388;388-450;450-515;515-580;580-644;644-706;706-771;" --selector "XPath" --xpath "/root/pane[1]/pane[1]/pane[1]/datagrid[1]" mappedImageGrid=value
getGridValue --cultureformat "en" --ocrprovider "GoogleVision" --grid ${mappedImageGrid} --row 1 --column 1 valueObtained=value
logMessage --message "Value obtained from the mapped table: ${valueObtained}" --type "Info"