excel保存到android数据库中 ,excel中的竖直数据保存不了
附图:
try {
Workbook wb=Workbook.getWorkbook(new File("/mnt/sdcard/2014-2015.xls"));
Sheet sheet=wb.getSheet(0);//get a Sheet object
int row=sheet.getRows();//行
int cols=sheet.getColumns();//列
System.out.println(sheet.getCell(2,1).getContents());
System.out.println(sheet.getCell(3,1).getContents());
System.out.println(sheet.getCell(4,1).getContents());
System.out.println(sheet.getCell(6,1).getContents());
//遍历所有数据
for(int i=1;i<row;i++){
info=new TeacherInfo();
info.setTestdate(sheet.getCell(0,i).getContents());
info.setCoursename(sheet.getCell(1,i).getContents());
info.setClassname(sheet.getCell(2,i).getContents());
info.setClassnumber(sheet.getCell(3,i).getContents());
info.setSameroom(sheet.getCell(4,i).getContents());
info.setTestroom(sheet.getCell(5,i).getContents());
info.setTestnumber(sheet.getCell(6,i).getContents());
info.setAcademy(sheet.getCell(7,i).getContents());
info.setTestteacher1(sheet.getCell(8,i).getContents());
info.setTestteacher2(sheet.getCell(9,i).getContents());
info.setTestteacher3(sheet.getCell(10,i).getContents());
info.setTestteacher4(sheet.getCell(11,i).getContents());
info.setCourseteacher(sheet.getCell(12,i).getContents());
info.setTestmode(sheet.getCell(13,i).getContents());
list.add(info);
}
wb.close();
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
sysout打印的是:
05-05 19:35:24.621: I/System.out(1873): 班级名称
05-05 19:35:24.631: I/System.out(1873): 班级
05-05 19:35:24.631: I/System.out(1873): 人数
05-05 19:35:24.631: I/System.out(1873): 同教室
05-05 19:35:24.631: I/System.out(1873): 标记
05-05 19:35:24.631: I/System.out(1873): 考场
05-05 19:35:24.631: I/System.out(1873): 人数
这是怎么回事,请大牛们指点,谢谢!
Is
sheet.getCell(0,i) written backwards? Try changing it to sheet.getCell(i,0).