0

I need to do lots of protected range manipulation. I want to unlink the sheet to perform the operations on a local copy and sync it afterwards. This, however, doesn't work.

spreadsheet = googleCloud.open_by_key(key)
worksheets = spreadsheet.worksheets()
worksheets[4].unlink()
print(worksheets[4].get_value((1, 5)))

This code causes an exception:

  File "/usr/local/lib/python2.7/dist-packages/pygsheets/worksheet.py", line 293, in get_value
    include_tailing_empty_rows=True, value_render=value_render)[0][0]
TypeError: 'bool' object has no attribute '__getitem__'

Without the unlink() the code works as expected. Am I using this method incorrectly? pygsheets from staging.

1 Answers1

0

You can't fetch values from an unlinked sheet.

When an unlinked sheet is linked these things happen.

  1. The sheets properties json is synced to cloud.
  2. The cells from data_grid is synced to cloud.
  3. All the data update calls called during unlinked state is replayed.

So any cell data fetching functions won't work when a worksheet is unliked. If you want to get sheet data, use the worksheet.data_grid, it is save while unlinking. Its a matrix of cells.

Nithin
  • 5,470
  • 37
  • 44