title: Openxlsx in R Cell Merging and Centering content
body: <p>I am using <code>openxlsx</code> in r to create excel files with certain formatting parameters.  The following is the reusable code:</p>
  
  <pre><code>library(openxlsx)
  wb &lt;- createWorkbook()
  addWorksheet(wb, "TestSheet")
  df &lt;- mtcars
  df$Car &lt;- row.names(mtcars)
  row.names(df) &lt;- NULL
  df &lt;- df[,c(length(df), 1:length(df)-1)]
  
  forTopTit &lt;- createStyle(fontColour = "#ffffff", fgFill = "#F4D03F",halign = "center",wrapText = TRUE,valign = "center")
  forColHdr &lt;- createStyle(fontColour = "#ffffff", fgFill = "#4F81BD",halign = "center",wrapText = TRUE,valign = "center")
  forDatStl &lt;- createStyle(fontColour = "#ffffff", halign="center")
  
  writeData(wb,"TestSheet", "THIS IS A TEST MESSAGE", startCol = 1,startRow = 1,colNames = FALSE, rowNames = TRUE,
            headerStyle = forTopTit,borders = "surrounding",borderStyle = "medium")
  
  writeData(wb,"TestSheet", df, startCol = 1,startRow = 2,colNames = TRUE,rowNames = FALSE,
            headerStyle = forColHdr,borders='all',borderStyle = "thin")
  mergeCells(wb, "TestSheet", cols=1:length(df), rows=1)
  setColWidths(wb, "TestSheet", ignoreMergedCells = TRUE,cols = 1:ncol(df), widths = "auto")
  openXL(wb)
  </code></pre>
  
  <p>I am facing two problems:</p>
  
  <ol>
  <li><p>The title which I am trying to create in the first col first row  (which is a merged cell) is always left aligned and none of the color is getting applied.</p></li>
  <li><p>I want to center the data from row 3 col 2, which I am not able to do.  I tried using the following code:</p>
  
  <p>addStyle(wb, "TestSheet", style=forDatStl, rows = 3:nrow(df), cols=3:length(df), gridExpand=TRUE)</p></li>
  </ol>
  
  <p>The above kind of hides all the data points, though it still remains in the cell.  I am not able to see them but when I select the cell i could see it on the summary line above the sheet.  I am using Ubuntu 18.04 and Libre Office Calc.</p>