I wish to use POI api to read excel files. I get the dependency for POI api from Maven
<!-- 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?
Looking into Apache POI components map
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:
<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:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.