向此脚本添加什么以使其在主文件夹下的驱动器中创建客户文件夹?

问题描述

我编写了脚本来复制客户并制作他们自己的工作表。现在我还想让它在名为 Customer Files 的主文件夹下为每个客户在 google drive 中创建一个文件夹。你能帮我吗?

function clonesheetsIter() {
  var ss = SpreadsheetApp.getActiveSpreadsheet()
  var mainSheet = ss.getSheetByName("Customer_Entry");
  var startRow = 6;
  var numRows = mainSheet.getLastRow();//obtains the last row in the sheet
  var setrgh = mainSheet
  var datarange = mainSheet.getRange(startRow,1,numRows,15); //rowStart,columnStart,row count,column count,the columncount needs to be large enough to encompass all your ancillary data
  var data = datarange.getValues();
  var iter = 0;
  var c0d = "B2";
  
  if (numRows >= 180){var maxIter = 180;}else{var maxIter = numRows;} //Setting maxIter to numrows or a predefined value,whichever is smaller
 
  for (i in data){
    if (iter != maxIter){ //making sure we haven't gone over the iteration limit
      var row = data[i];
      if (row[0] != ""){ //making sure the first cell in that row of data isn't empty to ensure we stop at the end of data and dont make blank sheets
        var newName = (row[0]);
        var checkExist = ss.getSheetByName(newName); //if the proposed sheetname doesnt exist,returns null,or sometimes sheet
        if (!checkExist) { //skip if it exists already
          if (checkExist !="Sheet"){ //skip if called sheet
            var row = data[i];            
            var newSheet = ss.getSheetByName('Customer_Info_Template').copyTo(ss); //make a copy of the template sheet
            SpreadsheetApp.flush(); //its rude not to flush
            newSheet.setName(newName); //set the name of the copied sheet
            ss.setActiveSheet(newSheet);// then set it as active
            newSheet.getRange(c0d).setValue(row[0]).setNote(mainSheet.getRange(startRow+(iter),1).getNote());
            
            /*
            
            Two-line sample of range protection which may be done while the sheets are created iteratively
            Additional disparate cells may be protected by duplicating the second line,or groups of cells may be protected by specifying a range in A1 notation,ie ("G2:K6")
            
            var sheet = ss.getSheetByName(newName);
            sheet.getRange("G2").protect().setWarningOnly(true);
            */
          }
        }
      }
      iter+=1; //iteration ++ at the end of the for loop
    }
  }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)