admin管理员组

文章数量:1123272

const fileTitle = ss.getRange(i, 2).getValue(); // test1; test2

var blob = Utilities.newBlob(htmlBody, 'text/html').getAs('application/pdf').setName({fileTitle}&'.pdf');
DriveApp.createFile(blob);

I do not know why I get 0 as file name instead of test1 test2 - when I check Logger.log of the fileTitle - I get the correct name - test1, test2

const fileTitle = ss.getRange(i, 2).getValue(); // test1; test2

var blob = Utilities.newBlob(htmlBody, 'text/html').getAs('application/pdf').setName({fileTitle}&'.pdf');
DriveApp.createFile(blob);

I do not know why I get 0 as file name instead of test1 test2 - when I check Logger.log of the fileTitle - I get the correct name - test1, test2

Share edited 11 hours ago Agnieszka Liszka asked 11 hours ago Agnieszka LiszkaAgnieszka Liszka 34 bronze badges 4
  • 1 Please make a minimal reproducible example that can be copy/paste/run without changes to illustrate the issue. Example: htmlBody, what is your htmlBody? – Jats PPG Commented 11 hours ago
  • htmlBody is irrelevant as the file is being saved with the content from htmlBody - but the file name is 0.pdf instead of test1.pdf – Agnieszka Liszka Commented 11 hours ago
  • 1 It is actually relevant because it will make it easier for us to replicate your issue (most users ignore this kind of incomplete posts). It seems that this code snippet is placed within a for loop due to the i variable. You might as well add that as well as the definition of your ss variable as the error might be there. Please read this article to know more about the reason why it is required for you to clearly define your code snippet. – PatrickdC Commented 11 hours ago
  • I have just resolved the issue setName(fileTitle) - works – Agnieszka Liszka Commented 11 hours ago
Add a comment  | 

1 Answer 1

Reset to default -1

the following solution works: setName(fileTitle) works

本文标签: How to set a pdf file namename taken from the spreadsheet cell apps scriptStack Overflow