回答編集履歴
1
こめんとでもつけてみるか
test
CHANGED
@@ -34,21 +34,21 @@
|
|
34
34
|
|
35
35
|
const copyList = curSpreadsheet.getSheetByName("Bシート").getDataRange().getValues();
|
36
36
|
|
37
|
-
copyList.shift();
|
37
|
+
copyList.shift(); //ヘッダ行を捨てる
|
38
38
|
|
39
|
-
copyList.forEach(function(element, index, array){
|
39
|
+
copyList.forEach(function(element, index, array){ //forEachでループ。elementが1行分
|
40
40
|
|
41
|
-
const fileName = element[0];
|
41
|
+
const fileName = element[0]; // A列にファイル名
|
42
42
|
|
43
43
|
const file = SpreadsheetApp.create(fileName);
|
44
44
|
|
45
|
-
const users = element.slice(1).filter(String);
|
45
|
+
const users = element.slice(1).filter(String); // B列以降で文字になるやつだけフィルタ
|
46
46
|
|
47
47
|
file.addEditors(users);
|
48
48
|
|
49
|
-
const copied = templateSheet.copyTo(file);
|
49
|
+
const copied = templateSheet.copyTo(file); //copyToすると、コピーしたシートが返り値になる
|
50
50
|
|
51
|
-
copied.setName("Aシート");
|
51
|
+
copied.setName("Aシート"); //デフォルトで「Aシートのコピー」とかになるのでリネーム
|
52
52
|
|
53
53
|
trimSheet(file, "Aシート");
|
54
54
|
|
@@ -58,7 +58,7 @@
|
|
58
58
|
|
59
59
|
|
60
60
|
|
61
|
-
function trimSheet(spreadsheet, name) {
|
61
|
+
function trimSheet(spreadsheet, name) { //スプレッドシートを作ると「シート1」ができちゃうので、指定した名前(name)を持たないシートを消すやつ
|
62
62
|
|
63
63
|
spreadsheet.getSheets().filter(function(sheet){ return sheet.getName().indexOf(name) === -1}).forEach(function(sheet){spreadsheet.deleteSheet(sheet);});
|
64
64
|
|