一般用jxl在插入单元格内容之前都需要对ceil进行各种各样的样式设置,比如以下的:
WritableFont font1 = new WritableFont(WritableFont.TIMES, 12,
WritableFont.BOLD);
WritableCellFormat formatTitle = new WritableCellFormat(font1);// 表头样式
formatTitle.setBorder(jxl.format.Border.ALL,
jxl.format.BorderLineStyle.THIN);
formatTitle.setAlignment(jxl.format.Alignment.CENTRE);
WritableCellFormat formatCeil = new WritableCellFormat();// 非表头样式
formatCeil.setAlignment(jxl.format.Alignment.CENTRE);
formatCeil.setBorder(jxl.format.Border.ALL,
jxl.format.BorderLineStyle.THIN);
然后后面就用这两个对象进行插入的时候重用样式,比如:
Label titel0 = new Label(0, 0, "日期", formatTitle);// (列,行,值)
wsheet0.addCell(titel0);
今天遇到一个问题,就是想要在原来的样式对象的基础上进行增量修改的,再对某一些单元格进行插入,我们很理所当然地会想到以下的写法:
//在新的对象上增量设置,减少代码冗余
WritableCellFormat newFormat=formatTitle4sheet3;//下单错误统计头橙色
newFormat