AnyLogic 7:未指定 Excel 访问库 (Apache POI)
我正在尝试使用 AnyLogicExcelFile
类,但似乎 AnyLogic 找不到所需的 Apache POI 库:
Error during model startup:
Excel access library (Apache POI) is not specified (or is specified incorrectly) in the classpath
Caused by: org/apache/poi/openxml4j/exceptions/InvalidFormatException
Caused by: org.apache.poi.openxml4j.exceptions.InvalidFormatException
java.lang.RuntimeException: Excel access library (Apache POI) is not specified (or is specified incorrectly) in the classpath
at com.xj.anylogic.engine.Engine.a(Unknown Source)
at com.xj.anylogic.engine.Engine.start(Unknown Source)
at com.xj.anylogic.engine.ExperimentSimulation.b(Unknown Source)
at com.xj.anylogic.engine.ExperimentSimulation.run(Unknown Source)
at generic_agent_based_model_with_births_and_deaths.Simulation.executeShapeControlAction(Simulation.java:107)
Caused by: java.lang.NoClassDefFoundError: org/apache/poi/openxml4j/exceptions/InvalidFormatException
at generic_agent_based_model_with_births_and_deaths.ExcelDataSource.onStartup(ExcelDataSource.java:668)
at generic_agent_based_model_with_births_and_deaths.ExcelDataSource.start(ExcelDataSource.java:652)
at generic_agent_based_model_with_births_and_deaths.Main.start(Main.java:1046)
... 4 more
Caused by: java.lang.ClassNotFoundException: org.apache.poi.openxml4j.exceptions.InvalidFormatException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 7 more
我该如何解决?
一些注意事项:
- 我正在使用最初由其他人开发的模型。我假设该模型最初是为 AnyLogic 6.9 构建的,但我使用的是 AnyLogic 7.0.3。
- 我假设 AnyLogic 应该自动导入 POI 库:知道它做错了什么/我做错了什么导致 AnyLogic 失败吗?
- 为了避免混淆,
ExcelDataSource
我创建了一个包装类来简化ExcelFile
我们的用例。
提前致谢!