Skip to main content

Read-Column

Command Description

Read columns after the specified cell (inclusive) and return an array

Command Prototype

arrayRet = Excel.ReadColumn(objExcelWorkBook,sheet,strCell,bRetDisplay)

Parameter Description

ParameterRequiredTypeDefaultDescription
objExcelWorkBookTrueexpressionobjExcelWorkBookExcel workbook object (workbook opened with "Open Excel" command (Excel.OpenExcel) or the workbook object returned by the command "Bind Excel" (Excel.BindBook))
sheetTruestring"Sheet1"The string means sheet name. The number means sheet order(starting from 0)
strCellTruestring"A1"Two forms of cell are supported: cell names (such as "A1") or array of rows and columns (such as [row number, column number]). It is case-insensitive to use cell names
bRetDisplayTruebooleanTrueSelect "Yes", then the return content is consistent with the content displayed in the Excel cell, and always returns in the form of a string (when there is a wrap, the content will be automatically encapsulated with double quotation marks); Select "No", then the content will be automatically converted according to the data type, for example, the returned value of 0.1 would be 0.1 instead of the string "0.1"

return

arrayRet,The variable used to save the output of the command.

Demo

/************************Read columns********************** ************ 
**Input 1:
** objExcelWorkBook--Excel workbook object (a workbook opened using the "Open Excel" command (Excel.OpenExcel) or a job bound using the "Bind Excel" command (Excel.BindBook) book object).
**Entry 2:
** sheet--If a string is used, it means the name of the specified worksheet; if a number is used, it means the order of the specified worksheet (starting from 0).
**Entry 3:
** strCell--Specified cell, supports two forms of cell name such as "A1" and row and column array such as [row number, column number]. When using the cell name, it is not case-sensitive.
**Exports:
** arrayRet--The variable to which the output of the function call is saved.
**
*********************************************************************/

objExcelWorkBook = Excel.OpenExcel(@res"Test.xlsx",True,"Excel","","")
arrayRet = Excel.ReadColumn (objExcelWorkBook, "Sheet1", "A1")
TracePrint "Read column: The value of the column where Excel object Sheet1 worksheet A1 is located:"
TracePrint arrayRet
Excel.CloseExcel(objExcelWorkBook,False)