添加依赖
implementation 'net.sourceforge.jexcelapi:jxl:2.6.12'
public class Excel {
public static void main(String[] args) {
Workbook workbook;
int i;
try {
workbook = Workbook.getWorkbook(new File("xxxx.xls"));
// 获取第一个工作表
Sheet sheet = workbook.getSheet(0);
//获取数据
//获取列
for (int j = 0; j <sheet.getRows() ; j++) {
//获取行
for (int k = 0; k < sheet.getColumns(); k++) {
Cell cell = sheet.getCell(k, j);
System.out.println("cell---:"+cell.getContents());
}
System.out.println();
}
workbook.close();
} catch (IOException e) {
e.printStackTrace();
} catch (BiffException e) {
e.printStackTrace();
}
}
}