Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9843

Adding range into code to get the range PDF [duplicate]

$
0
0

The code was working perfectly before adding this code > .getRange("A1:K33").activate() < the purpose of adding this line is to get the pdf of the given range.

If i remove the get range from the code it will work perfectly and save the whole sheet PDF into drive.

But i am trying to add a range into code that it will just make a pdf of desired range.

For example if i want A1:J50 range pdf then by mentioning that range into code and after running the code it should save the pdf of specific range.

Looking for any help.

function myFunction() {const ss = SpreadsheetApp.openByUrl("Url");  const sheet = ss.getSheetByName("PaySlip").getRange("A1:K33").activate();const ssID = ss.getId();const shID = sheet.getSheetId().toString();const nameFile = sheet.getRange("E7").getValue().toString() +".pdf";const fid = 'Url ID';  const folder = DriveApp.getFolderById(fid);  const requestData = {"method": "GET", "headers":{"Authorization":"Bearer "+ScriptApp.getOAuthToken()}};  const url = "https://docs.google.com/spreadsheets/d/"+ ssID +"/export?format=pdf&id="+ssID+"&gid="+shID;const result = UrlFetchApp.fetch(url , requestData);  folder.createFile(result.getBlob()).setName(nameFile);  }

Viewing all articles
Browse latest Browse all 9843

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>