Java利用POI导出Excel设置单元格格式

来源:互联网 发布:淘宝网刷销量 编辑:程序博客网 时间:2024/05/21 02:20
HSSFCellStyle cellStyle = demoWorkBook.createCellStyle();HSSFDataFormat format = demoWorkBook.createDataFormat();cellStyle.setDataFormat(format.getFormat("@"));cell.setCellStyle(cellStyle2);

HSSFDataFormat的数据格式

内置数据类型 编号 内置数据类型 编号 “General” 0 “h:mm:ss AM/PM” 0x13 “0” 1 “h:mm” 0x14 “0.00” 2 “h:mm:ss” 0x15 “#,##0” 3 “m/d/yy h:mm” 0x16 “#,##0.00” 4 保留为过国际化用 0x17 - 0x24 “($#,##0_);($#,##0)” 5 “(#,##0_);(#,##0)” 0x25 “($#,##0_);[Red]($#,##0)” 6 “(#,##0_);[Red](#,##0)” 0x26 “($#,##0.00);($#,##0.00)” 7 “(#,##0.00_);(#,##0.00)” 0x27 “($#,##0.00_);[Red]($#,##0.00)” 8 “(#,##0.00_);[Red](#,##0.00)” 0x28 “0%” 9 “_($*#,##0_);_($*(#,##0);_($* \”-\”_);_(@_)” 0x29 “0.00%” 0xa “_($*#,##0.00_);_($*(#,##0.00);_($*\”-\”??_);_(@_)” 0x2a “0.00E+00” 0xb “_($*#,##0_);_($*(#,##0);_($*\”-\”??_);_(@_)” 0x2b “# ?/?” 0xc “_($*#,##0.00_);_($*(#,##0.00);_($*\”-\”??_);_(@_)” 0x2c “# ??/??” 0xd “mm:ss” 0x2d “m/d/yy” 0xe “[h]:mm:ss” 0x2e “d-mmm-yy” 0xf “mm:ss.0” 0x2f “d-mmm” 0x10 “##0.0E+0” 0x30 “mmm-yy” 0x11 “@” - This is text format 0x31 “h:mm AM/PM” 0x12
原创粉丝点击