更新最终工作表而不丢失数据 [英] Updating final sheet without losing data
问题描述
我在同一张电子表格中有几张纸,有数据的纸张可以方便我的工作,当我执行生成需要的纸张的脚本时,我的问题是当我添加更多数据时,是否有任何解决方案来更新最终纸张而不会丢失我之前写的内容。
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;
}
}
推荐答案
我的猜测会删除这些清理行应该做的。
My guess would be that removing these cleanup lines should do the trick.
currentMonthSheet.clear();
currentMonthSheet.clearFormats();
try{
currentMonthSheet.deleteColumns(2, cols - nbDays );
}catch(e){
//Logger.log("erreur : " + e);
}
try{
currentMonthSheet.deleteRows(2, rows - 3);
}catch(e){
//Logger.log("erreur : " + e);
}
这篇关于更新最终工作表而不丢失数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!