How to create hyperlink to range in Google Sheets App Script?

后端 未结 4 732
忘了有多久
忘了有多久 2020-12-10 09:39

I\'m trying to fill cells with hyperlinks to ranges in Google Sheets app script with the same desired outcome I would get had I done it in GUI. I managed to create hyperlink

4条回答
  •  情书的邮戳
    2020-12-10 09:42

    Here is another example. Hopefully, it is clean and self-explanatory

    function hyperlinkRange(shDest,rgDest,shSrc,rgSrc,linkText) {
      
      // get the spreadsheet
      var ss = SpreadsheetApp.getActiveSpreadsheet()
      
      // get the destination sheet id
      var idDest = shDest.getSheetId()  
      
      // link the range
      var formula = '=hyperlink("#gid='+idDest+'&range='+rgDest+'","'+linkText+'")'
      shSrc.getRange(rgSrc).setValue(formula)
      
    }

提交回复
热议问题