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

前端 未结 2 1661
醉话见心
醉话见心 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:44

    Have you tried a simple function like this one ?

    function getRCposition(){
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var cell = ss.getActiveCell();
      var R = cell.getRow();
      var C = cell.getColumn();
      Browser.msgBox('Row = '+R+' and Col = '+C);
      }
    

    or a more 'universal' function like this :

    function getposition(){
       var sh = SpreadsheetApp.getActiveSheet();
       var ss = SpreadsheetApp.getActiveSpreadsheet();
      var range = ss.getActiveRange();
      var R = range.getRowIndex();
      var C = range.getColumnIndex();
      var W = range.getWidth();
      var H = range.getHeight();
      var A1not = range.getA1Notation();
      Browser.msgBox('Row = '+R+' / Col = '+C+' Width = '+W+'  / Heigth = '+H+'  A1 notation = '+A1not);
      }
    

提交回复
热议问题