2

I am attempting to export a spreadsheet which is "created" daily through an automated e-mail in Google Apps Script. When attempting to convert to PDF I only get the top row shown in the PDF document (none of the data).

var file = DriveApp.getFileById(spreadsheet.getId()).getAs(MimeType.PDF);

  MailApp.sendEmail('email', 'Equipment Update', 'Spreadsheet Attached', {
name: 'Testing',
attachments: [file]
  });

I have checked and the spreadsheet does have the appropriate list of information on the sheet which is to be exported.

Any ideas as to what might be causing this?

1
  • Your advice fixed the issue perfectly, I greatly appreciate it.
    – STowslee
    Dec 21, 2016 at 2:25

1 Answer 1

3

It appears you were trying to convert a spreadsheet to PDF immediately after it was filled with data. This is sometimes an issue because the data may be stuck in a pipeline: the changes are not immediately applied for performance reasons. Use the command

SpreadsheetApp.flush();

before conversion to PDF, to make sure any pending changes are applied. Reference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.