0

I have a dataframe that I have applied a space between each group in a given category using the following code.

DF2 <- head(do.call(rbind, by(DF, DF$AcctName, rbind,"")), -1)

Whenever I try to use DF2 in an openxlsx script with the following number format, the resulting Excel file has no formatting and only the raw data. What is causing the script to not apply the format to the Excel file, as the script works normally if I do not perform the rbind code adding the spacing?

addWorksheet(wb, "Sheet")
writeData(wb, "Sheet", DF2, startCol = 2, startRow = 2)
midStyle <- createStyle(halign = "center", numFmt = "#,##0;-#,##0;-")
addStyle(wb, "Sheet", midStyle, rows = 2:18, cols = 2:55, gridExpand = T)
Brandon
  • 47
  • 5
  • 2
    Can you please provide a reproducible example? define DF so that I can run the same code of yours – Edo Nov 26 '19 at 23:34
  • My dataframe is being generated using a SQL import and obdc package. But the data consists of the following structure. `AcctName , Year, W1, W2...etc for all 52 weeks.` – Brandon Nov 27 '19 at 00:38
  • Use `dput` to give us a sample of `DF` (something we can copy and run immediately). – A. S. K. Nov 27 '19 at 04:00

0 Answers0