how to change the tab color of a worksheet with Apache Poi

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

sheet.setTabColor(int colorIndex) 

is used for that, and so if we use

 sheet.setTabColor(num);
  • num = 0 : set Black Color in tab.

  • num = 1 : set White Color in tab.

  • num = 2 : set Red Color in tab.

  • num = 3 : set Green Color in tab.

  • num = 4 : set Blue Color in tab.

  • num = 5 : set Yellow Color in tab.

and so on.


As commented by Piotr,
to color tabs in POI 3.11 i had to use:

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

(Note that it is "IndexedColors", not "IndexedColor" like showed by Piotr.)
here is a list showing the colors: http://jlcon.iteye.com/blog/1122538