• Excel 日期转换


    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( " 	 " );
                                 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( " 	 " );
                }
                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);
        }
  • 相关阅读:
    A1132 Cut Integer (20分)
    A1131 Subway Map (30分)
    A1130 Infix Expression (25分)
    A1129 Recommendation System (25分)
    A1128 N Queens Puzzle (20分)
    arm指令集
    韦东山视频地址
    汇编知识
    emacs 使用教程
    ip
  • 原文地址:https://www.cnblogs.com/kedoudejingshen/p/3854790.html
Copyright © 2020-2023  润新知