2

I'm looking for a way to set the color of the background of an Excel worksheet using Java's Apache POI

Thanks!

biggtor
  • 47
  • 1
  • 8

2 Answers2

1

Try XSSFSheet.setTabColor from the POI Documentation

Edited:

You may need to apply it to each cell / row style.

How to apply background color for the rows in excel sheet using Apache POI?

Another similar example/better explanation here:

excel poi: apply foreground color to blank cells

Community
  • 1
  • 1
Mike
  • 3,186
  • 3
  • 26
  • 32
  • This function sets the color of the tab's background, but not the sheet's one. Thanks anyway, I'll keep on searching for a solution! – biggtor Sep 06 '12 at 08:16
  • @biggtor Updated the answer. Another Resource: http://obscuredclarity.blogspot.de/2011/12/set-background-color-and-add-border-to.html taken from here: http://stackoverflow.com/questions/12242828/starting-with-apache-poi – Mike Sep 06 '12 at 13:55
0
HSSFCellStyle cellStyle = workBook.createCellStyle();
style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
cell.setCellStyle(style);
swamy
  • 1,200
  • 10
  • 23