是否有一个限制读XLSX文件? 随着XLS文件,我面对任何问题。
我的环境是:
- 了SoapUI免费版本5.3.0
- Apache的POI 3.14
- Windows 7中的Pro / Office 2010中
Apache的POI库的位置
I unzipped the downloaded POI package into the following folder:
C:\Program Files\SmartBear\SoapUI-5.3.0\bin\ext
fyi - I have also tried adding it to lib
错误我得到当我试图运行下面提供的Groovy脚本是:
org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
我的Groovy脚本是:
import java.io.File;
import java.io.FileInputStream;
import java.util.Iterator;
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;
String filepath = "E:\\SoapUiProjects\\MyWorkspace\\data\\data.XLSX"
String sheetName = "login"
FileInputStream fis = new FileInputStream(new File(filepath))
Workbook wb = WorkbookFactory.create(fis)
Sheet sh = wb.getSheet(sheetName)
Iterator itrRow = sh.rowIterator()
while(itrRow.hasNext())
{
Row row = itrRow.next()
for(Cell cell : row)
{
switch(cell.getCellType())
{
case Cell.CELL_TYPE_NUMERIC:
log.info cell.getNumericCellValue()
break;
default:
log.info cell.getRichStringCellValue()
}
}
}
fis.close()
wb.close()
堆栈跟踪:
2017-07-11 15:09:50,631 ERROR [SoapUI] An error occurred [java.lang.reflect.InvocationTargetException], see error log for details
2017-07-11 15:09:50,631 ERROR [errorlog] org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
at org.apache.poi.POIXMLFactory.createDocumentPart(POIXMLFactory.java:65)
at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:601)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:174)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:249)
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:211)
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:170)
at org.apache.poi.ss.usermodel.WorkbookFactory$create.call(Unknown Source)
at Script21.run(Script21.groovy:14)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:90)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:141)
at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:250)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:56)
at org.apache.poi.POIXMLFactory.createDocumentPart(POIXMLFactory.java:62)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.poi.POIXMLTypeLoader
at org.apache.poi.xssf.model.ThemesTable.<init>(ThemesTable.java:85)
... 19 more
先感谢您。