hi, i want to update my data base(google sheet) with dowload a file csv direcly on my application.before i try with integromat but know i don t remenber.
Hey, we used app script for that. And it works perfectly. We just upload xlsx file to our app, then in a minute all database is updated. If you want the script, just reply.
hi, thanks you yes i want the script thanks
Hi, Theo,
function onCellValueChange(e) {
var range = e.range;
var sheet = range.getSheet();
var row = range.getRow();
var column = range.getColumn();
if (sheet.getName() === “Sheet1” && row === 2 && column === 1) {
updateGoogleSheetFromExcel();
}
}
function updateGoogleSheetFromExcel() {
// Get the URL of the Excel file from a cell in Google Sheets
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var excelFileURL = sheet.getRange(“A2”).getValue(); // Update the cell reference as per your requirement
// Fetch the Excel file
var fileBlob = UrlFetchApp.fetch(excelFileURL).getBlob();
// Convert the Excel file to a temporary Google Sheets file
var tempFile = Drive.Files.insert(
{ title: “TempFile”, mimeType: “application/vnd.google-apps.spreadsheet” },
fileBlob
);
var tempFileId = tempFile.id;
var tempSpreadsheet = SpreadsheetApp.openById(tempFileId);
// Clear the existing data in the destination Google Sheet
var destinationSheet = SpreadsheetApp.openById(“1oBvxb6cFoeJX5AY5Ack57GUY3nUFlwYstNayiR3Js3f”).getActiveSheet();
destinationSheet.clearContents(); // Clears all the data
// Get the data from the temporary Google Sheets file
var tempSheet = tempSpreadsheet.getSheets()[0];
var sheetData = tempSheet.getDataRange().getValues();
// Write the parsed data to the destination Google Sheet
var numRows = sheetData.length;
var numCols = sheetData[0].length;
destinationSheet.getRange(1, 1, numRows, numCols).setValues(sheetData);
// Delete the temporary Google Sheets file
Drive.Files.remove(tempFileId);
}
пн, 25 сент. 2023 г. в 18:02, theo 180280 via Glide Community <notifications@glideapps.discoursemail.com>: