Jonathan del Strother
Jonathan del Strother

Reputation: 2552

Link to open a Google Drive file in Sheets

Using the Google Drive API I can get a file's webViewLink to link to the file-preview in Drive, and the user can then select 'Open with Google Sheets' in the top bar to open the file up in Sheets.

Is there a way to skip that intermediary step, and link directly to that file in Google Sheets?

Upvotes: 1

Views: 5893

Answers (2)

pinoyyid
pinoyyid

Reputation: 22286

What are you seeing in webViewLink?

When I try, I get

"webViewLink": https://docs.google.com/spreadsheets/d/1egZQnArX7TOHlQWSHiba3TTNt9Y7JoqgDAIJMdM0MQ/edit?usp=drivesdk"

which directly opens the sheet.

So a couple of things:-

  1. Are you sure that the file in question is a native Google spreadsheet, or is it, for example, an uploaded Excel
  2. If your webViewLink is different, you could construct the URL yourself by setting your own file's ID after the /d/

Upvotes: 1

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116868

File.resource also contains a link called webViewLink

webViewLink string A link for opening the file in a relevant Google editor or viewer in a browser.

This will not work on all file types but it should work on sheets.

Upvotes: 2

Related Questions