博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Excel 日期转换
阅读量:4318 次
发布时间:2019-06-06

本文共 2390 字,大约阅读时间需要 7 分钟。

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);    }

转载于:https://www.cnblogs.com/kedoudejingshen/p/3854790.html

你可能感兴趣的文章
linux uniq 命令
查看>>
Openssl rand命令
查看>>
HDU2825 Wireless Password 【AC自动机】【状压DP】
查看>>
BZOJ1015: [JSOI2008]星球大战starwar【并查集】【傻逼题】
查看>>
HUT-XXXX Strange display 容斥定理,线性规划
查看>>
mac修改用户名
查看>>
一道关于员工与部门查询的SQL笔试题
查看>>
Canvas基础
查看>>
[Hive - LanguageManual] Alter Table/Partition/Column
查看>>
可持久化数组
查看>>
去除IDEA报黄色/灰色的重复代码的下划波浪线
查看>>
Linux发送qq、网易邮件服务配置
查看>>
几道面试题
查看>>
【转】使用 WebGL 进行 3D 开发,第 1 部分: WebGL 简介
查看>>
js用正则表达式控制价格输入
查看>>
chromium浏览器开发系列第三篇:chromium源码目录结构
查看>>
java开发操作系统内核:由实模式进入保护模式之32位寻址
查看>>
第五讲:单例模式
查看>>
Python编程语言的起源
查看>>
Azure ARMTemplate模板,VM扩展命令
查看>>