Forum Discussion

chathurad's avatar
chathurad
Contributor
6 years ago
Solved

How to get all the data on my data source using groovy script assertion

From the below code i was able to get the 1st column data from my excel data source file. def data = context.expand( '${DataSource#data}') log.info data But there are more data available on my ...
  • chathurad's avatar
    chathurad
    6 years ago

    Thanks.

     

    I was able to get all the data by using below code.

    def fs = new FileInputStream("C:\\Users\\cja\\Documents\\Book1.xlsx")
    def wb = new XSSFWorkbook(fs)
    def ws = wb.getSheet("data1")
    def r = ws.getPhysicalNumberOfRows()
    
    for(def i=0; i<r; i++)
    {
    def row = ws.getRow(i)
    def c = row.getPhysicalNumberOfCells()
    
    for (def j=0;j<c;j++)
    {
    def cell = row.getCell(j)
    log.info cell.getStringCellValue()
    
    }
    }