3

There is a single Google spreadsheet document. After selecting the very first A1 cell from a right-click pull-down menu I choose: Get Link to this Cell command.

The URL link is now stored in a memory and it can be pasted into any text editor. The copied cell's URL link would look like this:

https://docs.google.com/spreadsheets/d/f8s9HO0sidw9qIGwuqYq1wFFb9QWWpuFIXE3flYcgBG1/edit?ts=7559594f#gid=2879414198&range=A1

Question: How to get the the same cell's link using gspread in Python?

alphanumeric
  • 17,967
  • 64
  • 244
  • 392

1 Answers1

-3

First you'll need to generate OAuth2 credentials: http://gspread.readthedocs.io/en/latest/oauth2.html

You'll need to create a new authorization object in your Python using the OAuth2 credentials:

gc = gspread.authorize(credentials)

Then you need to create a connection to the worksheet:

# If you want to be specific, use a key (which can be extracted from
# the spreadsheet's url)
yoursheet = gc.open_by_key('0BmgG6nO_6dprdS1MN3d3MkdPa142WFRrdnRRUWl1UFE')

# Or, if you feel really lazy to extract that key, paste the entire url
yoursheet = gc.open_by_url('https://docs.google.com/spreadsheet/ccc?key=0Bm...FE&hl')

Then you can grab the cell you want

val = yoursheet.acell('B1').value

All code was pulled from the gspread Github basic usage with minor tweaks https://github.com/burnash/gspread

Cheers!

zachMade
  • 34
  • 5
  • 2
    `val = yoursheet.acell('B1').value` command returns the value the cell is filled (populated) with. But my question was how to get the Cell's URL - the URL link you get when you right-click and run `Get Link To This Cell` command. – alphanumeric Jun 18 '17 at 01:51
  • Hmm... I don't think Google exposes that functionality via the Sheets API. I suppose there are a few arduous ways of replicating opening the page and extracting the value that way, but I don't know if there's any easy way to do this. – zachMade Jun 18 '17 at 03:40