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

穿精又带淫゛_ 提交于 2019-12-11 00:33:22

问题


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.


回答1:


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




回答2:


Good luck!

var thisDocumentUrl = SpreadsheetApp.getActiveSpreadsheet().getUrl();


来源:https://stackoverflow.com/questions/41664508/how-could-i-get-the-link-of-an-specific-sheet-with-google-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!