Skip to main content

Get-Row-Count

Command Description

Get the number of rows used in the sheet

Command Prototype

iRet = Excel.GetRowsCount(objExcelWorkBook,sheet)

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)

return

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

Demo

/************************Get row count************************ ********* 
**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).
**Exports:
** iRet--The variable to which the output of the function call is saved.
**
*********************************************************************/

objExcelWorkBook = Excel.OpenExcel(@res"Test.xlsx",True,"Excel","","")
iRet = Excel.GetRowsCount(objExcelWorkBook,"Sheet1")
TracePrint "Get the number of rows: The number of used rows of the Excel object Sheet1 worksheet is:"&iRet
Excel.CloseExcel(objExcelWorkBook,False)