开发者

JXL Attempt to modify a referenced format while setting background color

While trying to execute the below code:

Colour selectedColour = Colour.WHITE;
myWritableCellFormat.setBackground(selectedColour);

I am getting this Exception:

jxl.write.biff.JxlWriteException: Attempt to modify a referenced format

Why is this? For reference I've used the same object before these 2 lines to write a cell with another color. Is this of any 开发者_C百科importance?


If you want to change the color for different cell, you need to create the different WritableFont object and have to pass to WritableCellFormat constructor.

i.e every time you need to create new objects for WritableFont, WritableCellFormat classes.

WritableFont font = new WritableFont(WritableFont.createFont("Calibri"), 11);
WritableCellFormat format = new WritableCellFormat(font);
format.setBackground(Colour.LIGHT_GREEN, Pattern.SOLID);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜