Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wb_comment] modify the background color. closes #869 #870

Merged
merged 9 commits into from
Dec 12, 2023
Merged

Conversation

JanMarvin
Copy link
Owner

wb <- wb_workbook()
wb$add_worksheet("Sheet 1")

# write comment without author
c1 <- wb_comment(text = "this is a comment", author = "", visible = TRUE)
wb$add_comment(dims = "B10", comment = c1)

# Write another comment with author information
c2 <- wb_comment(text = "this is another comment", author = "Marco Polo")
wb$add_comment(sheet = 1, dims = "C10", comment = c2)

# write a styled comment with system author
s1 <- create_font(b = "true", color = wb_color(hex = "FFFF0000"), sz = "12")
s2 <- create_font(color = wb_color(hex = "FF000000"), sz = "9")
c3 <- wb_comment(text = c("This Part Bold red\n\n", "This part black"), style = c(s1, s2))

wb$add_comment(sheet = 1, dims = wb_dims(3, 6), comment = c3, color = wb_color("green"))
if (interactive()) wb$open()

@JanMarvin
Copy link
Owner Author

JanMarvin commented Dec 12, 2023

Add background image to comment

library(openxlsx2)
wb <- wb_workbook()
wb$add_worksheet("Sheet 1")

# file extension must be png or jpeg, not jpg?
tmp <- tempfile(fileext = ".png")
png(file = tmp, bg = "transparent")
plot(1:10)
rect(1, 5, 3, 7, col = "white")
dev.off()
#> quartz_off_screen 
#>                 2

# write comment without author
c1 <- wb_comment(text = "this is a comment", author = "", visible = TRUE)
wb$add_comment(dims = "B12", comment = c1, file = tmp)

if (interactive()) wb$open()

R/class-workbook.R Outdated Show resolved Hide resolved
@JanMarvin JanMarvin merged commit 86a167f into main Dec 12, 2023
9 checks passed
@JanMarvin JanMarvin deleted the comment_color branch December 12, 2023 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant