解決poi匯出excel日期格式為數字的問題

2021-10-03 04:35:07 字數 1077 閱讀 3980

最近在做使用poi匯出excel匯出**時,日期為純數字,並不是按照日期格式匯出

如下圖顯示:

!-- poi操作excel --

>

org.apache.poi<

/groupid>

poi-ooxml<

/artifactid>

3.8<

/version>

<

/dependency>`在這裡插入**片`

org.apache.poi<

/groupid>

poi<

/artifactid>

3.8<

/version>

<

/dependency>

org.apache.poi<

/groupid>

poi-ooxml-schemas<

/artifactid>

3.8<

/version>

<

/dependency>

// 日期格式轉為字串輸出

******dateformat sdf =

new******dateformat

("yyyy-mm-dd hh:mm:ss");

// 日期格式: yyyy-mm-dd 年月日 yyyy-mm-dd hh:mm:ss 年月日 時分秒

string time = sdf.

format

((date) rtdata.

get(

"reportedat"))

;// 這步根據具體的業務來確定

POI匯出Excel 合併單元格

合併方法 sheet.addmergedregion new cellrangeaddress firstrow,lastrow,firstcol,lastcol 引數分別表示 開始行索引,結束行索引,開始列索引,結束列索引.使用poi大致步驟 1.建立excel模板,並建立輸入流 fileinpu...

poi匯出excel單元格樣式設定

final xssfworkbook wb new xssfworkbook is final sheet datahssfsheet wb.getsheetat 0 獲取到第乙個工作表 final sheet datahssfsheetadd wb.getsheetat 1 獲取到第二個工作表 d...

POI匯出Excel檔案

workbook workbook exportservice.exportfile request,student outputstream out null try catch ioexception e finally catch exception e 實現類 設定各列寬度 short st...