Google App Script Tutorial
Google App Script Tutorial
Google App Script Tutorial
function myFunction()
{
var ss=SpreadsheetApp.getActiveSpreadsheet();
var sheet=ss.getActiveSheet();
var range=sheet.getRange('A1');
range.setValue('Hello')
}
var ss=SpreadsheetApp.getActiveSpreadsheet();
var sheet=ss.getActiveSheet();
var range=sheet.getDataRange();
var values = range.getValues();
var ss=SpreadsheetApp.getActiveSpreadsheet();
var sheet=ss.getActiveSheet();
var range=sheet.getDataRange();
var values = range.getValues();
var email=values[1][0];
var subject= values[1][2];
var body=values[1][3];
var ss=SpreadsheetApp.getActiveSpreadsheet();
var sheet=ss.getActiveSheet();
var range=sheet.getDataRange();
var values = range.getValues();
for(i=1;i<values.length;i++)
{
var email=values[i][0];
var subject= values[i][2];
var body=values[i][3];
var ss=SpreadsheetApp.getActiveSpreadsheet();
var sheet=ss.getActiveSheet();
var range=sheet.getDataRange();
var values = range.getValues();
var email=values[1][0];
var subject= values[1][2];
var ss=SpreadsheetApp.getActiveSpreadsheet();
var sheet=ss.getActiveSheet();
var range=sheet.getDataRange();
var values = range.getValues();
for(i=1;i<values.length;i++)
{
var email=values[i][0];
var subject= values[i][2];
var body=sheet.getRange('A1);
}
function runDemo() {
try {
} catch(error) {
Browser.msgBox(error.message);
}
}
function getFirstProfile() {
var accounts = Analytics.Management.Accounts.list();
if (accounts.getItems()) {
var firstAccountId = accounts.getItems()[0].getId();
if (profiles.getItems()) {
var firstProfile = profiles.getItems()[0];
return firstProfile;
} else {
throw new Error('No views (profiles) found.');
}
} else {
throw new Error('No webproperties found.');
}
}
Browser.msgBox(firstProfile) ;
/*
else {
throw new Error('No accounts found.');
}
*/
}
function getReportDataForProfile(firstProfile) {
// Today.
var optArgs = {
'dimensions': 'ga:keyword',
'sort': '-ga:sessions,ga:keyword',
'start-index': '1',
'max-results': '250'
};
startDate,
endDate,
if (results.getRows()) {
return results;
} else {
throw new Error('No views (profiles) found');
}
}
function getLastNdays(nDaysAgo) {
var today = new Date();
var before = new Date();
before.setDate(today.getDate() - nDaysAgo);
return Utilities.formatDate(before, 'GMT', 'yyyy-MM-dd');
}
function outputToSpreadsheet(results) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().insertSheet();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var cell = ss.getRange('A2');
cell.offset(row, i).setValue(result.getString(i+1));
}
row++;
}
result.close();
SQLstatement.close();
connection.close();
}
Clear the contents of the spreadsheet
function runDemo() {
var ss=SpreadsheetApp.getActiveSpreadsheet();
var x=ss.getActiveSheet();
x.clearContents();