I am beginner in Google script ,So apologies if i asked any silly things I need to import the Excel file (which i received in gmail) in to existing Google sheet. The below code will do the same thing which i req But the Below code import the CSV only , Can any one help me to modify this so that the code will import the Excel file .
function importCSVFromGmail() {
var threads = GmailApp.search("from:reports@example.com");var message = threads[0].getMessages()[0];
var attachment = message.getAttachments()[0];
if (attachment.getContentType() === "text/csv") {
var sheet = SpreadsheetApp.getActiveSheet();
var csvData = Utilities.parseCsv(attachment.getDataAsString(), ",");
sheet.clearContents().clearFormats();
sheet.getRange(1, 1,csvData.length,csvData[0].length).setValues(csvData);
}
}