Ask a Question

How can I Count the row of test data in my excel sheet.

SOLVED
kaiiii
Regular Contributor

How can I Count the row of test data in my excel sheet.

How can I Count the row of test data in my excel sheet.

Like:

 Project.Variable.VariableName.IsEOF  ---> used to check sheet is empty or not

 Project.Variable.VariableName.ColumnCount --> used to check no of column in the sheet

similarly,

how can i find out the no of total rows in a sheet

4 REPLIES 4
tristaanogre
Esteemed Contributor

There is no function/method/property of the DB Table variable type that will give you the explicit row count.  So, you'll need to write code to do so.

function sheetText(){
    var rowCount
    rowCount = 0
    while (!Project.Variables.VariableName.IsEOF()) {
        rowCount++
        Project.Variables.VariableName.Next()
    }
    Log.Message(rowCount)
}

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
sethir
Frequent Visitor

@kaiiii  You can use follwoing groovy script to get number of rows in an excel sheet-

---------------------------------------------------------------------------------------------

import com.eviware.soapui.support.XmlHolder
import jxl.*
import jxl.write.*

// DECLARE THE VARIABLES
def myTestCase = context.testCase //myTestCase contains the test case
def size 
Workbook workbook1 = Workbook.getWorkbook(new File("C:\\Users\\sethir\\files\\numbers.xls")) //file containing the data
Sheet sheet1 = workbook1.getSheet("orders")// You can also provide 0 instead of sheet name. It will read first sheet from the workbook
size= sheet1.getRows().toInteger() //get the number of rows, each row is a data set
log.info ("total rows"+ size);

tristaanogre
Esteemed Contributor

TestComplete does not support Groovy.  That's a SoapUI solution.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
sonya_m
SmartBear Alumni (Retired)

Hi @kaiiii , have you tried using the approach that tristaanogre suggested? Let us know whether you situation is resolved.


Sonya Mihaljova
Community and Education Specialist

cancel
Showing results for 
Search instead for 
Did you mean: