Getting the cursor row/column from a Google spreadsheet through a Javascript method

前端 未结 2 1683
醉话见心
醉话见心 2021-01-15 15:16

On 29 Mar 2010, Jason Hale wanted to use the spreadsheet cursor location to select an e-mail address for a Javascript app he was writing - See http://productforums.google.co

2条回答
  •  感动是毒
    2021-01-15 15:48

    The following code works for me. It prompts me with the row number of my current position in the spreaadsheet:

    function onOpen() {
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var menuEntries = [ {name: "Test1", functionName: "menuItem1"}];
      ss.addMenu("Tests", menuEntries);
    }
    
    function menuItem1() {
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      Browser.msgBox("You have selected row " + ss.getActiveCell().getRow());
    }
    

提交回复
热议问题