未指定AnyLogic 7:Excel访问库(Apache POI)

时间:2014-09-29 19:03:51

标签: apache-poi simulation anylogic

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

我该如何解决这个问题?

一些注意事项:

  1. 我正在使用最初由其他人开发的模型。我假设该模型最初是为AnyLogic 6.9构建的,但我使用的是AnyLogic 7.0.3。
  2. 我认为AnyLogic应该自动导入POI库:知道它做错了什么/我做错了导致AnyLogic失败了吗?
  3. 为避免任何混淆,ExcelDataSource是我创建的一个包装类,用于简化ExcelFile用例。
  4. 提前致谢!

1 个答案:

答案 0 :(得分:2)

AnyLogic使用Apache POI库来处理Excel电子表格。但默认情况下禁用它是不必要的。您应该从连接选项板中删除Excel文件元素,以便能够使用Apache POI方法。另一种方法 - 将库添加到模型依赖项列表中(请参阅模型属性视图的“依赖项”部分)。