使用POI技术实现excel文件的导入

1.POI概念

Apache POI 是用Java编写的免费开源的跨平台的Java API,Apache POI提供API给Java程序对Microsoft Office格式档案读和写的功能,其中使用最多的就是使用POI操作Excel文件。POI为"Poor Obfuscation Implementation"的首字母缩写,意为"简洁版的模糊实现"。

官网地址:

https://poi.apache.org/componen

2.POI坐标依赖

复制代码
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>4.1.2</version>
</dependency>

3.POI核心API概述

3.1 创建工作簿对象

复制代码
Workbook workbook=new XSSFWorkbook(path)

3.2 获取execl表中的sheet对象

复制代码
Sheet sheet = workbook.getSheetAt(0);

3.3 获取excel文件中所有物理数据的有效行数

复制代码
int rows = sheet.getPhysicalNumberOfRows()

3.4获取行对象

复制代码
Row row =sheet.getRow(i)

3.5 获取行中的列对象

复制代码
Cell cell=row.getCell(0)

3.6 获取列的字符串类型数据

复制代码
cell.getStringCellValue()

3.7 获取列的数字类型字段数据

复制代码
cell.getNumericCellValue()
相关推荐
开开心心_Every2 小时前
文件数量统计工具:支持多层文件夹数量统计
游戏·微信·pdf·excel·语音识别·swift·lisp
私人珍藏库3 小时前
[吾爱大神原创工具] Excel 数据批量转 Word 工具(2026年最新版)
word·excel·工具·软件·win
linuxxx1104 小时前
excel365批量拆分列并填充单元格
excel
徐赛俊4 小时前
Excel 数据写入 PowerPoint 表格与文本框(涨跌幅颜色自动处理)
powerpoint·excel
好好学操作系统4 小时前
notion+excel自动创建表格| 了解了notion api
数据库·python·oracle·excel·notion
UR的出不克1 天前
使用 Python 爬取 Bilibili 弹幕数据并导出 Excel
java·python·excel
wtsolutions1 天前
Understanding Excel Data Formats - What Excel to JSON Supports
ui·json·excel
ぁず1 天前
excel想生成一列随机数并删除公式保留值
excel
wtsolutions1 天前
Real-World Use Cases - How Organizations Use Excel to JSON
json·github·excel
一只小H呀の1 天前
pandas处理excel数据
excel·pandas