Created
June 14, 2019 13:58
-
-
Save MSakamaki/795b4c947fb0fdfc8e41d320e6e5ddc1 to your computer and use it in GitHub Desktop.
google app script example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function columnStart() { | |
return 3; | |
} | |
function replaceHyperlink(str){ | |
var splitStr = str.split('\"');; | |
return { | |
url: splitStr[1], | |
name: splitStr[3], | |
}; | |
} | |
function sheetArrayTemplate(count) { | |
var ary = []; | |
for (var index = columnStart(); index <= count; index++) { | |
ary.push(index); | |
} | |
return ary; | |
} | |
function getData(sheetName) { | |
const sheet = SpreadsheetApp.getActive().getSheetByName(sheetName); | |
const range = sheet.getDataRange(); | |
return sheetArrayTemplate(range.getLastRow()).map(function(index){ | |
const cell = sheet.getRange('A' + index); | |
return { | |
name: cell.getValue(), | |
link: replaceHyperlink(cell.getFormula()) | |
}; | |
}); | |
} | |
function doGet(e) { | |
// https://xxxxxx/exec?year=2019 | |
// var year = e.parameter.year | ''; | |
var data = getData('Contributers'); | |
return ContentService.createTextOutput(JSON.stringify(data)) | |
.setMimeType(ContentService.MimeType.JSON); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dashboard url:
https://script.google.com/home