Skip to content

Instantly share code, notes, and snippets.

@MSakamaki
Created June 14, 2019 13:58
Show Gist options
  • Select an option

  • Save MSakamaki/795b4c947fb0fdfc8e41d320e6e5ddc1 to your computer and use it in GitHub Desktop.

Select an option

Save MSakamaki/795b4c947fb0fdfc8e41d320e6e5ddc1 to your computer and use it in GitHub Desktop.

Revisions

  1. MSakamaki created this gist Jun 14, 2019.
    40 changes: 40 additions & 0 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    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);
    }