title: Google Sheet App Script - For Specific Sheet Hide Rows that are empty then export to PDF
body: <p><a href="https://docs.google.com/spreadsheets/d/1nFgdpoIdUUufvDTmkFvNR1NQ7BBxDiDe1xXf2JSyG0o/edit?usp=sharing/%22Google%20Sheet%20Link%22" rel="nofollow">Google Sheet Link</a></p>
  
  <p><strong>Updated</strong> with working script</p>
  
  <p>I am having a little bit difficulty figuring how to hide ranges of rows. 
  I also notice I am not using the updated api for ui messages.</p>
  
  <pre><code>UiApp API is deprecated.Expand
  File: PrintOrder Line: 28
  Anchor API is deprecated.Expand
  File: PrintOrder Line: 31
  UiInstance API is deprecated.Expand
  File: PrintOrder Line: 28
  </code></pre>
  
  <p>I have a sheet("printOrder" that pulls data from sheet("salesOrder")</p>
  
  <p>My plan is to link a script to button on salesOrder that prints or exports to PDF printOrder.</p>
  
  <p>Now I would like to hide the empty rows that are not filled in between Row 41 to Row 76.  Here is my mangled script so far:</p>
  
  <pre><code>function printOrder() {
  
      SpreadsheetApp.flush();
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var sheet = ss.getSheetByName("printOrder");
      var gid = sheet.getSheetId();
  
    //start number Row, start number Column, number of Rows , number of Columns 
      var range = sheet.getRange(41, 1, 36,10); 
  
    //get the values to those rows
      var values = range.getValues();
      Logger.log(values)
  
        for (var i=0; i&lt;values.length; i++) {
  
           if(values[i][0] === ""){
               sheet.hideRow(sheet.getRange(i+41,1));1
           }     
         }
  
    // Getting 'name' for PDF from Cell G5 
      var name = sheet.getRange("G5").getValue()+".pdf";
    // setting output options  
      var pdfOpts = '&amp;size=letter' +
                    '&amp;fzr=true'+ 
                    '&amp;portrait=true'+
                    '&amp;fitw=true'+
                    '&amp;gridlines=false'+
                    '&amp;printtitle=false'+
                    '&amp;sheetnames=false'+
                    '&amp;pagenum=CENTER'+
                    '&amp;attachment=false'+
                    '&amp;gid=';
  
    // retrieving url to link for download of pdf
      var url = ss.getUrl().replace(/edit$/, '') + 
                'export?exportFormat=pdf&amp;format=pdf' + 
                 pdfOpts + 
                 sheet.getSheetId();
  
    // simple ui popup to allow user to click-download pdf
      var app = UiApp.createApplication().setWidth(200).setHeight(50);
        app.setTitle('Print this sheet');
  
      var link = app.createAnchor('Download PDF', url).setTarget('_new');
        app.add(link);
        ss.show(app);
  
   }
  </code></pre>
  
  <p>Thank you for the guidance.</p>
  
  <p>Cheers,</p>
  
  <p>mars</p>