// mergeCells(a,b,c,d) 单元格合并函数a 单元格的列号b 单元格的行号c 从单元格[a,b]起,向下合并的列数d 从单元格[a,b]起,向下合并的行数
try {
sheet.mergeCells(startcol, startrow, endcol, endrow);
WritableFont font = new WritableFont(WritableFont.createFont("宋体"), 14, WritableFont.BOLD); // 字体设置
WritableCellFormat format = new WritableCellFormat(font);
format.setVerticalAlignment(VerticalAlignment.CENTRE); // 设置单元格居中
WritableCell cell=new Label(startcol,startrow,value,format);
sheet.addCell(cell);
} catch (WriteException e) {
e.printStackTrace();
}
try {
sheet.mergeCells(startcol, startrow, endcol, endrow);
WritableFont font = new WritableFont(WritableFont.createFont("宋体"), 14, WritableFont.BOLD); // 字体设置
WritableCellFormat format = new WritableCellFormat(font);
format.setVerticalAlignment(VerticalAlignment.CENTRE); // 设置单元格居中
WritableCell cell=new Label(startcol,startrow,value,format);
sheet.addCell(cell);
} catch (WriteException e) {
e.printStackTrace();
}