当前位置:网站首页>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;
}
边栏推荐
猜你喜欢

100 important knowledge points that SQL must master: sorting and retrieving data

Industry case | see the operation of bank digital transformation from the king of retail

Let Ma Huateng down! Web3.0, hopeless

Go从入门到实战——接口(笔记)

Codeforces Round #717 (Div. 2)

squid代理服務器

Go從入門到實戰——接口(筆記)

于文文、胡夏等明星带你玩转派对 皮皮APP点燃你的夏日

Ceph分布式存储

Show the comprehensive strength of strong products, and make the first show of 2022 Lincoln aviator in Southwest China
随机推荐
强制 20 天内开发 APP 后集体被裁,技术负责人怒批:祝“早日倒闭!”
Go从入门到实战——接口(笔记)
Use the storcli tool to configure raid. Just collect this article
Go from introduction to actual combat - context and task cancellation (notes)
gomock mockgen : unknown embedded interface
MySQL客户端工具推荐,一定想不到最好用巨然是它
覆盖接入2w+交通监测设备,EMQ 为深圳市打造交通全要素数字化新引擎
Codeforces Round #722 (Div. 2)
SQL必需掌握的100个重要知识点:组合 WHERE 子句
今晚战码先锋润和赛道第2期直播丨如何参与OpenHarmony代码贡献
100 important knowledge points that SQL must master: retrieving data
SQL必需掌握的100个重要知识点:用通配符进行过滤
ICML2022 | 可扩展深度高斯马尔可夫随机场
安装gatewayworker之后启动start.php
MySQL performance optimization index function, hidden, prefix, hash index usage (2)
抖音的兴趣电商已经碰到流量天花板?
Go从入门到实战——Context与任务取消(笔记)
AI 绘画极简教程
Flask----应用案例
Full record of 2022 open source moment at Huawei partners and Developers Conference