poi解析excel遇到的问题

本文介绍使用Apache POI库处理Excel文件的三个关键技巧:解决版本兼容性问题,解析纯数字单元格,以及读取时间格式。通过示例代码展示了如何配置依赖项,设置单元格类型,以及获取日期值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题一

poi对excel版本问题可用

Workbook workbook;
workbook = WorkbookFactory.create(upload);
Sheet sheet=workbook.getSheetAt(0);

maven 引入以来如下

 <dependency>
		    <groupId>org.apache.poi</groupId>
		    <artifactId>poi</artifactId>
		    <version>3.15</version>
		</dependency>
		
		<dependency>
		    <groupId>org.apache.poi</groupId>
		    <artifactId>poi-ooxml-schemas</artifactId>
		    <version>3.15</version>
		</dependency>
		
		<dependency>
		    <groupId>org.apache.poi</groupId>
		    <artifactId>poi-ooxml</artifactId>
		    <version>3.15</version>
		</dependency>
		
		<dependency>
		    <groupId>org.apache.xmlbeans</groupId>
		    <artifactId>xmlbeans</artifactId>
		    <version>3.0.0</version>
		</dependency>
		
		<dependency>
		    <groupId>com.github.virtuald</groupId>
		    <artifactId>curvesapi</artifactId>
		    <version>1.05</version>
		</dependency>

问题二

poi不能直接解析excel中的纯数字需要把数字转换成字符串

Cell numcell=row.getCell(2);
numcell.setCellType(CellType.STRING);
Integer num=Integer.parseInt(numcell.getStringCellValue());

问题三

poi获取excel中的时间

Date time=timeCell.getDateCellValue();

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值