AnyLogic 7:未指定Excel访问库(Apache POI)
我正在尝试使用AnyLogic ExcelFile
类,但似乎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
我该如何解决这个问题?
一些注意事项:
ExcelDataSource
是我创建的一个包装类,用于简化ExcelFile
用例。提前致谢!
答案 0 :(得分:2)
AnyLogic使用Apache POI库来处理Excel电子表格。但默认情况下禁用它是不必要的。您应该从连接选项板中删除Excel文件元素,以便能够使用Apache POI方法。另一种方法 - 将库添加到模型依赖项列表中(请参阅模型属性视图的“依赖项”部分)。