Skip to content
Advertisement

How could I get the link of an specific sheet with Google script?

I have a spreadsheet with many sheets. Each sheet is a report and has a different link. How could I get the link of this active sheet?

Eg: Output > The link of the report is available here.

Advertisement

Answer

Your ‘here’ link doesn’t work, however, in lieu of that, it is possible to create a public hyperlink to a specific sheet.

When you open the Google Sheet and navigate the sheets in your browser, you will notice that there is an anchor element to the URL that is #gid=some_number .

Appending that same #gid=some_number piece to any hyperlink you have for the spreadsheet will link directly to that sheet.

If you are generating the sheets programmatically using a script, so don’t know the gid in advance, then you will need to use the getSheetID function in your Google Script

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement