Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

333
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda