Forum Discussion

abhishek8908's avatar
abhishek8908
Occasional Contributor
12 years ago

How to write data into Excel file

Hi All,

I am trying to append data from the response of an operation in an Excel sheet under column name= "Data" using groovy script.Kindly help me on this. I am using below connection for this purpose.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( "Add#Response" )
holder.namespaces["ns"] = "http://tempuri.org/"
for( item in holder.getNodeValues( "//ns:AddResult" ))
y=log.info "$item"

def soapUI_Excel = "D:\\try.xls"
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
soapUIDataConnection = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=" + soapUI_Excel + ";ReadOnly=0", "", "");
Statement stmt = ((Connection) soapUIDataConnection).createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

q2 = stmt.update "[ExcelSheetName\$]" + y


The above code is not working.Please help me to proceed further.
No RepliesBe the first to reply