How can I bold part of a text string using openxlsx?
Asked Answered
C

0

9

I want to bold part of a text string. For example, is there a way to only bold 'text' in 'this is my text string' using openxlsx R package:

wb <- openxlsx::createWorkbook()

openxlsx::addWorksheet(wb, 'Contents')

bold_text <- openxlsx::createStyle(textDecoration = "bold")
openxlsx::addStyle(wb, sheet = 'Contents', bold_text, rows = 1, cols = 1, gridExpand = TRUE, stack = TRUE)

writeData(wb, sheet = 'Contents', x = 'this is my text string', startRow = 1, startCol = 1)

openxlsx::saveWorkbook(wb, file =  'D:testing.xlsx', overwrite = TRUE)
Charlatan answered 14/1, 2022 at 13:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.