How to change tab tab color using Apache Poi

I am trying to set the background color of a sheet tab using Apache POI. I can't figure out how to set the style in the tabs themselves.

Thanks for the help!

+6
source share
3 answers

It would seem impossible. boo. This was the best explanation of why:

http://osdir.com/ml/user-poi.apache.org/2009-03/msg00034.html

+1
source

As Alfabravo commented ... now it's possible to change the color of the XSSFSheet tab.

 sheet.setTabColor(int colorIndex) 

used for this and therefore if we use

  sheet.setTabColor(num); 
  • num = 0 : set the color to black on the tab.

  • num = 1 : set white color on the tab.

  • num = 2 : set the red color on the tab.

  • num = 3 : set the green color on the tab.

  • num = 4 : set the color to blue on the tab.

  • num = 5 : set the yellow color on the tab.

and so on.

+8
source

As Peter commented,
for color tabs in POI 3.11 I had to use:

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

(Note that these are “IndexedColor s, ” not “IndexedColor,” as shown by Piotr.)
here is a list showing the colors: http://jlcon.iteye.com/blog/1122538

+2
source

All Articles