I have several sheets in the same spreadsheet, sheets with data to facilitate my job when i do my script that generates sheets that i need, and my problem is when i add more data, is there any solution to update the final sheet without losing what I wrote before .
My exemple : Every user I add the sheet of data, if I execute the function it'll add a timesheet with its name in final sheet, and I don't know how to keep the data i added in the timesheets of users because, as you know, the execution of the function will crush it and generate a new timesheet for all the users
Here is the code of the function that generates the timesheets:
function generateTimeSheet(){
Logger.clear();
var semaine=1;
var projectSheet = ss.getSheetByName("Liste Projets");
var usersSheet = ss.getSheetByName("Utilisateurs");
var tabProjectsLibs = getProjectList();
//Récupération de la liste des utilisateurs
var tabUsers = getUsersList();
//Suppression des colonnes vides
for(i = 1; i < 13; i++){
//Nombre de jours du mois
var date = new Date(i + "/01/" + year);
var nbDays = getNbJours(date);
//Nettoyage de la feuille
var currentMonthSheet = getSheetByMonth(tabMonth[i - 1]);
var rows = currentMonthSheet.getMaxRows();
var cols = currentMonthSheet.getMaxColumns();
var currentMonthRange = currentMonthSheet.getRange(rows, cols);
currentMonthSheet.clear();
currentMonthSheet.clearFormats();
//Suppression des lignes et colonnes inutiles
try{
currentMonthSheet.deleteColumns(2, cols - nbDays );
}catch(e){
//Logger.log("erreur : " + e);
}
try{
currentMonthSheet.deleteRows(2, rows - 3);
}catch(e){
//Logger.log("erreur : " + e);
}
var numProjects = getProjectNumber();
var prjLines = 2;
//Ajout des utilisateurs
//Ajout des entêtes et des tableaux par user
for(l = 0; l < tabUsers.length; l++){
var firstLine = 1 + (l+1)*10 - 10 + (l + 1) * numProjects - numProjects;
var nbTours = generateUserTimeSheet(tabUsers[l], firstLine, currentMonthSheet, nbDays, semaine);
prjLines = 2;
//Ajout des projets par user
for(m = 0; m < numProjects; m++){
addProject(tabProjectsLibs[m], firstLine + 5 + m, currentMonthSheet, prjLines, numProjects);
prjLines++;
}
}
semaine += nbTours;
}
}