Forum Discussion

mohantysuchi's avatar
mohantysuchi
Occasional Contributor
6 years ago

need help in using xl sheet for data parametrization in groovy scripting

Hi,

 

I am getting the below error while executing groovy script code in soap ui.

 

error: java.io.FileNotFoundException: C:\Users+0364\Documents\GE_Confidential\test data_automation project\testdata_reverse material.ods (The system cannot find the path specified) error at line: 7

 

Code used to use Xl in groovy scripting:

 

import jxl.*
import jxl.write.*
WritableWorkbook workbook = Workbook.createWorkbook(new File("C:\\Users\530364\\Documents\\GE_Confidential\\test data_automation project\\testdata_reverse material.ods"))
WritableSheet sheet = workbook.createSheet("Worksheet 1", 0)
log.info(sheet1.isHidden())
Label label = new Label(0, 2, "Test data in Column A, Row 3"); //column=0=A,row=0=1
sheet.addCell(label);
Label label1 = new Label(2, 2, "Column C, Row 3");
sheet.addCell(label1);
workbook.write()
workbook.close()
Workbook workbook1 = Workbook.getWorkbook(new File("C:\\Users\530364\\Documents\\GE_Confidential\\test data_automation project\\testdata_reverse material.ods"))
Sheet sheet1 = workbook1.getSheet(0)
Cell a1 = sheet1.getCell(1,1) // getCell(row,column) -- place some values in myfile.xls
Cell b2 = sheet1.getCell(1,2) // then those values will be acessed using a1, b2 & c3 Cell.
Cell c2 = sheet1.getCell(1,3)
log.info a1.getContents()
log.info b2.getContents()

 

Thanks,

Suchismita
log.info c2.getContents()
workbook1.close()

1 Reply

  • Lucian's avatar
    Lucian
    Community Hero

    You are missing a double slash in 'C:\\Users\530364'.

     

    Also I usually try to keep folder names without spaces. That can help in avoiding some problems later on... :smileyhappy: