Home > Enterprise >  Trying to export to pdf using google app scripts
Trying to export to pdf using google app scripts

Time:10-29

I am currently trying to export a sheet as a pdf. This works fine using the getBlob() parameter, but I wish to export with a custom name of the file. When trying to use the following, the MimeType throws up an error message, and if removed the file is exported as plain text which I don't want. Any help would be great, either with exporting the file as a pdf or renaming it later

var sqc = ss.getSheetByName('SQC')
var folder = DriveApp.getFolderById('FOLDER ID')
  //var pdf = folder.createFile(ss.getBlob());
var pdf = folder.createFile('New Text File', ss.getBlob, MimeType.exportPDF)

CodePudding user response:

Based on my understanding you are trying to export your Google Sheet to a PDF file.

Here are some of my observations:

  • You are using an invalid enter image description here

    Test1

    enter image description here

    Test2

    enter image description here

    CodePudding user response:

    I was able to sort it out. Just chuck in

    pdf.setName = "Name"
    
  • Related