0

I am trying to provide colors to my headers(first row) to all of my excel sheets, but it's not working. Am i missing something? Can you please provide your feedback

val workbook = XSSFWorkbook(inputStream)
val style: CellStyle = workbook.createCellStyle();
style.setFillForegroundColor(IndexedColors.GREEN.getIndex())
style.setFillPattern(FillPatternType.SOLID_FOREGROUND)
val font: Font = workbook.createFont()
font.color = IndexedColors.YELLOW.getIndex()
style.setFont(font)
val Sheet1 = workbook.createSheet("Sheet1")
Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
A gupta
  • 39
  • 5
  • 2
    So, you've created a `CellStyle` and `Sheet`, but to whose cells on a sheet, this style should be applied? You need to explicitly define it in your code (see https://stackoverflow.com/questions/37782880/apply-style-to-range-of-cells-apache-poi) – Михаил Нафталь Jan 18 '22 at 11:31
  • @МихаилНафталь True, thanks. I am wondering whether we can add hexacode for colors? I want color which is not provided by IndexedColors. So, how can i add hexacode? – A gupta Jan 18 '22 at 12:47
  • 1
    https://stackoverflow.com/questions/70425477/java-apache-poi-xssf-custom-rgb-cellbackground-not-working/70426030#70426030 – Axel Richter Jan 18 '22 at 14:20

0 Answers0