1D Array to fill a spreadsheet column

前端 未结 2 1175
甜味超标
甜味超标 2021-01-07 15:31

I\'m using the built-in group service to pull a list of usernames...

function getUsersInGroup(group) {
  var usersInGroup = GroupsApp.getGroupByEmail(group).         


        
2条回答
  •  北荒
    北荒 (楼主)
    2021-01-07 15:51

    You can also use the sheets API, If you don't want to loop through.

    Use Advanced Google services and switching majorDimension as columns:

      var data = [ 'person1@email.com', 'person2@email.com', 'person3@email.com' ];
      var request = {
        range: 'Sheet1!A1',
        majorDimension: 'COLUMNS',
        values: [data], //still 2D
      };
      //API must be enabled before use. 
      //https://developers.google.com/apps-script/advanced/sheets
      Sheets.Spreadsheets.Values.update(request, ss.getId(), request.range, {
        valueInputOption: 'USER_ENTERED',
      });
    

    Or loop through:

    data = data.map(function(e){return [e];});
    

提交回复
热议问题