当前位置:网站首页>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;
}
边栏推荐
- Love math experiment | phase 9 - intelligent health diagnosis using machine learning method
- 微服务之远程调用
- 100 important knowledge points that SQL must master: retrieving data
- 本周二晚19:00战码先锋第8期直播丨如何多方位参与OpenHarmony开源贡献
- 系统自带的karsonzhang/fastadmin-addons报错
- 创建对象时JVM内存结构
- 100 important knowledge points that SQL must master: creating calculation fields
- 小王的面试训练任务
- Go从入门到实战——接口(笔记)
- AI 绘画极简教程
猜你喜欢

Go从入门到实战——协程机制(笔记)

Experience Navicat premium 16, unlimited reset, 14 day trial method (with source code)

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

A set of system to reduce 10 times the traffic pressure in crowded areas

今晚战码先锋润和赛道第2期直播丨如何参与OpenHarmony代码贡献

Tiktok's interest in e-commerce has hit the traffic ceiling?

Galaxy Kirin system LAN file sharing tutorial

Codeforces Round #717 (Div. 2)

Ceph分布式存储

Go从入门到实战——channel的关闭和广播(笔记)
随机推荐
Go从入门到实战——接口(笔记)
PCIE知识点-008:PCIE switch的结构
Go from introduction to actual combat - panic and recover (notes)
Go从入门到实战——channel的关闭和广播(笔记)
Squid proxy server
mysql使用笔记一
送你12个常用函数公式,用过的都说好
MySQL usage notes 1
Industry case | see the operation of bank digital transformation from the king of retail
Yu Wenwen, Hu Xia and other stars take you to play with the party. Pipi app ignites your summer
GoLand permanently activated
Educational Codeforces Round 108 (Rated for Div. 2)
ICML2022 | 可扩展深度高斯马尔可夫随机场
Open a new ecological posture | use the wrodpress remote attachment to store it in COS
银河麒麟系统局域网文件共享教程
Go from introduction to actual combat - package (notes)
MySQL client tools are recommended. I can't imagine that it is best to use Juran
MYSQL 性能优化 index 函数,隐藏,前缀,hash 索引 使用方法(2)
微服务之远程调用
Acwing周赛57-数字操作-(思维+分解质因数)