我正在尝试通过 Xpage 将任何类型的 Excel 工作表(xls/xslx)导入我的数据库,以下代码返回错误:
importPackage(org.apache.poi.ss.usermodel);
var tempFile:java.io.File = fileData.getServerFile();
var wb:WorkBook = WorkbookFactory.create(tempFile);
var sheet:Sheet = wb.getSheetAt(0);
var rows = sheet.getPhysicalNumberOfRows();
“找不到工作簿工厂”
我已将 API 放在 buld 路径中:/tradesec(9).nsf/WebContent/WEB-INF/lib/poi-3.9-20121203.jar
我在没有 importPackage 的情况下尝试过,但没有运气。 未找到“组织”
请指教!
/米
更新: 我现在已经将所有 jar 从 POI 复制到 jvm/lib/ext,为 java.policy 中的所有内容添加了授权,创建了一个 java 类作为 bean。仍然出现异常:
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:56)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:39)
java.lang.reflect.Constructor.newInstance(Constructor.java:527)
com.ibm.jscript.types.JavaAccessObject.construct(JavaAccessObject.java:260)
com.ibm.jscript.types.JavaWrapperObject.construct(JavaWrapperObject.java:1)
com.ibm.jscript.ASTTree.ASTNew.interpret(ASTNew.java:109)
com.ibm.jscript.ASTTree.ASTMember.interpret(ASTMember.java:106)
com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:88)
com.ibm.jscript.ASTTree.ASTVariableDecl.interpret(ASTVariableDecl.java:82)
com.ibm.jscript.ASTTree.ASTBlock.interpret(ASTBlock.java:100)
com.ibm.jscript.ASTTree.ASTTry.interpret(ASTTry.java:109)
com.ibm.jscript.ASTTree.ASTBlock.interpret(ASTBlock.java:100)
com.ibm.jscript.ASTTree.ASTTry.interpret(ASTTry.java:109)
com.ibm.jscript.ASTTree.ASTIf.interpret(ASTIf.java:85)
com.ibm.jscript.ASTTree.ASTBlock.interpret(ASTBlock.java:100)
com.ibm.jscript.ASTTree.ASTTry.interpret(ASTTry.java:109)
com.ibm.jscript.ASTTree.ASTProgram.interpret(ASTProgram.java:119)
com.ibm.jscript.ASTTree.ASTProgram.interpretEx(ASTProgram.java:139)
com.ibm.jscript.JSExpression._interpretExpression(JSExpression.java:435)
com.ibm.jscript.JSExpression.access$1(JSExpression.java:424)
com.ibm.jscript.JSExpression$2.run(JSExpression.java:414)
java.security.AccessController.doPrivileged(AccessController.java:310)
com.ibm.jscript.JSExpression.interpretExpression(JSExpression.java:410)
com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:251)
com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:234)
com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(JavaScriptInterpreter.java:221)
com.ibm.xsp.binding.javascript.JavaScriptMethodBinding.invoke(JavaScriptMethodBinding.java:111)
com.ibm.xsp.actions.ActionGroup.invoke(ActionGroup.java:135)
com.ibm.xsp.component.UIViewRootEx.invokePhaseMethodBinding(UIViewRootEx.java:1735)
com.ibm.xsp.controller.FacesControllerImpl.invokePhaseMethodBinding(FacesControllerImpl.java:444)
com.ibm.xsp.controller.FacesControllerImpl.access$0(FacesControllerImpl.java:438)
com.ibm.xsp.controller.FacesControllerImpl$ViewPhaseListener.beforePhase(FacesControllerImpl.java:527)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:197)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:120)
com.ibm.xsp.controller.FacesControllerImpl.render(FacesControllerImpl.java:264)
com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:248)
com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:204)
com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138)
com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)
com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:583)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1281)
com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:860)
com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:803)
com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:572)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1265)
com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:658)
com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:481)
com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:341)
com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:297)
com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
我必须说,我在这部分的知识非常有限。
目前我正在考虑摆脱这个并开始实现一个普通的旧文本文件。恐怕我紧张的项目时间表需要处理太多的开销和依赖项。如果有人在那里找到解决方案,我很乐意探索它