I have a short code snippet that should convert an Excel file to Google Sheet via App Script on Google Drive.
That uses DriveApp service and inserts a new file with mimeType : MimeType.GOOGLE_SHEETS
function convertExcelFileToGoogleSheets(fileId){
let excelFile = DriveApp.getFileById(fileId);
if(excelFile == null) return -1;
if(excelFile.getMimeType == MimeType.Google_Sheets) return fileId;
let blob = excelFile.getBlob();
let config = {
title : "[Google Sheets]" + excelFile.getName(),
parents : [{id: excelFile.getParents().next().getId()}],
mimeType : MimeType.GOOGLE_SHEETS
};
let spreadSheet = Drive.Files.insert(config, blob);
return spreadSheet.id;
}
But it converts to a new file with Google Docs instead of expected Google Sheet
Here is the Google Enum MimeType of AppScript Documentation.