2011-06-16 87 views
1

我想将单元格中的部分文本设置为一种颜色(字体颜色),将其他部分设置为另一种颜色。这可能与jxl api?或者它是一个限制?JAVA/JXL-单元格中文本的不同颜色

例如:

我有“的名字*”细胞,现在我想在蓝色的“名称”的颜色和红色“*”。

在此先感谢。

回答

4

是的,你可以做到这一点。请检查以下代码。

 WritableFont TableFormat = new WritableFont(WritableFont.ARIAL, 8, WritableFont.BOLD,false, UnderlineStyle.NO_UNDERLINE, Colour.WHITE); 
    WritableCellFormat tableFormatBackground = new WritableCellFormat(); //table cell format 
    tableFormatBackground.setBackground(Colour.DARK_BLUE) ; //Table background 
    tableFormatBackground.setBorder(Border.ALL, BorderLineStyle.THIN,Colour.BLACK); //table border style 
    tableFormatBackground.setFont(TableFormat); //set the font 
    tableFormatBackground.setAlignment(Alignment.CENTRE);// set alignment left