无法在 Apache POI 中导入 XSSF
我正在引用 Apache POI 的 3.7 版本,并且在执行此操作时收到“无法解析”错误:
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
引用 POI 的其他导入语句不会给我错误,例如:
import org.apache.poi.ss.usermodel.*;
有什么想法吗? ?
I am referencing the version 3.7 of the Apache POI and I am getting a "cannot be resolved" error when I do:
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
Other import statements that reference POI DO NOT give me errors, such as:
import org.apache.poi.ss.usermodel.*;
Any ideas??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(14)
首先,您需要在 pom.xml 中添加以下依赖项:
注意: 如果您的项目仍然找不到依赖项,请在 module-info.java 中添加以下行:
First you need to add the following dependencies in your pom.xml:
NOTE: If your project still cannot find the dependecy, add the following line in your module-info.java:
你没有描述环境,无论如何,你应该下载apache poi库。如果您使用的是 eclipse,请右键单击根项目,然后在属性和 java 构建路径中添加外部 jar 并在项目中导入这些库:
xmlbeans-2.6.0; poi-ooxml-schemas- ... ; poi-ooxml-...; poi-...;
You did not described the environment, anyway, you should download apache poi libraries. If you are using eclipse , right click on your root project , so properties and in java build path add external jar and import in your project those libraries :
xmlbeans-2.6.0 ; poi-ooxml-schemas- ... ; poi-ooxml- ... ; poi- .... ;
我的实现需要以下文件:
从apache获取)
(虽然说实话,我并不完全确定它们都是必要的......)这有点令人困惑,因为它们是这样包装的。我需要将它们手动放置在我自己的“lib”文件夹中,然后添加引用...
Maven 似乎总是下载比我需要的更多的东西,所以我总是手动放置 libaries/dll 和类似的东西。
I needed the following files for my implementation:
get from apache)
(though honestly, I'm not completely sure they are all necessary...) It's a little confusing because they are packaged that way. I needed to place them manually in my own "lib" folder and then add the references...
Maven always seems to download more than I need, so I always place libaries/dlls and things like that manually.
如果您使用 Maven:
添加 poi 和 poi-ooxml 依赖项以使其正常工作:)
If you use Maven:
Add the poi and the poi-ooxml dependency to make it work :)
在尝试了多种方法之后,真正有效的是:
1.手动下载“poi”和“poi-ooxml”
2.将这些 d/w jar 添加到“Maven 依赖项”中
After trying multiple things,what really worked was:
1. downloading "poi" and "poi-ooxml" manually
2.Adding these d/w jars into "Maven Dependencies"
我也遇到了同样的问题,所以我挖了poi-3.17.jar文件,里面没有xssf包。
然后我浏览了其他文件,发现 xssf int poi-ooxml-3.17.jar
所以看来解决方案是添加
到您的项目中,因为这似乎使它工作(至少对我来说)
I had the same problem, so I dug through the poi-3.17.jar file and there was no xssf package inside.
I then went through the other files and found xssf int the poi-ooxml-3.17.jar
So it seems the solutions is to add
to your project, as that seems to make it work (for me at least)
2021 年 11 月 6 日实际情况:
Actual for 06.11.2021 days:
1)从 POI 文件夹导入所有 JAR
2)从POI文件夹的子目录ooxml文件夹导入所有JARS
3)从 POI 文件夹的子目录 lib 文件夹导入所有 JARS
1) imported all the JARS from POI folder
2) Imported all the JARS from ooxml folder which a subdirectory of POI folder
3) Imported all the JARS from lib folder which is a subdirectory of POI folder
问题:导入“org.apache.poi.xssf.usermodel.XSSFWorkbook”类时,在 Eclipse 中显示错误。
解决方案:使用此maven依赖项来解决此问题:
-Hari Krishna Neela
Problem: While importing the " org.apache.poi.xssf.usermodel.XSSFWorkbook"class showing an error in eclipse.
Solution: Use This maven dependency to resolve this problem:
-Hari Krishna Neela
我找到了解决方案
你们需要牢记一些要点。
有两种不同的依赖关系,一种是 (poi) &其他依赖项是 (poi-
ooxml),但请确保您必须在代码中使用 poi-ooxml 依赖项。
只需在 pom.xml 中添加以下依赖项即可保存它。
3.保存pom.xml后,您需要尝试一些小事情,使用
(.) 操作员将尝试导入/获取它 &最终不会看到任何错误
因为现在它已经将那个东西导入到你的包中了。
示例代码以更好地理解!
我尽力为您提供解决方案,如果您在这里遇到任何问题评论,我会尝试
来解决它。
继续学习伙计们!
I Got the Solution Guys
You need to keep some points in your mind .
There are two different dependency one is (poi) & other dependency is (poi-
ooxml) but make sure you must use poi-ooxml dependency in your code.
Just Add the following dependency in pom.xml & Save it.
3 .After you have saved the pom.xml then you need to try a small thing ,Use
(.) operator will try to import/fetch it & finally will not see any sort of error
because now it has imported that thing in your package.
Sample Code to Understand Better !!
I tried my best to give you the solution , If you face any issue comment here i will try
to solve it .
Keep Learning Guys !!
如果您使用 Maven:
poi => artifactId 中的 poi-ooxml
If you use Maven:
poi => poi-ooxml in artifactId
我在应用程序“build.gradle”中添加了以下内容
I added below contents in app "build.gradle"
OOXML 文件格式的类(例如 .xlsx 的 XSSF)位于不同的 Jar 文件中。您需要在项目中包含 poi-ooxml jar 及其依赖项
您可以在 POI 网站 此处。
您可能想要做的是下载 3.11 二进制包,获取
poi-ooxml
jar,以及 ooxml-lib 目录中的依赖项。将这些导入到您的项目中,您就会被排序。或者,如果您使用 Maven,则可以查看此处以获取您的工件列表你想要依赖,但它希望是这样的:
poi-ooxml maven 依赖项将自动为你引入主 POI jar 和依赖项。如果您想使用非电子表格格式,您还需要依赖
poi-scratchpad
工件,详见 POI 组件页面The classes for the OOXML file formats (such as XSSF for .xlsx) are in a different Jar file. You need to include the poi-ooxml jar in your project, along with the dependencies for it
You can get a list of all the components and their dependencies on the POI website here.
What you probably want to do is download the 3.11 binary package, grab the
poi-ooxml
jar from it, and the dependencies in theooxml-lib
directory. Import these into your project and you'll be sorted.Alternately, if you use Maven, you can see here for the list of the artificats you'll want to depend on, but it'd want to be something like:
The poi-ooxml maven dependency will pull in the main POI jar and the dependencies for you automatically. If you want to work with the non-spreadsheet formats, you'd also want to depend on the
poi-scratchpad
artifact too, as detailed on the POI components page为了使 OOXML 工作,您需要 POI-OOXML jar,它与 POI jar 分开打包。
从以下位置下载 POI-OOXML jar -
http://repo1.maven.org/maven2/org/apache/poi/poi-ooxml/3.11/poi-ooxml-3.11.jar
对于 Maven2 添加以下依赖项 -
For OOXML to work you need the POI-OOXML jar which is separately packaged from the POI jar.
Download the POI-OOXML jar from the following location -
http://repo1.maven.org/maven2/org/apache/poi/poi-ooxml/3.11/poi-ooxml-3.11.jar
For Maven2 add the below dependency -