tidyverse / googlesheets4

Google Spreadsheets R API (reboot of the googlesheets package)
https://googlesheets4.tidyverse.org
Other
359 stars 51 forks source link

Think about checkboxes #6

Open jennybc opened 6 years ago

jennybc commented 6 years ago

https://support.google.com/docs/answer/7684717

jennybc commented 4 years ago

https://stackoverflow.com/questions/56781167/is-there-a-way-to-add-and-manipulate-check-boxes-in-a-google-sheets-using-python

jennybc commented 4 years ago

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

jennybc commented 4 years ago

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.

bes827 commented 3 years ago

@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

jennybc commented 3 years ago

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 ...
samhunter commented 3 years ago

Thanks @jennybc this is working brilliantly for me!

morganlig commented 8 months ago

@jennybc Your code works perfectly to add the Checkbox Data validation rule! Is there also a way to remove the checkboxes using this package?