Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

330
Views
Google Apps Script How to google spreadsheet to Excel (xlsx)

I would like to convert the Google Spread Sheet created using Google Apps Script into an Excel (xlsx) file and send it as an attachment through Gmail (MailApp).

I used the code below, but there is an error, so please check it.

Exception: Converting from application/vnd.google-apps.spreadsheet to application/vnd.openxmlformats-officedocument.spreadsheetml.sheet is not supported.

    //send email
    var emailTitle = noteSheet.getRange(2,2).getValue();
    var emailContent = noteSheet.getRange(3,2).getValue();
    var emailRecipient = noteSheet.getRange(4,2).getValue();
    var emailCarboncopy = noteSheet.getRange(5,2).getValue();

    var paymentfileName = paymentSheet.getRange(2,2).getValue();
    var paymentXlsx = DriveApp.getFilesByName(paymentfileName);
    if  (!paymentXlsx.hasNext()) {
      throw new Error("No paymentXlsx file.");
    }
    var paymentXlsx = paymentXlsx.next();

    MailApp.sendEmail(emailRecipient, emailTitle, emailContent, {
      name: 'name',
      cc: emailCarboncopy,
      attachments: [paymentXlsx.getAs(MimeType.MICROSOFT_EXCEL)]
    }); 
    }
almost 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!