简体   繁体   English

如何获得POI API的依赖关系?

[英]How do I get the dependency for POI API?

I wish to use POI api to read excel files. 我希望使用POI api读取Excel文件。 I get the dependency for POI api from Maven 我从Maven获取POI api的依赖项

<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>4.1.0</version>
</dependency>

How do I know what else needs to be included in the POM.xml to clear all the dependencies? 我怎么知道要清除所有依赖项,POM.xml还需要包含什么?

Looking into Apache POI components map 查看Apache POI组件图

在此处输入图片说明

my expectation is that you need to use poi-ooxml library, Maven transitive dependencies feature will get all underlying dependencies automatically so you basically need only this one: 我的期望是您需要使用poi-ooxml库,Maven 传递依赖项功能将自动获取所有基础依赖项,因此您基本上只需要以下一项:

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

An example code to read the file would be something like: 读取文件的示例代码如下所示:

OPCPackage pkg = OPCPackage.open(new File("/path/to/your/file.xlsx"));
XSSFWorkbook wb = new XSSFWorkbook(pkg);
XSSFSheet sheet = wb.getSheetAt(0);
XSSFRow row = sheet.getRow(0);
XSSFCell cell = row.getCell(0);
System.out.println(cell.getStringCellValue());
pkg.close();

References: 参考文献:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM