-
Notifications
You must be signed in to change notification settings - Fork 10
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_add_data] unify hyperlink and numeric styling #365
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
allow dims to be "A1:A2;C1:C2"
should be a C style index starting at 0
If FALSE no cellStyle is applied and the original cell style remains (if any was found).
This was referenced Oct 8, 2022
Merged
This was
linked to
issues
Oct 8, 2022
JanMarvin
changed the title
Add data and add style
[wb_add_data] unify hyperlink and numeric styling
Oct 8, 2022
the style creation is a bunch of duplicated code, but I've been to long at the PC already |
might fix #372
This could need some testing with styled files and newly created files |
Looks like it is working. The code below adds an ugly table into an existing worksheet. It goes back and forth to add background colors, number formats, borders, font and cell styles. wb <- wb_load(file = system.file("extdata", "loadExample.xlsx", package = "openxlsx2"))$
# add title
add_data("testing", dims = "C10", x = "MTCARS Title")$
add_font(dims = "C10", bold = "1", size = "16")$
# add data
add_data(x = head(mtcars), startCol = 3, startRow = 11, removeCellStyle = TRUE)$
add_fill(dims = "C11:M11", color = wb_colour("turquoise"))$
add_font(dims = "C11:M11", color = wb_colour("white"))$
add_border(dims = "C17:M17",
bottom_color = wb_colour(hex = "FF000000"),
bottom_border = "thin",
left_border = "",
right_border = "",
top_border = "")$
add_numfmt(dims = "J12:M17", numfmt = "0.%")$
add_fill(dims = "C12:M17", color = wb_colour("white"))$
add_border(dims = "C12:M17",
bottom_color = wb_colour(hex = "FF000000"),
bottom_border = "thin",
left_border = "thin",
right_border = "thin",
top_border = "",
inner_vgrid = "thin")$
add_border(dims = "C11:M11",
bottom_color = wb_colour(hex = "FF000000"),
bottom_border = "thick",
left_border = "thick",
right_border = "thick",
top_border = "thick",
inner_vgrid = "")$
add_fill(dims = "C12:M17", color = wb_colour("lightgray"), every_nth_row = 2)
wb$open() |
This was referenced Oct 13, 2022
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Second attempt to clean up style application. This unifies our attempts to apply styles when writing data. If we write to a workbook we can
applyCellStyles = TRUE
on top of what other style we have found (e.g. if a cell uses a font, border or fill: we only add our number format to the existing style).applyCellStyles = FALSE
removeCellStyle = TRUE