I'm new/not familiar with app scripting language. I need a script (or part off) that converts a named Excel file to Spreadsheet format in a specific Drive folder. I found a code that does the converting part but every time when I execute the script it generates a new Spreadsheet. What I need is a code/script that does the same but overwrites the 'main' Spreadsheet which is shared and used for Data Studio as data source.
Hope you Experts have a solution to do this. Below the code I use for the converting part.
function convertExceltoGoogleSpreadsheet2(fileName) {
try {
fileName = fileName || "test_ds.xlsx";
var excelFile = DriveApp.getFilesByName(fileName).next();
var fileId = excelFile.getId();
var folderId = Drive.Files.get(fileId).parents[0].id;
var blob = excelFile.getBlob();
var resource = {
title: excelFile.getName().replace(/.xlsx?/, ""),
key: fileId
};
Drive.Files.insert(resource, blob, {
convert: true
});
} catch (f) {
Logger.log(f.toString());
}
}