2010-01-19 119 views

回答

7

正如Alfabravo評論...現在它可能改變XSSFSheet標籤顏色。

sheet.setTabColor(int colorIndex) 

用於這一點,所以如果我們使用

sheet.setTabColor(num); 

NUM = 0:設置黑顏色的標籤。

num = 1:在標籤中設置白色。

num = 2:在選項卡中設置紅色。

num = 3:在選項卡中設置綠色。

num = 4:在選項卡中設置藍色。

num = 5:在選項卡中設置黃色。

等等。

+0

顏色列表:https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/IndexedColors.html例如sheet.setTabColor(IndexedColor.BLACK.getIndex()) – Piotr 2014-06-11 09:06:48

2

正如評論說彼得,
在POI 3.11我的色彩標籤必須使用:

import org.apache.poi.ss.usermodel.IndexedColors; 
sheet.setTabColor(IndexedColors.BLACK.getIndex()); 

(請注意,這是 「IndexedColor 小號」,而不是 「IndexedColor」 像顯示由彼得· )
這裏是一個顯示顏色的列表:http://jlcon.iteye.com/blog/1122538

+2

不推薦使用setTabColor(int colorIndex)方法。一個應該使用setTabColor(XSSFColor顏色)。 'final XSSFSheet diffExpected = wbDiff.createSheet(refSheetName); diffExpected.setTabColor(new XSSFColor(Color.RED));' – ScarOnTheSky 2017-05-15 12:25:55

相關問題