2011-06-16 43 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 
相關問題