Google Sheets

Append rows to a spreadsheet
Set a range's values
Log the data of a spreadsheet
Clear a sheets values
Report data to a spreadsheet

Append rows to a spreadsheet


function appendRowsToSpreadsheet(){
  const spreadsheetId = 'Spreadsheet ID';
  const ss = SpreadsheetApp.openById(spreadsheetId);
  const sheetName = 'test';
  let sh = ss.getSheetByName(sheetName);
  sh.appendRow(['Armadillo', 'Bear', 'Cat']);
}

Set a range's values


function setRangeValues(){
  const spreadsheetId = 'Spreadsheet ID';
  const ss = SpreadsheetApp.openById(spreadsheetId);
  const sheetName = 'test1';
  let sh = ss.getSheetByName(sheetName);
  const dataArray = [
    ['America','Brazil','Canada','Denmark'],
    ['Apple','Banana','Cherry','Daikon'],
  ];
  sh.getRange('A1').setValues(dataArray);
}

Log the data of a spreadsheet


function logDataOfSpreadsheet(){
  const spreadsheetId = 'Spreadsheet ID';
  const ss = SpreadsheetApp.openById(spreadsheetId);
  const sheetName = 'test1';
  let sh = ss.getSheetByName(sheetName);
  let dataArray = sh.getDataRange().getValues();
  for (let i = 0; i < dataArray.length; i++){
    Logger.log(dataArray[i].join(', '));   
  }
}

Clear a sheets values


function clearSheetsValues(){
  const spreadsheetId = 'Spreadsheet ID';
  const ss = SpreadsheetApp.openById(spreadsheetId);
  const sheetName = 'test1';
  let sh = ss.getSheetByName(sheetName);
  sh.getRange('A1:C2').clear();
}

Report data to a spreadsheet


function reportDataToSpreadsheet(){
  const spreadsheetId = 'Spreadsheet ID';
  const ss = SpreadsheetApp.openById(spreadsheetId);
  const sheetName = 'test1';
  let sh = ss.getSheetByName(sheetName);
  const reports = AdsUtilities.getSearchReport({
    accountId: AdsUtilities.getCurrentAccountId(),
    fields: [
      'ACCOUNT_ID','IMPS','CLICKS','COST'
    ],
    reportDateRangeType: 'THIS_MONTH',
    reportType: 'ACCOUNT',
  });
  sh.getRange('A1').setValues(reports.reports[0].rows);
}