-
Notifications
You must be signed in to change notification settings - Fork 11
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
75 protect #157
75 protect #157
Conversation
* wrapper and method were (somehow) producing separate results * simplifies method with early returns * adds arg matching for type * adds more xml_node_create()
* use arg matching for properties * put all properties into a character vector * vectorize! * more xml_node_create()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree with the character vs null comment. though we have to check a very lot of functions and not only local, but with Excel too. Sometimes something looks strange on theR side, but is required by Excel for whatever reason.
and enabling Mac and windows builds lead to a hanging Mac build (6+ hours) that used all the remaining minutes 🙈
Oh, fantastic! Maybe we can add a timeout to the actions to prevent this? https://stackoverflow.com/questions/59073731/set-default-timeout-on-github-action-pipeline#59076067. |
I'll look into this, the last time this happened it was also caused by the mac ci. The quota will reset in 5 days ... |
Had a look at the failing tests and fixed these, but currently protect can cause broken Excels:
|
It appears that there's another problem, wb_protect and wb_protect_worksheet somehow behave different. The latter is a void function and I'm unsure why. Maybe the worksheets need different cloning or deep cloning? wb <- wb_workbook()
wb$add_worksheet("S1")
write_datatable(wb, 1, x = iris[1:30, ])
wb$worksheets[[1]]$sheetProtection
# Formatting cells / columns is allowed , but inserting / deleting columns is protected:
wb_protect_worksheet(wb, "S1",
protect = TRUE,
properties = c("formatCells", "formatColumns", "insertColumns", "deleteColumns")
)
wb$worksheets[[1]]$sheetProtection |
This is indeed fixed with deep cloning. Do we need to apply this to all worksheet touching wrappers? |
The remaining issue here is can we keep or enforce a certain order of Right now I can only think of something like selecting the names, removing the entry, increasing the length of the list (this will add a new null entry at the end), name the new entry and reorder by known names. But it's been a long week already ... |
# Conflicts: # man/wbWorkbook.Rd # tests/testthat/test-class-workbook-wrappers.R
"bookViews", "sheets", "functionGroups", "externalReferences", "definedNames", "calcPr", | ||
"oleSize", "customWorkbookViews", "pivotCaches", "smartTagPr", "smartTagTypes", "webPublishing", | ||
"fileRecoveryPr", "webPublishObjects", "extLst" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: I'm not entirely happy with this. It creates workbooks that Excel will open without hesitation, but it also limits us to use the structure in this field. If we miss an entry here, even though we import it when loading, we will no longer write it. Either it is in this list or it will be lost.
Added a few minor changes and merged! |
related to #75
Also removes a few
openxlsx2:::
calls while debugging the below. We should need to include those in anything.devtools::load()
works well enough to attach all package objects.I'm also seeing some opportunity to make sure that we initialize the objects correctly. In some cases we use
NULL
for an initial value and others might becharacter()
. Could be helpful to keep these aligned and make sure when we revert anything that we change the value to the default on initialization. For example, when we unprotect a workbook, do we set the field to""
,character()
orNULL
? This way we have a bit more parity when creating new workbooks and modifying existing ones.wb_protect()
changesI had to make some changes for
$protect()
because we were getting different results with the direct method call and the wrapper:on main
Created on 2022-05-01 by the reprex package (v2.0.1)
on pr
Created on 2022-05-01 by the reprex package (v2.0.1)
I don't know what exactly caused that, so I just cleaned it up a bit and now they return the same.
wb_protect_worksheet()
changesI couldn't help myself and modified the params. We now have a single
properties
param that we can list the individual properties to lock. The code is vectorized for checks and formatting. I'm wondering if we may want to add anotherif
statement where whenprotect = FALSE
the properties are reversed so we can unprotect theproperties
.