使用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()
相关推荐
医疗信息化王工5 小时前
DataForge:基于 Python 的数据库批量导出 Excel 工具——从架构到部署的全流程实战
数据库·python·excel
1314lay_100711 小时前
通过Sql Server创建EXCEL文件:master..xp_cmdshell
数据库·excel
2601_9623008117 小时前
Python + Requests + Pytest + Excel + Allure:接口自动化测试项目实战
python·excel·pytest·allure·requests
ms365copilot18 小时前
Excel Copilot一键美化图表,无需手动调格式
excel·copilot·outlook
2501_9336707919 小时前
内部审计校招的数据化趋势:SQL、Excel、Power BI和证书选择
数据库·sql·excel
weixin_493503672 天前
商会系统里的在线文件预览:PDF/Word/Excel 三种实现与选型(Node + 前端实战)
pdf·word·excel
asdzx672 天前
Python 解析 Excel 数据、图片与图表的实现方案
python·excel
慧都小妮子2 天前
GcExcel 服务端 Excel 组件:无需安装 Office 的 Java/.NET 报表方案
java·.net·excel·gcexcel·服务端excel组件
The Future is mine2 天前
Excel如何只允许对部分表格内容进行修改
excel
2601_962099462 天前
Python xlwt设置excel单元格字体及格式
python·excel·xlwt·样式设置·单元格格式