是否可以创建一个包含 Font、NumberFormat、BackgroundColor 和 Border 的 jxl.WritableCellFormat 属性?
这有效:
public static final NumberFormat numberformatter = new NumberFormat("#,###0.00");
public static final WritableFont defaultfont = new WritableFont(WritableFont.TAHOMA, 10);
public static final WritableCellFormat numberCellFormat = new WritableCellFormat(defaultfont, numberformatter); '
但我无法获得边框和颜色,认为创建工作表时多次需要相同类型的单元格。
最佳答案
实例化单元格后,您可以通过 WritableCellFormat.setBorder()
和 WritableCellFormat.setBackground()
方法设置边框和背景。
您可以看到API there .
如果你必须经常这样做,你可以创建一个像这样的辅助函数:
public static makeCell(NumberFormat format, WritableFont font, Color backgrd, Border border){
final WritableCellFormat result = new WritableCellFormat(defaultfont, numberformatter);
result.setBorder(border);
result.setBackground(backgrd);
return result;
}
关于java - jxl.WritableCellFormat 定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4603605/