当前位置:网站首页>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;
}
边栏推荐
- MySQL Express - day 1 - basic introduction
- MySQL client tools are recommended. I can't imagine that it is best to use Juran
- Day8 ---- 云资讯项目介绍与创建
- MySQL客户端工具推荐,一定想不到最好用巨然是它
- What is the core competitiveness of front-line R & D personnel aged 35~40 in this position?
- AI 绘画极简教程
- Unleash the innovative power of open source database | [Gansu] opengauss meetup has come to a successful conclusion
- squid代理服务器
- Covering access to 2w+ traffic monitoring equipment, EMQ creates a new digital engine for all elements of traffic in Shenzhen
- Ceph分布式存储
猜你喜欢

DO280OpenShift访问控制--security policy和章节实验

Covering access to 2w+ traffic monitoring equipment, EMQ creates a new digital engine for all elements of traffic in Shenzhen

SQL必需掌握的100个重要知识点:排序检索数据

How to participate in openharmony code contribution

100 important knowledge points that SQL must master: using functions to process data

Go从入门到实战——channel的关闭和广播(笔记)

Show the comprehensive strength of strong products, and make the first show of 2022 Lincoln aviator in Southwest China

White whoring red team goby & POC, how do you call white whoring?

Go从入门到实战——共享内存并发机制(笔记)

Go从入门到实战——接口(笔记)
随机推荐
Covering access to 2w+ traffic monitoring equipment, EMQ creates a new digital engine for all elements of traffic in Shenzhen
Tiktok's interest in e-commerce has hit the traffic ceiling?
oss上传调用的是哪个方法
体验Navicat Premium 16,无限重置试用14天方法(附源码)
关于异常处理的知识整理
SQL必需掌握的100个重要知识点:检索数据
银河麒麟系统局域网文件共享教程
Go从入门到实战—— 多路选择和超时控制(笔记)
Is it safe to open an account and buy stocks? Who knows
MySQL performance optimization index function, hidden, prefix, hash index usage (2)
Kirin V10 installation font
Go从入门到实战——channel的关闭和广播(笔记)
SQL必需掌握的100个重要知识点:使用函数处理数据
Go from introduction to actual combat - package (notes)
今晚战码先锋润和赛道第2期直播丨如何参与OpenHarmony代码贡献
100 important knowledge points that SQL must master: retrieving data
How to participate in openharmony code contribution
Navicat premium connection problem --- host 'XXXXXXXX' is not allowed to connect to this MySQL server
Tutorial | fNIRS data processing toolkit homer2 download and installation
本周二晚19:00战码先锋第8期直播丨如何多方位参与OpenHarmony开源贡献