/*调用方式*/
/*设置整体excel单元格格式*/
FileOutputStream fos = null;
try {
fos = new FileOutputStream(rptRealPathAndName);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
//System.out.println("创建文件失败。。。");
log.info("In WriteRptByType.writeRptTypeFive(),create file failed!!!");
log.error(e.getMessage());
//e.printStackTrace();
return -1;
}
HSSFWorkbook workBook = new HSSFWorkbook();
HSSFSheet sheet = workBook.createSheet();;
workBook.setSheetName(0,"移动",HSSFWorkbook.ENCODING_UTF_16);
HSSFCellStyle cellStyleHdr = FontCellStyle.getAnyCellStyle(workBook,FontCellStyle.getHdrFont(workBook),HSSFCellStyle.ALIGN_CENTER, HSSFCellStyle.VERTICAL_CENTER, (short)-1, true);
HSSFRow curRow = sheet.createRow(0);
HSSFCell curCell= curRow.createCell((short)0);
curCell.setEncoding(HSSFCell.ENCODING_UTF_16);
curCell.setCellStyle(cellStyleHdr );
curCell.setCellValue("可以写入汉字,无乱码");
/*.............写入文件.............*/
try {
workBook.write(fos);
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
//System.out.println("写错误。。。");
succFlag = -1;
log.error("报表写错误:"+e.getMessage());
//e.printStackTrace();
责任编辑:小草