Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save oshliaer/eb58a263fc20c3569c1f618fb47cccb9 to your computer and use it in GitHub Desktop.
Save oshliaer/eb58a263fc20c3569c1f618fb47cccb9 to your computer and use it in GitHub Desktop.
function duplicate1() {
var ss = SpreadsheetApp.getActive();
var roster = ss.getSheetByName('Roster');
var form = ss.getSheetByName("Rubric Template");
var values = roster.getRange('A2:B').getValues();
values.map(mapping)
.forEach(generateSheet.bind({}, ss, form));
}
function generateSheet(spreadsheet, template, data){
if(!data.name || !data.username)
return undefined;
var sheet = spreadsheet.getSheetByName(data.name) || template.copyTo(spreadsheet).setName(data.name);
sheet.getRange('B1').setValue(data.username);
}
function mapping(roster){
return {
name: roster[1],
username: roster[0]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment