public static void importExcel2(File file) throws Exception, IOException {
Workbook book = Workbook.getWorkbook(file);
// 获得第一个工作表对象
Sheet sheet = book.getSheet( 0 );
// 得到第一列第一行的单元格
int columnum = sheet.getColumns(); // 得到列数
int rownum = sheet.getRows(); // 得到行数
System.out.println(columnum);
System.out.println(rownum);
for ( int i = 1 ; i < rownum; i ++ ) // 循环进行读写
{
// for ( int j = 0 ; j < columnum; j ++ ) {
// }
CaseInfor caseInfor = new CaseInfor();
System.out.print(sheet.getCell(0, i).getContents());
caseInfor.title=sheet.getCell(0, i).getContents();
// if(sheet.getCell(0, i).getContents()==""){
// flash.put("error", "标题不能为空");
// list(null,null);
// }
Cell cell1 = sheet.getCell(1, i);
if(sheet.getCell(1, i).getType() == CellType.DATE){
DateCell dc = (DateCell)cell1;
Date date = dc.getDate();
SimpleDateFormat ds = new SimpleDateFormat("yyyy-MM-dd");
String cellcon = ds.format(date);
System.out.print(cellcon);
System.out.print( " \t " );
caseInfor.acceptTime=date;
}
Cell cell2 = sheet.getCell(2, i);
if(sheet.getCell(1, i).getType() == CellType.DATE){
DateCell dc = (DateCell)cell2;
Date date = dc.getDate();
SimpleDateFormat ds = new SimpleDateFormat("yyyy-MM-dd");
String cellcon = ds.format(date);
System.out.print(cellcon);
caseInfor.deadTime=date;
System.out.print( " \t " );
}
caseInfor.department=sheet.getCell(3, i).getContents();
caseInfor.process=sheet.getCell(4, i).getContents();
caseInfor.account=sheet.getCell(5, i).getContents();
caseInfor.information=sheet.getCell(6, i).getContents();
caseInfor.mandatory=sheet.getCell(7, i).getContents();
caseInfor.save();
}
book.close();
flash.put("success", "导入成功");
list(null,null);
}