We are trying to read data from xlsx file using apache POI, we have all the jars files placed under soap/bin/ext. It gives us below error when running our groovy script.
org.apache.poi.ooxml.POIXMLException: org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions; error at line: 15
import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import org.apache.poi.ss.usermodel.Cell;import org.apache.poi.ss.usermodel.Row;import org.apache.poi.ss.usermodel.Sheet;import org.apache.poi.ss.usermodel.Workbook;import org.apache.poi.ss.usermodel.WorkbookFactory;import org.apache.poi.ss.usermodel.CellStyle;
FileInputStream inputStream = new FileInputStream("D:\\SOAP\\ExcelPOI.xlsx")
Workbook wb = WorkbookFactory.create(inputStream)Sheet sheet1 = wb.getSheet("Sheet Name")int rows = sheet1.getLastRowNum();log.info(rows)
Hi JHunt, Sorry for delayed reply.
Tried it using your script too but it does not work. XLSX file is just two row data. Could you please try to read data in groovy script as test step in soapUI from attached sheet.
SOAP UI - 5.5.0
Added error log from error output: Not sure if it has something to have with jars placed inside ext and lib folder. Can you share your jars for soap in ext and lib. Thanks
Your Groovy scripts run in the same JVM as SoapUI.
SoapUI has a dependency on XmlBeans 2.4.0 and loads this before the JARs in bin/ext/, but poi-ooxml-schemas (the latest version) has a dependancy on XmlBeans 3.1.0.
You could try using Apache POI 3.9 because it is looking for XmlBeans 2.3.0 and is more likely to work with SoapUI's version (no guarantees).