0
votes

I need to read a Google Spreadsheet with the Google-Sheet API, but in addition to read the data I need to know which cells, or range of cells are protected.

Looking in the API documentation I found the way to create, delete or update protected ranges... (https://developers.google.com/sheets/api/samples/ranges) but I couldn't find any method that, given a range, can tell me which cells are protected and which are not.

1

1 Answers

2
votes

Answer:

You can make a call to Spreadsheets.get and view a list of protected ranges in the sheets/protectedRanges object key.

More Information:

As per the documentation on Sheet objects, which is a sub-object of the return from the Spreadsheets.get endpoint:

ProtectedRange

A protected range.

{
  "protectedRangeId": integer,
  "range": {
    object (GridRange)
  },
  "namedRangeId": string,
  "description": string,
  "warningOnly": boolean,
  "requestingUserCanEdit": boolean,
  "unprotectedRanges": [
    {
      object (GridRange)
    }
  ],
  "editors": {
    object (Editors)
  }
}

The range object of this protectedRange contains a GridRange object of the range that is being protected.

I hope this is helpful to you!

References: