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

pom:

<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>

代码示例:

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();
。。。
}

发布了7 篇原创文章 · 获赞 0 · 访问量 96

猜你喜欢

转载自blog.csdn.net/qq_39052099/article/details/104304132