0
点赞
收藏
分享

微信扫一扫

Android 开发 读取excel文件 jxl.jar包


首先将 jxl.jar 导入,下载地址:

然后就按照这个demo就可以了,

   

String mainPath = System.getProperty("user.dir");
String Q1G_Path = mainPath + "/resource/Q1G.xls";

List<Gate> gate_list = new ArrayList<>();
Sheet sheet;
Workbook book;

//Q1G_Path为要读取的excel文件完全路径名
book = Workbook.getWorkbook(new File(Q1G_Path));

//获得第一个工作表对象(ecxel中sheet的编号从0开始,0,1,2,3,....)
sheet = book.getSheet(0);

for (int i = 1; i <= 69; i++) {
Gate gate = new Gate();
gate.id = sheet.getCell(0, i).getContents();//(列,行);
gate.plane_type = sheet.getCell(5, i).getContents();
gate.arrive_type = sheet.getCell(3, i).getContents();//(列,行)
gate.go_type = sheet.getCell(4, i).getContents();
gate.pucks = new ArrayList<>();
gate_list.add(gate);
}

举报

相关推荐

0 条评论