我无法从一个电子表格的不同选项卡中获取URL。
我已经能够获得想要的工作表和第一页的URL,但是,我无法弄清楚如何获得指向该工作表中名称的任何特定选项卡的链接。
function nameCheck() {
var targetFolder = DriveApp.getFolderById('FOLDER ID HERE');
var getFiles = targetFolder.getFiles();
while (getFiles.hasNext()) {
var file = getFiles.next();
if (file.getMimeType() == 'application/vnd.google-apps.spreadsheet') {
if (file.getName() == 'TESTING'){
Logger.log('Success ' + file.getName())
Logger.log('Overview: ' + file.getUrl())
break;
}
}
}
}
答案 0 :(得分:0)
function ztest() {
var sheets = SpreadsheetApp.getActive().getSheets();
for (i = 0;i<sheets.length;i++){
if (sheets[i].getSheetName() == 'NAMEOFTAB'){ // replace with the name of your tab
Logger.log(sheets[i].getName()); // double checking along the way
Logger.log(sheets[i].getSheetId()); // double checking along the way
var URLgid = 'LINKHERE#gid=' + sheets[i].getSheetId() //replace link here with the general link
SpreadsheetApp.getActiveSpreadsheet().setActiveSheet(SpreadsheetApp.getActiveSpreadsheet().getSheets()[i]);
SpreadsheetApp.getActiveSpreadsheet().getRange('RANGE').setValue('REPLACE'); //replace the range and what you are substituting
Logger.log(URLgid) // testing to see what the link is
}
}
}