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