jxl.WritableCellFormat 定义
是否可以创建一个包含 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); '
但我无法获得边框和颜色,认为创建工作表时多次需要相同类型的单元格。
Is it possible to create one jxl.WritableCellFormat attribute which contains Font, NumberFormat, BackgroundColor and Border?
This works:
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); '
but I can't get borders and colors, thought same kind of cell is needed many times when creating sheets.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实例化单元格后,您可以通过
WritableCellFormat.setBorder()
和WritableCellFormat.setBackground()
方法设置边框和背景。您可以在那里查看 API。
如果你必须经常这样做,你可以创建一个像这样的辅助函数:
You can set the border and background via the
WritableCellFormat.setBorder()
andWritableCellFormat.setBackground()
methods after having instanciated your cell.You can see the API there.
If you have to do that a lot, you can make a helper function like this :
您可以通过 2 个步骤来完成此操作
创建 WritableFont
以 WritableFont、NumberFormats 作为参数创建 WritableCellFormat
附加代码片段
You Can do this by 2 steps
Create a WritableFont
Create a WritableCellFormat with WritableFont,NumberFormats as a parameter
Attaching the code snippet