zoukankan      html  css  js  c++  java
  • 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);
        }
  • 相关阅读:
    安装 SciPy 和 scikit-learn 升级pip 及pip基本命令表
    js修改:before、:after的内容
    初试Celery
    python中的@
    python去除空格和换行符的方法
    Beautiful 疑问小记
    http://www.oreilly.com/catalog/errataunconfirmed.csp?isbn=9780596529321
    浏览器提示框事件
    从欧几里得距离、向量、皮尔逊系数到http://guessthecorrelation.com/
    win安装NLTK出现的问题
  • 原文地址:https://www.cnblogs.com/kedoudejingshen/p/3854790.html
Copyright © 2011-2022 走看看