java jxl讀取excel中Date類型


Workbook book = Workbook.getWorkbook(excel);
Sheet sheet = book.getSheet(0);
int clos = sheet.getColumns();//得到所有的列
int rows = sheet.getRows();//得到所有的行
for (int i = 1; i < rows; i++) {
    for (int j = 0; j < clos; j++) {
        //sheet.getCell(j, i).getContents();//第一個是列數,第二個是行數
        String columnValue = "";
        if ("DATE".equals(dataTypeMap.get(titles[j]))) {
            DateCell dc = (DateCell) sheet.getCell(j, i);
            Date data = dc.getDate();
            SimpleDateFormat dataFormat = new SimpleDateFormat("yyyy-MM-dd");
            String columnValue = dataFormat.format(data);
        } else {
            columnValue = sheet.getCell(j, i).getContents();
        }
    }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM