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?

  • Your advice fixed the issue perfectly, I greatly appreciate it. – STowslee Dec 21 '16 at 2:25
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, privacy policy and cookie policy

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