google 的重复脚本
Duplicate script for google
完成!!!
非常感谢 Ilya Lapitan 和我的朋友 Zent。你救我 :)
要执行的脚本:
- 模板重复 sheet;
重命名新的 sheet,如:"Number" + "name from base sheet"(它的 "All_base",列表在哪里的名字)
function makeCopies() {
///getting active spreadsheet
var activeSreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var basicSheet = activeSreadsheet.getSheetByName("All_base");
var activeSreadsheet2 = SpreadsheetApp.getActiveSpreadsheet();
var templateSheet = activeSreadsheet2.getSheetByName("1. Win");
//setting template sheet as active
activeSreadsheet2.setActiveSheet(templateSheet);
//getting values from selected range
var rangeArr = basicSheet.getRange("B4:B6").getValues();
//going through range values
for(i = 0; i < rangeArr.length; i++){
//preparing name for new sheet
var name = (i + 2) + '. ' + rangeArr[i][0];
//making duplicate of base sheet
var newSheet = SpreadsheetApp.getActiveSpreadsheet().duplicateActiveSheet();
//setting new name for duplicated sheet
newSheet.setName(name)
}
};
这是一个根据选定范围复制基数 sheet 的解决方案:
function onOpen() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "Make Copies",
functionName : "makeCopies"
}];
spreadsheet.addMenu("Duplicate", entries);
};
function makeCopies() {
//getting active spreadsheet
var activeSreadsheet = SpreadsheetApp.getActiveSpreadsheet();
//getting basic sheet
var basicSheet = activeSreadsheet.getSheetByName("All_base");
//setting basic sheet as active
activeSreadsheet.setActiveSheet(basicSheet);
//getting values from selected range
var range = basicSheet.getRange("D7").getValue().split(", ");
//going through range values
for(i = 0; i < range.length; i++){
//preparing name for new sheet
var name = (i + 1) + '.' + range[i];
//making duplicate of base sheet
var newSheet = SpreadsheetApp.getActiveSpreadsheet().duplicateActiveSheet();
//setting new name for duplicated sheet
newSheet.setName(name)
}
};
使用示例:
- Select 基数 sheet
的范围
- Select 一个菜单项:"Duplicate" -> "Make Copies"
完成!!! 非常感谢 Ilya Lapitan 和我的朋友 Zent。你救我 :) 要执行的脚本:
- 模板重复 sheet;
重命名新的 sheet,如:"Number" + "name from base sheet"(它的 "All_base",列表在哪里的名字)
function makeCopies() { ///getting active spreadsheet var activeSreadsheet = SpreadsheetApp.getActiveSpreadsheet(); var basicSheet = activeSreadsheet.getSheetByName("All_base"); var activeSreadsheet2 = SpreadsheetApp.getActiveSpreadsheet(); var templateSheet = activeSreadsheet2.getSheetByName("1. Win"); //setting template sheet as active activeSreadsheet2.setActiveSheet(templateSheet); //getting values from selected range var rangeArr = basicSheet.getRange("B4:B6").getValues(); //going through range values for(i = 0; i < rangeArr.length; i++){ //preparing name for new sheet var name = (i + 2) + '. ' + rangeArr[i][0]; //making duplicate of base sheet var newSheet = SpreadsheetApp.getActiveSpreadsheet().duplicateActiveSheet(); //setting new name for duplicated sheet newSheet.setName(name) } };
这是一个根据选定范围复制基数 sheet 的解决方案:
function onOpen() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "Make Copies",
functionName : "makeCopies"
}];
spreadsheet.addMenu("Duplicate", entries);
};
function makeCopies() {
//getting active spreadsheet
var activeSreadsheet = SpreadsheetApp.getActiveSpreadsheet();
//getting basic sheet
var basicSheet = activeSreadsheet.getSheetByName("All_base");
//setting basic sheet as active
activeSreadsheet.setActiveSheet(basicSheet);
//getting values from selected range
var range = basicSheet.getRange("D7").getValue().split(", ");
//going through range values
for(i = 0; i < range.length; i++){
//preparing name for new sheet
var name = (i + 1) + '.' + range[i];
//making duplicate of base sheet
var newSheet = SpreadsheetApp.getActiveSpreadsheet().duplicateActiveSheet();
//setting new name for duplicated sheet
newSheet.setName(name)
}
};
使用示例:
- Select 基数 sheet 的范围
- Select 一个菜单项:"Duplicate" -> "Make Copies"