当前位置:网站首页>excel读取文件内容方法
excel读取文件内容方法
2022-06-27 19:23:00 【高粱】
/** * 描述:获取IO流中的数据,组装成List<List<Object>>对象 * @param in,fileName * @return * @throws IOException */
public List<List<Object>> getBankListByExcel(InputStream in, String fileName) throws Exception
{
List<List<Object>> list = null;
// 创建Excel工作薄
Workbook work = this.getWorkbook(in, fileName);
if (null == work)
{
throw new Exception("创建Excel工作薄为空!");
}
Sheet sheet = null;
Row row = null;
Cell cell = null;
list = new ArrayList<List<Object>>();
// 遍历Excel中所有的sheet
for (int i = 0; i < work.getNumberOfSheets(); i++)
{
sheet = work.getSheetAt(i);
if (sheet == null)
{
continue;
}
// 遍历当前sheet中的所有行
for (int j = sheet.getFirstRowNum(); j <= sheet.getLastRowNum(); j++)
{
row = sheet.getRow(j);
if (row == null || row.getFirstCellNum() == j)
{
continue;
}
// 遍历所有的列
List<Object> li = new ArrayList<Object>();
for (int y = row.getFirstCellNum(); y < row.getLastCellNum(); y++)
{
cell = row.getCell(y);
li.add(this.getCellValue(cell));
}
list.add(li);
}
}
((InputStream) work).close();
return list;
}
边栏推荐
- 互联网 35~40 岁的一线研发人员,对于此岗位的核心竞争力是什么?
- TypeScript学习
- Codeforces Round #722 (Div. 2)
- PCIE知识点-008:PCIE switch的结构
- Let Ma Huateng down! Web3.0, hopeless
- Galaxy Kirin system LAN file sharing tutorial
- Safe and efficient, non-contact "hand brushing" identification helps epidemic prevention and control
- 微服务之远程调用
- Experience Navicat premium 16, unlimited reset, 14 day trial method (with source code)
- 白嫖红队goby&POC,叫你如何白嫖?
猜你喜欢

Go从入门到实战——行为的定义和实现(笔记)

GFS分布式文件系统

快递e栈——数组篇小型项目

SQL Server for循环用法

释放开源数据库创新力量 | 【甘肃】openGauss Meetup圆满结束
![Unleash the innovative power of open source database | [Gansu] opengauss meetup has come to a successful conclusion](/img/21/9c5f5122270adea9444ff5f2d199ed.jpg)
Unleash the innovative power of open source database | [Gansu] opengauss meetup has come to a successful conclusion

Squid proxy server

非常全面的DolphinScheduler(海豚调度)安装使用文档

华为伙伴暨开发者大会2022开源时刻全纪录

Yu Wenwen, Hu Xia and other stars take you to play with the party. Pipi app ignites your summer
随机推荐
SQL必需掌握的100个重要知识点:组合 WHERE 子句
MYSQL 性能优化 index 函数,隐藏,前缀,hash 索引 使用方法(2)
GFS分布式文件系统
SQL必需掌握的100个重要知识点:IN 操作符
squid代理服務器
Go from entry to practice -- CSP concurrency mechanism (note)
今晚战码先锋润和赛道第2期直播丨如何参与OpenHarmony代码贡献
Ceph分布式存储
Go from introduction to practice - Interface (notes)
GoLand永久激活
White whoring red team goby & POC, how do you call white whoring?
Squid proxy server
100 important knowledge points that SQL must master: creating calculation fields
mysql使用笔记一
猜拳游戏专题训练
关于异常处理的知识整理
Go从入门到实战——Context与任务取消(笔记)
String类的常用方法
Use the storcli tool to configure raid. Just collect this article
squid代理服务器