Prompt user for range in .gs function, pass array to html script and re-focus on the HTML dialog

前端 未结 1 2008
再見小時候
再見小時候 2020-12-22 03:18

I have a google sheet, I want to prompt a user to select ranges to get information from, store that into an array, and then create a chart in an html popup. I have read a bi

1条回答
  •  时光说笑
    2020-12-22 04:04

    Here's a simple example of picking a range with a modeless dialog. With just a few extra features thrown in for good measure.

    Code.gs:

    function selRange()//run this to get everything started.  A dialog will be displayed that instructs you to select a range.
    {
      var output=HtmlService.createHtmlOutputFromFile('pickRange').setWidth(300).setHeight(200).setTitle('Select A Range');
      SpreadsheetApp.getUi().showModelessDialog(output, 'Range Selector');
    }
    
    function selCurRng() 
    {
      var sso=SpreadsheetApp.getActive();
      var sh0=sso.getActiveSheet();
      var rg0=sh0.getActiveRange();
      var rng0A1=rg0.getA1Notation();
      rg0.setBackground('#777700');
      return rng0A1;
    }
    
    function clrRange(range)
    {
      var sso=SpreadsheetApp.getActive();
      var sh0=sso.getActiveSheet();
      var rg0=sh0.getRange(range);
      rg0.setBackground('#ffffff');
    }
    

    pickRange.html

    
    
      
        
        
        
      
      
        
    Please select your desired range.

    0 讨论(0)
提交回复
热议问题