Updated with working script
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.
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
I have a sheet("printOrder" that pulls data from sheet("salesOrder")
My plan is to link a script to button on salesOrder that prints or exports to PDF printOrder.
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:
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<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 = '&size=letter' +
'&fzr=true'+
'&portrait=true'+
'&fitw=true'+
'&gridlines=false'+
'&printtitle=false'+
'&sheetnames=false'+
'&pagenum=CENTER'+
'&attachment=false'+
'&gid=';
// retrieving url to link for download of pdf
var url = ss.getUrl().replace(/edit$/, '') +
'export?exportFormat=pdf&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);
}
Thank you for the guidance.
Cheers,
mars