Forum Discussion

roshana's avatar
roshana
Occasional Visitor
2 years ago

Error:groovy.lang.MissingPropertyException: No such property: Workbook for class: Script1

Getting Below error for groovy script in SOUPUI 5.6.0

Error:groovy.lang.MissingPropertyException: No such property: Workbook for class: Script1

 

For Below script :

 

import jxl.*
import jxl.write.*
import groovy.json.*

 

String fileLocation = "H:\\Desktop\\mSSanity_SOAPUI Framework\\FMO mS_Automation_DataSheet_v1_UAT.xls"; // Change the file path.
def fileP = new File(fileLocation);
def workBook1 = Workbook.getWorkbook(fileP);
def sheet1 = workBook1.getSheet(0);
def rowsCount = sheet1.getRows();
context["rowsCount1"]=rowsCount-1;
context["sheet1"]=sheet1;
context["fileLocation"]=fileLocation;
context["pointing_URL"]=sheet1.getCell(1,rowsCount-1).getContents();
context["dme_URL"]=sheet1.getCell(2,rowsCount-1).getContents();
context["header_Auth"]=sheet1.getCell(3,rowsCount-1).getContents();
context["aft_val"]=sheet1.getCell(4,rowsCount-1).getContents();
context["httpvalue"]=sheet1.getCell(5,rowsCount-1).getContents();
context["sub_Context"]=sheet1.getCell(6,rowsCount-1).getContents();
context["Request_String"]=sheet1.getCell(7,rowsCount-1).getContents();

1 Reply

  • you can use the poi jar. below is the sample

     

    first you need to copy the poi jar in the lib folder and try to execute below sample code.

     

    String fileLocation = "H:\\Desktop\\mSSanity_SOAPUI Framework\\FMO mS_Automation_DataSheet_v1_UAT.xls"; // Change the file path.

    FileInputStream fis=new FileInputStream(new File(fileLocation));
    HSSFWorkbook wb=new HSSFWorkbook(fis);
    HSSFSheet sheet=wb.getSheetAt(0);
    Row row = sheet.getRow(0)
    log.info (sheet.getPhysicalNumberOfRows())
    Cell cell=row.getCell(1);
    value=cell.getStringCellValue();
    log.info (value)