title: Create different xlsx sheet header colors in R
body: <p>I would like to have different header colors for the xlsx sheet I'm creating. However, I'm only able to create a single color for the header with the below code using <code>xlsx</code> package. Is there a way to do multiple colors with this package? Thank you!</p>
  <pre><code>## create workbook with styles
  wb &lt;- createWorkbook(type=&quot;xlsx&quot;)
  TABLE_COLNAMES_STYLE &lt;- CellStyle(wb) + Font(wb, isBold = TRUE) + Fill(foregroundColor=&quot;light blue&quot;) + Alignment(wrapText=T, horizontal = &quot;ALIGN_CENTER&quot;)
  TABLE_STYLE &lt;- CellStyle(wb) + Alignment(wrapText=T, h=&quot;ALIGN_RIGHT&quot;, v = &quot;VERTICAL_TOP&quot;) 
  
  ## load worksheet 1
  sheet &lt;- xlsx::createSheet(wb, sheetName=&quot;Sheet&quot;)
  
  ### load data to worksheet with styles
  cell.format &lt;- rep(list(TABLE_STYLE), (dim(iris)[2]))
  xlsx::addDataFrame(data.frame(iris), sheet, row.names=FALSE, colStyle=cell.format, colnamesStyle = TABLE_COLNAMES_STYLE)
  setColumnWidth(sheet, colIndex = c(1), colWidth = 15)
  setColumnWidth(sheet, colIndex = c(2), colWidth = 50)
  setColumnWidth(sheet, colIndex = c(3:(ncol(iris)-1)), colWidth = 15)
  xlsx::createFreezePane(sheet, 2,2,2,3)
  </code></pre>
  <p>This is what I'm getting from the above code:
  <a href="https://i.stack.imgur.com/PDbYe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PDbYe.png" alt="enter image description here" /></a></p>
  <p>This is what I'd like to achieve with multiple header colors for easier differentiation of the columns:
  <a href="https://i.stack.imgur.com/HFy16.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HFy16.png" alt="enter image description here" /></a></p>