Handling POIXML Exception in Groovy Scripting
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
Code:
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)