getActiveRange not returning current selection

后端 未结 3 678
情歌与酒
情歌与酒 2021-01-24 17:51

This should be a simple one, but I could not crack it myself... I want to copy the currently selected cells in the active sheet in an array called data:

var shee         


        
3条回答
  •  孤城傲影
    2021-01-24 18:23

    I think that the problem is

    var sheet = SpreadsheetApp.getActive().getActiveSheet();
    

    This because there is some kind of bug when "chaining" methods of two different Object Classes, in this case Class Spreadsheet and Class Sheet. There is a bug report related to this getActiveSheet() returns first sheet name

    The workaround is to replace the above line with:

    var spreadsheet = SpreadsheetApp.getActive();
    var sheet = spreadsheet.getActiveSheet();
    

    Related

    • Why Class Range getValues sometimes returns [[]] when chained to Class Sheet getActiveRange?

提交回复
热议问题