Skip to content

Instantly share code, notes, and snippets.

@MSakamaki
Created June 14, 2019 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MSakamaki/795b4c947fb0fdfc8e41d320e6e5ddc1 to your computer and use it in GitHub Desktop.
Save MSakamaki/795b4c947fb0fdfc8e41d320e6e5ddc1 to your computer and use it in GitHub Desktop.
google app script example
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);
}
@MSakamaki
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment