java 循环取出Excle数据(将excle中的数据存入数据库)

pom:

<!-- 引入poi,解析workbook视图 -->
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi</artifactId>
			<version>3.16</version>
		</dependency>
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi-ooxml</artifactId>
			<version>3.14</version>
		</dependency>
		<!-- 处理excel和上面功能是一样的-->
		<dependency>
			<groupId>net.sourceforge.jexcelapi</groupId>
			<artifactId>jxl</artifactId>
			<version>2.6.10</version>
		</dependency>

代码示例:

String file = "E:\\TIMcookies\\1344\\FileRecv\\";   //excle保存位置的全路径file
Workbook rwb = Workbook.getWorkbook(new File(file));
Sheet rs = rwb.getSheet(0);//或者rwb.getSheet("sheet页名")
int clos = rs.getColumns();//得到所有的列
int rows = rs.getRows();//得到所有的行

for (int i = 1; i < rows; i++) {
    for (int j = 0; j < clos; j++) {
        //第一个是列数,第二个是行数
        //默认最左边编号也算一列 所以这里得j++
        String bankflownum = rs.getCell(j++, i).getContents();//银行流水号
        String accountNum = rs.getCell(j++, i).getContents();
        String zjaccountName = rs.getCell(j++, i).getContents();
        String pzdh = rs.getCell(j++, i).getContents();
        String bz = rs.getCell(j++, i).getContents();
        。。。
   }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值