cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Highlighted
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

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

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

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

View solution in original post

4 REPLIES 4
Highlighted
Community Hero

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

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

View solution in original post

Highlighted
Frequent Visitor

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

@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);

Highlighted
Community Hero

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

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
Highlighted
Community Manager

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

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

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

Changing options from outside of TestComplete

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!
Top Kudoed Authors