Skip to content

How to change tab color for existing worksheet? #1096

Answered by JanMarvin
evan8daniels asked this question in Q&A
Discussion options

You must be logged in to vote

If - for whatever kind of reason you cannot update your openxlsx2 package - you could experiment with the following:

library(openxlsx2)

wb <- wb_load("testfile.xlsx")

tab_color <- xml_node_create("tabColor", xml_attributes = wb_color("green"))
tabColor <- sprintf('<sheetPr>%s</sheetPr>', tab_color)
wb$worksheets[[1]]$sheetPr <- tabColor
if (interactive()) wb$open()

This should work, but there might already be content in wb$worksheets[[1]]$sheetPr, so be careful and we have so many features and bugfixes, that an update to the latest release would be a huge benefit!

Replies: 1 comment 15 replies

Comment options

You must be logged in to vote
15 replies
@JanMarvin
Comment options

@evan8daniels
Comment options

@JanMarvin
Comment options

@JanMarvin
Comment options

Answer selected by evan8daniels
@evan8daniels
Comment options

@evan8daniels
Comment options

@JanMarvin
Comment options

@evan8daniels
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants