Forum Discussion
Layansan
9 years agoNew Contributor
You need to use an Excel API to communicate or manipulate data in the Excel files.
Download Java Excel API and place the JXL.jar file in the “lib” folder of your SoupUI installation directory.
Assume the response is like:
<Response xmlns="http://localhost/something"> <content>some content</content> <id>100</id> </Response>
Add a Groovy test step
import jxl.* import jxl.write.* def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) def holder = groovyUtils.getXmlHolder("RequestStep#ResponseAsXml") // Change RequestStep name log.info holder.getXml() // will display /Log the response in Xml WritableWorkbook workbook = Workbook.createWorkbook(new File("C:/output.xls")) WritableSheet sheet = workbook.createSheet("Worksheet 1", 0) log.info(sheet.isHidden()) xPath1 = "//*:id/text()" // use xPath to access the value from response xPath2 = "//*:content/text()" log.info holder.getNodeValue(xPath1) log.info holder.getNodeValue(xPath2) Label label = new Label(0, 1, holder.getNodeValue(xPath1)); //column=0,row=1 sheet.addCell(label); Label label1 = new Label(2, 2, holder.getNodeValue(xPath2)); //column=2,row=2 sheet.addCell(label1); workbook.write(); workbook.close();
- ddineesh6 years agoNew Contributor
its working just fine for me. Thanks a lot for this article.
- LearnAutomation8 years agoNew Member
I am able to extract the text from a tag and save it in excel using your code. But it will format the entire excel...I am trying to save the extracted response value in a particular cell in my test case. But when i run the code, all the other values in that particular excel sheet is removed and only the extracted soap response is saved.. can you help please!!
Related Content
- 5 years ago
- 4 years ago
Recent Discussions
- 15 years ago