googlesheets4
googlesheets4 copied to clipboard
Think about checkboxes
https://support.google.com/docs/answer/7684717
https://stackoverflow.com/questions/56781167/is-there-a-way-to-add-and-manipulate-check-boxes-in-a-google-sheets-using-python
On the R side, this is a minor variant of logical. In the Sheet, set dataValidation
for the cell.
https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/cells#DataValidationRule
Figure out how to read a checkbox with read_sheet()
.
If you just want the data, it works fine already. But if you were involved in some sort of round-tripping exercise, we're not set up for that. A version of same applied to formulas, of course, but with different considerations.
@jennybc Hello so is there a formula or something I can place through R that translates into google sheets as checkbox? for example, I want to create check box (in a separate column) next to each row, can this be done using this package? thank you
so is there a formula or something I can place through R that translates into google sheets as checkbox?
Not yet.
I want to create check box (in a separate column) next to each row, can this be done using this package?
Yes, but only in some very technical sense. I have had this need personally and have implemented it using low-level functions in this package. That is absolutely groundwork for exposing such functionality in a user-friendly way. But I haven't yet figured out what the interface would look like for an exported function.
In case you are highly motivated, here's a "use at your own risk", highly incomplete code snippet holding the really important bits:
# lots of code I'm not showing ...
rule_checkbox <- googlesheets4:::new(
"DataValidationRule",
condition = googlesheets4:::new_BooleanCondition(type = "BOOLEAN"),
inputMessage = "Lorem ipsum dolor sit amet",
strict = TRUE,
showCustomUi = TRUE
)
googlesheets4:::range_add_validation(ss, range = "x!E2:E", rule = rule_checkbox)
# lots of other code I'm not showing ...
Thanks @jennybc this is working brilliantly for me!
@jennybc Your code works perfectly to add the Checkbox Data validation rule! Is there also a way to remove the checkboxes using this package?