今天导出excel模板时需要加入标题,原有的方法没有添加标题的功能,只能修改了
// 标题
Row title = sheet.createRow(0);
//填充标题内容
this.createCellTitle(titleName,title,col);
//填充标题内容方法
public Cell createCellTitle(String cellName, Row row, int column)
{
// 创建列
Cell cell = row.createCell(0);
// 写入列信息
cell.setCellValue(cellName);
// 合并列
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, column));
cell.setCellStyle(styles.get("header"));
return cell;
}