一、字符串java
cell.setCellValue(new HSSFRichTextString("hello world");
二、整数node
cell.setCellValue(10); HSSFCellStyle cellStyle = wwb.createCellStyle(); cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("0")); cell.setCellStyle(cellStyle);
三、小数ui
cell.setCellValue(1.25l); HSSFCellStyle cellStyle = wwb.createCellStyle(); cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("0.00")); cell.setCellStyle(cellStyle);
另:生成cell的代码spa
if ( node.isNumber() ) { cell.setCellStyle( numberStyle );//自定义数值样式 cell.setCellValue( Integer.parseInt( node.value() ) ); } else { cell.setCellStyle( stringStyle );//自定义字符串样式 cell.setCellValue( node.value() ); }