java不用poi怎么读取excel,java-无法使用Apache POI读取Excel

您必须包括poi jar文件.它的版本将是4.1.0.如果使用的是Maven pom.xml,请包括以下依赖项.

org.apache.poi

poi-ooxml

4.1.0

org.apache.poi

poi

4.1.0

如果您不使用Maven,请从以下位置下载jar文件.

要使用Apache POI读取excel文件,如果不想使用Maven,则需要以下jar文件.

> poi-ooxml-4.1.0.jar

> poi-ooxml-schemas-4.1.0.jar

> xmlbeans-3.1.0.jar

> commons-compress-1.18.jar

> curveapi-1.06.jar

> poi-4.1.0.jar

> commons-codec-1.12.jar

> commons-collections4-4.3.jar

> commons-math3-3.6.1.jar

我在下面提供了有关如何使用的简短代码段.

FileInputStream file =

new FileInputStream(

new File(

"testdata\TestData_01.xlsx"));

XSSFWorkbook workbook = new XSSFWorkbook(file);

XSSFSheet sheet = workbook.getSheetAt(0);

Iterator rowIterator = sheet.iterator();

while (rowIterator.hasNext()) {

Row row = rowIterator.next();

Cell cell0 = row.getCell(0);

if (cell0 != null) {

System.out.println("First Column Data : "+cell0.getStringCellValue());

}

Cell cell1 = row.getCell(1);

if (cell1 != null) System.out.println("Second Column Data : "+cell1.getStringCellValue());

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值