//合并单元格
//(m,n)到(p,q)的单元格全部合并
WritableSheet.mergeCells(int m,int n,int p,int q);
//行高和列宽
//指定第i+1行的高度
WritableSheet.setRowView(int i,int height);
//指定第i+1列的宽度
WritableSheet.setColumnView(int i,int width);
//格式化数字
//NumberFormats表示数字格式,预定了几种格式,象NumberFormats.INTEGER表示取整,NumberFormats.FLOAT表示小数去两位。也可以自己定义数字格式。
WritableCellFormat integerFormat = new WritableCellFormat (NumberFormats.INTEGER);
Number number2 = new Number(0, 4, 3.141519, integerFormat);
sheet.addCell(number2);
WritableCellFormat floatFormat = new WritableCellFormat (NumberFormats.FLOAT);
Number number3 = new Number(1, 4, 3.141519, floatFormat);
sheet.addCell(number3);
NumberFormat fivedps = new NumberFormat("#.#####");
WritableCellFormat fivedpsFormat = new WritableCellFormat(fivedps);
Number number4 = new Number(2, 4, 3.141519, fivedpsFormat);
sheet.addCell(number4);
//也可以定义具有某种字体的数值格式:
WritableCellFormat fivedpsFontFormat = new WritableCellFormat(times16font, fivedps);
Number number5 = new Number(3, 4, 3.141519, fivedpsFontFormat);
sheet.addCell(number5);
//格式化日期
//DateFormat表示日期格式。
Date now = Calendar.getInstance().getTime();
DateFormat customDateFormat = new DateFormat ("dd MMM yyyy hh:mm:ss");
WritableCellFormat dateFormat = new WritableCellFormat (customDateFormat);
DateTime dateCell = new DateTime(0, 6, now, dateFormat);
sheet.addCell(dateCell);
|