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

笑着哭i 提交于 2020-02-07 05:16:47

问题


i wrote here few hours ago about this code and here i am again, it's almost ready but i don't know why it's giving me back this error: Converting from application/vnd.google-apps.spreadsheet to application/vnd.openxmlformats-officedocument.spreadsheetml.sheet is not supported.

So, when MimeType is pdf it works fine, email is sent and i've got the file attached, but our supplier have to get .xlsx file... So i've tried excel_legacy, GOOGLE_SHEETS ( when using this it asks me for blob which is not defined.

function sendOrder() {
  var ui = SpreadsheetApp.getUi();
  var response = ui.alert('Are you sure you want to send the order?', ui.ButtonSet.YES_NO);
  var deliveryDate = ui.prompt('Delivery date:');

  // Process the user's response.
  if (response == ui.Button.YES) {
  // Message in email \/
  var a = 'message1';
  var b = 'message2';
  var c = 'message3';
  //Divided as the message includes date of delivery between sentences (it could be done way easier, but who cares, it works
  var d = deliveryDate.getResponseText(); 
  //ID of the delivery sheet
  var s = SpreadsheetApp.openById('1pON34oXVhlpC8goyBxfu6-Gw92tgQBUVUpskZUtgp4E');
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var message = [a + d + b + c + d]
  var file = DriveApp.getFilesByName('NAME');
  if (file.hasNext()) {
  var emailAddress = 'example@example.com';
  var subject = 'subject ' + deliveryDate.getResponseText();

  //Function sending emails with attached file
  MailApp.sendEmail(emailAddress, subject, message, {
  attachments: [file.next().getAs(MimeType.MICROSOFT_EXCEL)],
  })}

  SpreadsheetApp.getUi().alert('Yeah! Your order has been sent :)')}};

I'm sorry for putting in whole code, but i think it will help to understand a bit more. I believe i'm close, but i can't get it...

来源:https://stackoverflow.com/questions/57334386/converting-from-application-vnd-google-apps-spreadsheet-to-application-vnd-openx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!