Selecting a specific sheet based off either number from 0 or nameExport (or print) with a google script new version of google spreadsheets to pdf file, using pdf optionsHow to convert a Google Docs-File to an Excel-File (XLSX)Request Failed for URL Returned Code 404Google Apps Script UrlFetchApp returns 404 when the URL existsUrlFetch getting 404 error from spreadsheet URLGoogle sheet Duplicatea specific sheet from a specific sheet and specific cellGoogle Script - Multi cells copy from a sheet to another with “if empty” checkExport Google Sheet to PDF Programmatically with Custom ParametersPrint a certain range of a Google Spreadsheet using a scriptName a sheet based on a cell in that sheet
For a MOSFET, does capacitive gate current only flow through to the source?
Sitecore Powershell extensions module compatibility with Sitecore 9.2
Is Grandpa Irrational? Another Grandpa Mystery
Why are angular mometum and angular velocity not necessarily parallel, but linear momentum and linear velocity are always parallel?
'static' value appears to reset after function call
Symbol of the tennis ball
How do I run a game when my PCs have different approaches to combat?
How can I stop myself from micromanaging other PCs' actions?
Where is this photo of a group of hikers taken? Is it really in the Ural?
If my business card says 〇〇さん, does that mean I'm referring to myself with an honourific?
What is the purpose of the fuel shutoff valve?
Using "Kollege" as "university friend"?
Area of parallelogram = Area of square. Shear transform
What is a reasonable time for modern human society to adapt to dungeons?
What do I do when a student working in my lab "ghosts" me?
Film where a boy turns into a princess
Historicity doubted by Romans
Inadvertently nuked my disk permission structure - why?
Book with a female main character living in a convent who has to fight gods
Why is chess failing to attract big name sponsors?
Direct revelation mechanism's sets of strategies and types
Spoken encryption
Impact of throwing away fruit waste on a peak > 3200 m above a glacier
Determine if a triangle is equilateral, isosceles, or scalene
Selecting a specific sheet based off either number from 0 or name
Export (or print) with a google script new version of google spreadsheets to pdf file, using pdf optionsHow to convert a Google Docs-File to an Excel-File (XLSX)Request Failed for URL Returned Code 404Google Apps Script UrlFetchApp returns 404 when the URL existsUrlFetch getting 404 error from spreadsheet URLGoogle sheet Duplicatea specific sheet from a specific sheet and specific cellGoogle Script - Multi cells copy from a sheet to another with “if empty” checkExport Google Sheet to PDF Programmatically with Custom ParametersPrint a certain range of a Google Spreadsheet using a scriptName a sheet based on a cell in that sheet
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to generate an email with a PDF attachment of a specific sheet, not necessarily the active sheet. I have tried referencing the specific sheet name as well as the number, but to no avail, it chooses sheet 1, titled 'AMDashboard_English'. Please help.
function CreatePDF()
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("AMDashboard_English");
var sheet = ss.getSheetByName("AMDashboard_English");
Logger.log(sheet.getName());
var url = "https://docs.google.com/spreadsheets/d/SS_ID/export?".replace("SS_ID", sheet.getId());
var url_ext = 'exportFormat=pdf&format=pdf' // export as pdf / csv / xls /
var token = ScriptApp.getOAuthToken();
var sheets = ss.getSheets();
var blobs = [];
var i=0
var response = UrlFetchApp.fetch(
url + url_ext + sheets[i].getSheetId(),
headers: 'Authorization': 'Bearer ' + token
);
blobs[i] = response.getBlob().setName(sheets[i].getName() + '.pdf');
DriveApp.createFile(blobs[i]);
return blobs[i];
google-apps-script google-sheets export-to-pdf
add a comment |
I am trying to generate an email with a PDF attachment of a specific sheet, not necessarily the active sheet. I have tried referencing the specific sheet name as well as the number, but to no avail, it chooses sheet 1, titled 'AMDashboard_English'. Please help.
function CreatePDF()
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("AMDashboard_English");
var sheet = ss.getSheetByName("AMDashboard_English");
Logger.log(sheet.getName());
var url = "https://docs.google.com/spreadsheets/d/SS_ID/export?".replace("SS_ID", sheet.getId());
var url_ext = 'exportFormat=pdf&format=pdf' // export as pdf / csv / xls /
var token = ScriptApp.getOAuthToken();
var sheets = ss.getSheets();
var blobs = [];
var i=0
var response = UrlFetchApp.fetch(
url + url_ext + sheets[i].getSheetId(),
headers: 'Authorization': 'Bearer ' + token
);
blobs[i] = response.getBlob().setName(sheets[i].getName() + '.pdf');
DriveApp.createFile(blobs[i]);
return blobs[i];
google-apps-script google-sheets export-to-pdf
1
a workbook ID (SpreadsheetApp.getActive().getId()) and a sheet ID (aka grid ID,SpreadsheetApp.getActive().getSheetByName("some name").getSheetId()) are not the same thing. developers.google.com/sheets/api/guides/concepts#common_terms
– tehhowch
Mar 26 at 20:44
add a comment |
I am trying to generate an email with a PDF attachment of a specific sheet, not necessarily the active sheet. I have tried referencing the specific sheet name as well as the number, but to no avail, it chooses sheet 1, titled 'AMDashboard_English'. Please help.
function CreatePDF()
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("AMDashboard_English");
var sheet = ss.getSheetByName("AMDashboard_English");
Logger.log(sheet.getName());
var url = "https://docs.google.com/spreadsheets/d/SS_ID/export?".replace("SS_ID", sheet.getId());
var url_ext = 'exportFormat=pdf&format=pdf' // export as pdf / csv / xls /
var token = ScriptApp.getOAuthToken();
var sheets = ss.getSheets();
var blobs = [];
var i=0
var response = UrlFetchApp.fetch(
url + url_ext + sheets[i].getSheetId(),
headers: 'Authorization': 'Bearer ' + token
);
blobs[i] = response.getBlob().setName(sheets[i].getName() + '.pdf');
DriveApp.createFile(blobs[i]);
return blobs[i];
google-apps-script google-sheets export-to-pdf
I am trying to generate an email with a PDF attachment of a specific sheet, not necessarily the active sheet. I have tried referencing the specific sheet name as well as the number, but to no avail, it chooses sheet 1, titled 'AMDashboard_English'. Please help.
function CreatePDF()
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("AMDashboard_English");
var sheet = ss.getSheetByName("AMDashboard_English");
Logger.log(sheet.getName());
var url = "https://docs.google.com/spreadsheets/d/SS_ID/export?".replace("SS_ID", sheet.getId());
var url_ext = 'exportFormat=pdf&format=pdf' // export as pdf / csv / xls /
var token = ScriptApp.getOAuthToken();
var sheets = ss.getSheets();
var blobs = [];
var i=0
var response = UrlFetchApp.fetch(
url + url_ext + sheets[i].getSheetId(),
headers: 'Authorization': 'Bearer ' + token
);
blobs[i] = response.getBlob().setName(sheets[i].getName() + '.pdf');
DriveApp.createFile(blobs[i]);
return blobs[i];
google-apps-script google-sheets export-to-pdf
google-apps-script google-sheets export-to-pdf
edited Mar 26 at 20:45
tehhowch
6,6294 gold badges12 silver badges31 bronze badges
6,6294 gold badges12 silver badges31 bronze badges
asked Mar 26 at 15:45
Mitchell WaltzMitchell Waltz
1
1
1
a workbook ID (SpreadsheetApp.getActive().getId()) and a sheet ID (aka grid ID,SpreadsheetApp.getActive().getSheetByName("some name").getSheetId()) are not the same thing. developers.google.com/sheets/api/guides/concepts#common_terms
– tehhowch
Mar 26 at 20:44
add a comment |
1
a workbook ID (SpreadsheetApp.getActive().getId()) and a sheet ID (aka grid ID,SpreadsheetApp.getActive().getSheetByName("some name").getSheetId()) are not the same thing. developers.google.com/sheets/api/guides/concepts#common_terms
– tehhowch
Mar 26 at 20:44
1
1
a workbook ID (
SpreadsheetApp.getActive().getId()) and a sheet ID (aka grid ID, SpreadsheetApp.getActive().getSheetByName("some name").getSheetId()) are not the same thing. developers.google.com/sheets/api/guides/concepts#common_terms– tehhowch
Mar 26 at 20:44
a workbook ID (
SpreadsheetApp.getActive().getId()) and a sheet ID (aka grid ID, SpreadsheetApp.getActive().getSheetByName("some name").getSheetId()) are not the same thing. developers.google.com/sheets/api/guides/concepts#common_terms– tehhowch
Mar 26 at 20:44
add a comment |
2 Answers
2
active
oldest
votes
The url should be of the format below:
https://docs.google.com/spreadsheets/d/[SPREADSHEET_ID]/export?format=[PDF]&gid=[SHEET_ID]
add a comment |
I found that the code actually does work as planned. The reason it was not working is that I had another set of code referencing the same var's which apparently confused google scripts. All is well. Thank you.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55361199%2fselecting-a-specific-sheet-based-off-either-number-from-0-or-name%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The url should be of the format below:
https://docs.google.com/spreadsheets/d/[SPREADSHEET_ID]/export?format=[PDF]&gid=[SHEET_ID]
add a comment |
The url should be of the format below:
https://docs.google.com/spreadsheets/d/[SPREADSHEET_ID]/export?format=[PDF]&gid=[SHEET_ID]
add a comment |
The url should be of the format below:
https://docs.google.com/spreadsheets/d/[SPREADSHEET_ID]/export?format=[PDF]&gid=[SHEET_ID]
The url should be of the format below:
https://docs.google.com/spreadsheets/d/[SPREADSHEET_ID]/export?format=[PDF]&gid=[SHEET_ID]
answered Mar 26 at 17:14
TheMasterTheMaster
13.2k3 gold badges10 silver badges38 bronze badges
13.2k3 gold badges10 silver badges38 bronze badges
add a comment |
add a comment |
I found that the code actually does work as planned. The reason it was not working is that I had another set of code referencing the same var's which apparently confused google scripts. All is well. Thank you.
add a comment |
I found that the code actually does work as planned. The reason it was not working is that I had another set of code referencing the same var's which apparently confused google scripts. All is well. Thank you.
add a comment |
I found that the code actually does work as planned. The reason it was not working is that I had another set of code referencing the same var's which apparently confused google scripts. All is well. Thank you.
I found that the code actually does work as planned. The reason it was not working is that I had another set of code referencing the same var's which apparently confused google scripts. All is well. Thank you.
answered Mar 27 at 19:05
Mitchell WaltzMitchell Waltz
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55361199%2fselecting-a-specific-sheet-based-off-either-number-from-0-or-name%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
a workbook ID (
SpreadsheetApp.getActive().getId()) and a sheet ID (aka grid ID,SpreadsheetApp.getActive().getSheetByName("some name").getSheetId()) are not the same thing. developers.google.com/sheets/api/guides/concepts#common_terms– tehhowch
Mar 26 at 20:44