Forum Discussion

chavachows's avatar
12 years ago

opening exisiting excel sheet and appending new values

Hi

I am struggling to open an existing excel sheet in the test step script assertion (datasource - test step-datasourceloop) where I want to add a row (node value from response)into the sheet each time the test step is executed.

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

def holder = new XmlHolder(messageExchange.responseContentAsXml)
holder.namespaces["ns1"]="http://xxxxxx.com/services"

Workbook booking = Workbook.getWorkbook(new File("C:/xxxxxx/booking.xls"))
Sheet sheet = booking.getSheet(0)

newRow = sheet.rows
sheet.insertRow(newRow)

def BookingRef = holder.getNodeValue("//ns1:makeBookingResponse[1]/ns1:Booking[1]/ns1:Reference[1]")
Label label = new Label(0, newRow, BookingRef)
sheet.addCell(label)

booking.write()
booking.close()


I have done lot of google search for this and finally found using insertrow syntax but it is not working. Please advice me. I want to use the existing sheet and add rows to it. If I create a book and sheet everytime then the previous values are being deleted.

Thanks
Praveen
No RepliesBe the first to reply