【问题标题】:The package org.apache.poi.ss.usermodel is accessible from more than one module: poi, poi.ooxmorg.apache.poi.ss.usermodel 包可以从多个模块访问:poi、poi.ooxm
【发布时间】:2019-01-25 09:01:22
【问题描述】:

在此问题的所有参考资料中,它已解决且不提供 maven,因为 notma​​ven 中进行操作。 错误是包org.apache.poi.ss.usermodel 可以从多个模块访问:poi, poi.ooxm 在两个错误中

我必须同时使用 poi 和 poi--ooxml,请运行此代码,我需要使用它。甚至此代码也是从互联网本身中提取的,并且有很多博客都显示了这种类型的代码,这是我的实际要求,但它不起作用。

【问题讨论】:

标签: java excel apache-poi


【解决方案1】:

我遇到了同样的问题并找到了解决方案。这有点晚了,但可能会帮助其他面临同样问题的人。 在您的模块中删除“需要 poi”并保留需要 poi.ooxml;

module com.example.MyModlue {
  //other require statement goes here
   requires poi.ooxml;
}

现在在你的代码中

代替使用 (CellType.NUMERIC) 导入 org.apache.poi.ss.usermodel.CellType;

获取单元格类型使用 (cell.getCellTypeEnum().NUMERIC) where cell if of type XSSFCell

import org.apache.poi.xssf.usermodel.XSSFCell;

希望这会有所帮助。 :)

【讨论】:

  • 我使用var 类型推断来避免直接引用类型。
【解决方案2】:

只需在模块类中将所有库添加到要求中

module MyProjct {
    requires poi;
    requires poi.excelant;
    requires poi.ooxml;
    requires poi.ooxml.schemas;
}

【讨论】:

    【解决方案3】:

    如果有人有同样的问题,只需下载新版本的 POI,旧版本与新版本的 java 不兼容

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-12
      • 2020-05-13
      • 1970-01-01
      • 1970-01-01
      • 2020-07-31
      • 2019-12-08
      • 1970-01-01
      • 2019-10-14
      相关资源
      最近更新 更多