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
All cell styles are removed when registering new cell styles before adding the first worksheet #803
Comments
Thanks for the report @mrainers , I'll look into it. I don't really use the manual add styles approach anymore, therefore indeed there might be undetected hickups. |
By the way, are there other ways for defining a set of styles for later use in the workbook? By reading the vignette it didn't seem so to me. |
No, I simply apply the styles with |
A potential fix is in #805 . I'm not going to merge it without some further testing. I want to avoid breakage since this is a more delicate part of our code. Just for reference, I'm now used to this way of styling cells. This applies the style on the cell range library(openxlsx2)
wb <- wb_workbook()$
add_worksheet("test")$
add_fill(dims = "A1:D4", pattern_type = "solid", color = wb_color("blue"))$
add_font(dims = "A1:D4", size = 36, bold = TRUE, color = wb_color("yellow"))$
add_data(x = "Foo")
if (interactive()) wb$open() |
Should be fixed now in main. Please have a look if this solves your problem. |
I installed the newest version from github and can confirm that it is fixed. Thanks :-) |
I tried to create a workbook with the following workflow:
Let's see what cell styles are registered:
Check styles again:
So it is not possible to apply the predefined cell styles later in the workbook.
Also with this workflow it is also not possible to add additional cell styles later, after the worksheet creation. It seem that the styles_mgr is kind of messed up then for the cell styles.
Expected behavior
It should be possible to assign cell styles before adding the first worksheet.
Like the 'fills' or 'fonts' styles the cell styles should be initialized with a default before adding the first self defined style.
Version Info
R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)
attached packages: openxlsx2_1.0
The text was updated successfully, but these errors were encountered: