-1

I need to output, using the openxlsx R package, some text rows in bullet point format. There doesn't appear to be a createStyle() option for doing this. Is anyone aware of a way to do this using openxlsx?

Peter
  • 11,500
  • 5
  • 21
  • 31
Allerious
  • 85
  • 4

1 Answers1

1

In the absence of reproducible data I've made up a small dataframe. You can do this with excel formulas, using the excel CHAR() function which accesses unicode characters. The example uses a solid dot, but you can use whatever bullet symbol appeals.

library(openxlsx)

dat <- data.frame(txt = c("This is some text", "Oneword", "1 a number"))


dat$bullet <-  paste("+CHAR(149)", paste0("\"", dat$txt, "\""), sep = "&")

class(dat$bullet) <- c(class(dat$bullet), "formula")


wb <- createWorkbook()
addWorksheet(wb, "Sheet 1")
writeData(wb, "Sheet 1", x = dat)
saveWorkbook(wb, "bullet-eg.xlsx", overwrite = TRUE)

Which results in:

enter image description here

Created on 2022-05-06 by the reprex package (v2.0.1)

Peter
  • 11,500
  • 5
  • 21
  • 31