Apache POI 工作所需的 Maven 依赖项 [英] Required maven dependencies for Apache POI to work

查看:102
本文介绍了Apache POI 工作所需的 Maven 依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Apache POI 库来解析 excel 文件(旧版本和新版本的 excel).所以我想知道我需要从 Apache POI 中包含哪些 jar,因为在以下链接中:

I want to use Apache POI library to parse excel files (old versions and newer versions of excel). So I was wondering what jars do i need to include from the Apache POI because in following link:

http://mvnrepository.com/artifact/org.apache.poi

我发现要包含很多 jar,我是否需要将它们全部包含在内?

I found lots of jars to be included, do I need to include them all?

如果是,要包含的最新稳定版本是什么,它是否适用于 Microsoft 的 Office 2010?

If so, what is the latest stable version to be included, and does it work with Microsoft's Office 2010?

推荐答案

不,不必包含 POI 的所有依赖项.Maven 的传递依赖机制会解决这个问题.正如指出,你只需要表达对适当POI的依赖神器.例如:

No, you don't have to include all of POI's dependencies. Maven's transitive dependency mechanism will take care of that. As noted you just have to express a dependency on the appropriate POI artifact. For example:

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>3.8-beta4</version>
</dependency>

编辑(更新):我不知道以前的版本,但要解决对 org.apache.poi 包中的 XSSFWorkbook 和其他类的导入,您也需要为 poi-ooxml 添加依赖项.依赖项将是:

Edit(UPDATE): I don't know about previous versions but to resolve imports to XSSFWorkbook and other classes in org.apache.poi package you need to add dependency for poi-ooxml too. The dependencies will be:

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>4.1.2</version>
</dependency>
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>4.1.2</version>
</dependency>

这篇关于Apache POI 工作所需的 Maven 依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆