SlideShare a Scribd company logo
Google: Drive, Documents
and Apps Script
GDG DevFest Pisa 2019
How to work efficiently and happily
whoami?
Alessandra Santi
email: santi.info@gmail.com
● Chartered Accountant and Auditor
● Linux User
Table of Contents
● Google Drive
● Google Documents
● Sharing documents
● Google Apps Script
● Automate jobs
Drive
Table of Contents
● Google Drive
● Google Documents
● Sharing documents
● Google Apps Script
● Automate jobs
Docs, sheets, forms, slides
Table of Contents
● Google Drive
● Google Documents
● Sharing documents
● Google Apps Script
● Automate jobs
Apps Script
where?Drive
where?
● App Google
● Drive
what is it?
Drive
container where:
- to save,
- to organize,
- to manipulate,
- to share
files
container where to save, organize, manipulate and share files
container where to save, organize, manipulate and share files
container where to save, organize, manipulate and share files
zoom
Right click
container where to save, organize, manipulate and share files
container where to save, organize, manipulate and share files
container where to save, organize, manipulate and share files
container where to save, organize, manipulate and share files
container where to save, organize, manipulate and share files
container where to save, organize, manipulate and share files
Working with documents
● Docs
● Sheets
● Slides
● Forms
● ….
Word processor and Spreadsheet
Spreadsheet functions
download in different formats
Forms → like a Mask → to record data
Slides → These slides with Slides :)
Setting
With or WithOut Net
Open files offline
To turn on offline access:
● You must be connected to the internet.
● Use the Google Chrome browser.
● Don't use private browsing.
● Install and enable Google Docs offline Chrome extension.
● Make sure you have enough free space on your device.
Open Google Docs, Sheets, and Slides offline
1. Open Chrome. Make sure you're signed in to Chrome.
2. Go to drive.google.com/drive/settings.
3. Check the box next to Sync Google Docs, Sheets ... files
https://support.google.com/drive/answer/2375012?co=GENIE.Platform%3DDesktop&hl=en
Apps Script
Automate jobs
Apps script
How to install
Apps script
Script
Bound
Script
Standalone
Apps Script
Apps Script Where to learn!
https://developers.google.com/apps-script/
Apps Script Documentation
https://developers.google.com/apps-script/
Apps Script A lot of documentation!
https://developers.google.com/apps-script/
Apps Script A lot of documentation!
Beginners: Ohhhh!!!!
Title: Skrik - Author: Edvard Munch
Apps Script
Don’t worry! No Panic!
● https://developers.google.com/apps-script/overview
● https://developers.google.com/apps-script/articles/
Scripts run on Google’s Servers
Nothing to install
Help: Guides, Tutorials...
Language: JavaScript
Apps Script
“You see, but you do not observe.
The distinction is clear.”
Sherlock Holmes Quote
scripts
Apps Script Observe code
https://codelabs.developers.google.com/codelabs/apps-script-intro/#4
function sendMap() {
var sheet = SpreadsheetApp.getActiveSheet();
var address = sheet.getRange('A1').getValue();
var map = Maps.newStaticMap().addMarker(address);
GmailApp.sendEmail('friend@example.com',
'Map',
'See below.',
{attachments:[map]})
}
function declaration
class method
Apps Script Observe code
Manipulating sheets: Formatting Cells
● Add headers
● Customize background cells (color, fonts …)
● Adjust columns size
● ….
Sheet: new style :)
Apps Script Observe code
Bounds
Script
Special Methods:
● getActiveSpreadsheet()
● getActiveSheet()
● getActiveRange()
● getActiveCell()
● setActiveSheet(sheet)
● setActiveRange(range)
https://developers.google.com/apps-script/guides/bound
Allow bound scripts to refer
to their parent file without
referring to the file's ID
Let the script determine the user's
current Sheet, selected Range of
cells, or selected individual Cell
Let the script change
getActive* selections
function formatStyle() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
//var sheet = ss.getSheetByName( 'Sheet1' );
var range1 = sheet.getRange( 'A1:C1' );
var range2 = sheet.getRange(2, 1, 1, 3); //(row, column, numRows, numColumns)
range1.mergeAcross()
.setBackground( 'green' )
.setValue( 'report' )
.setFontSize(12);
range2.setBackground( '#3bf59b' )
.setValues( [['Name', 'LastName', 'Value']] )
.setFontSize(10);
sheet.getRange(1, 1, 2, 3)
.setBorder(true, true, true, true, true, true) /(top, left, bottom, right, vertical, horizontal)
.setHorizontalAlignment( ['left', 'left', 'right'] )
.setVerticalAlignment( 'bottom' )
.setFontWeight( 'bold' );
var columnWidth = [150, 150, 80];
for ( var i = 0; i < columnWidth.length; i++ ) {
sheet.setColumnWidth(i+1,columnWidth[i]);
}
sheet.setFrozenRows(2);
SpreadsheetApp.flush();
}
Observe code
run =
video1
function formatStyle() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
//var sheet = ss.getSheetByName( 'Sheet1' );
var range1 = sheet.getRange( 'A1:C1' );
var range2 = sheet.getRange(2, 1, 1, 3); //(row, column, numRows, numColumns)
range1.mergeAcross()
.setBackground( 'green' )
.setValue( 'report' )
.setFontSize(12);
range2.setBackground( '#3bf59b' )
.setValues( [['Name', 'LastName', 'Value']] )
.setFontSize(10);
sheet.getRange(1, 1, 2, 3)
.setBorder(true, true, true, true, true, true) /(top, left, bottom, right, vertical, horizontal)
.setHorizontalAlignment( ['left', 'left', 'right'] )
.setVerticalAlignment( 'bottom' )
.setFontWeight( 'bold' );
var columnWidth = [150, 150, 80];
for ( var i = 0; i < columnWidth.length; i++ ) {
sheet.setColumnWidth(i+1,columnWidth[i]);
}
sheet.setFrozenRows(2);
SpreadsheetApp.flush();
}
Observe code
function formatStyle() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
//var sheet = ss.getSheetByName( 'Sheet1' );
var range1 = sheet.getRange( 'A1:C1' );
var range2 = sheet.getRange(2, 1, 1, 3); //(row, column, numRows, numColumns)
range1.mergeAcross()
.setBackground( 'green' )
.setValue( 'report' )
.setFontSize(12);
range2.setBackground( '#3bf59b' )
.setValues( [['Name', 'LastName', 'Value']] )
.setFontSize(10);
sheet.getRange(1, 1, 2, 3)
.setBorder(true, true, true, true, true, true) /(top, left, bottom, right, vertical, horizontal)
.setHorizontalAlignment( ['left', 'left', 'right'] )
.setVerticalAlignment( 'bottom' )
.setFontWeight( 'bold' );
var columnWidth = [150, 150, 80];
for ( var i = 0; i < columnWidth.length; i++ ) {
sheet.setColumnWidth(i+1,columnWidth[i]);
}
sheet.setFrozenRows(2);
SpreadsheetApp.flush();
}
Observe code
count from 0 (0, 1, 2)
count from 0 (0, 1, 2)
function onOpen(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
//var sheet = ss.getSheetByName( 'Sheet1' );
var range1 = sheet.getRange( 'A1:C1' );
var range2 = sheet.getRange(2, 1, 1, 3); //(row, column, numRows, numColumns)
range1.mergeAcross()
.setBackground( 'green' )
.setValue( 'report' )
.setFontSize(12);
range2.setBackground( '#3bf59b' )
.setValues( [['Name', 'LastName', 'Value']] )
.setFontSize(10);
sheet.getRange(1, 1, 2, 3)
.setBorder(true, true, true, true, true, true) /(top, left, bottom, right, vertical, horizontal)
.setHorizontalAlignment( ['left', 'left', 'right'] )
.setVerticalAlignment( 'bottom' )
.setFontWeight( 'bold' );
var columnWidth = [150, 150, 80];
for ( var i = 0; i < columnWidth.length; i++ ) {
sheet.setColumnWidth(i+1,columnWidth[i]);
}
sheet.setFrozenRows(2);
SpreadsheetApp.flush();
}
Observe code
Trigger
onOpen()
open file
Apps Script Observe code
● Add data
● Create and apply formulas
● Create charts
● Apply SQL queries
● ...
Customize your
work tools :)
Observe code/**
* A custom function that calculate tot price.
*
* @param {values} range of two cells
* @return {tot_price} Un_Price * Q_ty
*/
function TOTPRICE(values) {
var tot_pr = 1;
for ( var i = 0; i < values[0].length; i++) {
tot_pr *= values[0][i]; //tot_pr = tot_pr * values[0][i];
}
return tot_pr;
}
Custom function
Create a function with formula
video2
Observe code/**
* A custom function that calculate tot price.
*
* @param {values} range of two cells
* @return {tot_price} Un_Price * Q_ty
*/
function TOTPRICE(values) {
var tot_pr = 1;
for ( var i = 0; i < values[0].length; i++) {
tot_pr *= values[0][i]; //tot_pr = tot_pr * values[0][i];
}
return tot_pr;
}
Custom function
Create a function with formula
Observe codefunction addChart() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var range1 = sheet.getRange("A1:B6")
var chart = sheet.newChart()
.setChartType(Charts.ChartType.LINE)
.addRange(range1)
.setPosition(1, 4, 0, 0) //(anchorRowPos,anchorColPos,offsetX, offsetY)
.build();
sheet.insertChart(chart);
}
Embedded a Chart
video3
Observe codefunction addChart() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var range1 = sheet.getRange("A1:B6")
var chart = sheet.newChart()
.setChartType(Charts.ChartType.LINE)
.addRange(range1)
.setPosition(1, 4, 0, 0) //(anchorRowPos,anchorColPos,offsetX, offsetY)
.build();
sheet.insertChart(chart);
}
Embedded a Chart
Observe code
function addProfit() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getActiveSheet();
var range = sh.getRange(2, 3, 20, 2).getValues();
var profits = range.map( function(row) { return [ row[0] - row[1] ]; } );
sh.getRange(2, 5, profits.length, profits[0].length).setValues(profits);
sh.getRange(1, 5).setValue("profits").setFontWeight('bold');
}
.map
Populate a Range of Values
https://www.youtube.com/watch?v=985XJOeigpA
Observe code
function PROFIT(sales, cogs) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getActiveSheet();
var profit = sales - cogs;
return profit;
}
method .map
Observe codefunction addProfit() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getActiveSheet();
var range = sh.getRange(2, 3, 20, 2).getValues();
var profits = range.map( function(row) {
return [ row[0] - row[1] ];
}
);
sh.getRange(2, 5, profits.length, profits[0].length).setValues(profits);
sh.getRange(1, 5).setValue("profits").setFontWeight('bold');
}
.map
video4
Apps Script
attention … please! other considerations
Apps Script
Tutorial:
https://codelabs.developers.google.com/codelabs/apps-script-intro/#5
Run Authorization
Required
attention … please!
Apps Script
Alt +
space
Auto-complete
code
attention … please!
Drive: Ocr text in Docs
attention … please!
video5
End
Thank you for your attention!
GDG DevFest Pisa 2019 - 13/04/2019 - Alessandra Santi - licence: CC BY-NC-SA

More Related Content

What's hot (20)

PDF
Politics News and U.S. Elections Coverage
creepypreview6376
 
PDF
Technology and Science News - ABC News
ignorantlogic4950
 
PDF
Technology and Science News - ABC News
gapingtrousers365
 
PDF
Politics News and U.S. Elections Coverage
roastedrecluse128
 
PDF
Politics News and U.S. Elections Coverage
erna8nielsen65
 
PDF
Politics News and U.S. Elections Coverage
alertchair8725
 
PDF
U.S. News | National News
rhetoricalmosai86
 
PDF
Health News & Articles | Healthy Living
toothsomehardwa00
 
PDF
Politics News and U.S. Elections Coverage
excitedfoyer2246
 
PDF
Politics News and U.S. Elections Coverage
coldfascism4997
 
PDF
Politics News and U.S. Elections Coverage
awarequalm2586
 
PPT
Project presentation(View calender)
Ikhtiar Khan Sohan
 
PDF
Technology and Science News - ABC News
lethalsummary6309
 
DOCX
Codigo Server Festival
UNIVERSIDAD VERACRUZANA
 
PDF
U.S. News | National News
woodenpersonnel36
 
PDF
20/20 | Investigative Journalism & News Magazine
alertmishap944
 
PDF
U.S. News | National News
willingtablewar49
 
PDF
Nightline: Late Evening News - ABC News
dynamicindividu85
 
PDF
Politics News and U.S. Elections Coverage
exoticshame065
 
PDF
Politics News and U.S. Elections Coverage
talloration5719
 
Politics News and U.S. Elections Coverage
creepypreview6376
 
Technology and Science News - ABC News
ignorantlogic4950
 
Technology and Science News - ABC News
gapingtrousers365
 
Politics News and U.S. Elections Coverage
roastedrecluse128
 
Politics News and U.S. Elections Coverage
erna8nielsen65
 
Politics News and U.S. Elections Coverage
alertchair8725
 
U.S. News | National News
rhetoricalmosai86
 
Health News & Articles | Healthy Living
toothsomehardwa00
 
Politics News and U.S. Elections Coverage
excitedfoyer2246
 
Politics News and U.S. Elections Coverage
coldfascism4997
 
Politics News and U.S. Elections Coverage
awarequalm2586
 
Project presentation(View calender)
Ikhtiar Khan Sohan
 
Technology and Science News - ABC News
lethalsummary6309
 
Codigo Server Festival
UNIVERSIDAD VERACRUZANA
 
U.S. News | National News
woodenpersonnel36
 
20/20 | Investigative Journalism & News Magazine
alertmishap944
 
U.S. News | National News
willingtablewar49
 
Nightline: Late Evening News - ABC News
dynamicindividu85
 
Politics News and U.S. Elections Coverage
exoticshame065
 
Politics News and U.S. Elections Coverage
talloration5719
 

Similar to Google: Drive, Documents and Apps Script - How to work efficiently and happily (20)

PPTX
Google Apps Script for Beginners- Amazing Things with Code
Laurence Svekis ✔
 
PPT
Working with spreadsheets using google sheets
Billy Jean Morado
 
PDF
Tip-Create GoogleDrive Content List_FINAL.pdf
Invenio Advisors, LLC
 
PDF
Extending Google Apps/Spreadsheet using Google Apps Script
Dipali Vyas
 
PPTX
Introduction-to-use-Google-Sheets-Guide-pptx
VLink Inc
 
PDF
Enterprise workflow with Apps Script
ccherubino
 
PPTX
How to use Powerful tools of google sheet for organizing, visualizing and cal...
ControlRoom1FCCPP
 
PPT
Deep dive with google sheets
Billy Jean Morado
 
PDF
Minimal Fuss Data Transformation Using Google Apps Scripts
Salesforce Developers
 
PPT
Google spreadsheets
Raceel
 
PPTX
G Sheets introduction
Lyndon Watkins
 
PDF
Google Sheets Programming With Google Apps Script Michael Maguire
collabello2l
 
PDF
Google Apps Basic for Education
Kanda Runapongsa Saikaew
 
PPT
All about Microsoft Excel: Parts, Formulas
PubGZPh
 
PPT
Introduction to Google Apps Script
Martin Hawksey
 
PDF
14 awesome productivity hacks using google sheets [2020]
Adin Alihodzic
 
PPTX
Familiarizing_with_Spreadsheet_Application.pptx
JheaJashleyElaida
 
PPTX
Introducing google sheets and how to use it
KatherineHess9
 
PPT
Spreadsheets
iarthur
 
PPTX
Advanced Excel, Day 3
Khaled Al-Shamaa
 
Google Apps Script for Beginners- Amazing Things with Code
Laurence Svekis ✔
 
Working with spreadsheets using google sheets
Billy Jean Morado
 
Tip-Create GoogleDrive Content List_FINAL.pdf
Invenio Advisors, LLC
 
Extending Google Apps/Spreadsheet using Google Apps Script
Dipali Vyas
 
Introduction-to-use-Google-Sheets-Guide-pptx
VLink Inc
 
Enterprise workflow with Apps Script
ccherubino
 
How to use Powerful tools of google sheet for organizing, visualizing and cal...
ControlRoom1FCCPP
 
Deep dive with google sheets
Billy Jean Morado
 
Minimal Fuss Data Transformation Using Google Apps Scripts
Salesforce Developers
 
Google spreadsheets
Raceel
 
G Sheets introduction
Lyndon Watkins
 
Google Sheets Programming With Google Apps Script Michael Maguire
collabello2l
 
Google Apps Basic for Education
Kanda Runapongsa Saikaew
 
All about Microsoft Excel: Parts, Formulas
PubGZPh
 
Introduction to Google Apps Script
Martin Hawksey
 
14 awesome productivity hacks using google sheets [2020]
Adin Alihodzic
 
Familiarizing_with_Spreadsheet_Application.pptx
JheaJashleyElaida
 
Introducing google sheets and how to use it
KatherineHess9
 
Spreadsheets
iarthur
 
Advanced Excel, Day 3
Khaled Al-Shamaa
 
Ad

Recently uploaded (20)

PPTX
Exploring Multilingual Embeddings for Italian Semantic Search: A Pretrained a...
Sease
 
PDF
apidays Helsinki & North 2025 - How (not) to run a Graphql Stewardship Group,...
apidays
 
PPTX
recruitment Presentation.pptxhdhshhshshhehh
devraj40467
 
PPTX
Climate Action.pptx action plan for climate
justfortalabat
 
PDF
WEF_Future_of_Global_Fintech_Second_Edition_2025.pdf
AproximacionAlFuturo
 
PPTX
Advanced_NLP_with_Transformers_PPT_final 50.pptx
Shiwani Gupta
 
PDF
R Cookbook - Processing and Manipulating Geological spatial data with R.pdf
OtnielSimopiaref2
 
PDF
apidays Helsinki & North 2025 - APIs in the healthcare sector: hospitals inte...
apidays
 
PDF
Early_Diabetes_Detection_using_Machine_L.pdf
maria879693
 
PPTX
ER_Model_Relationship_in_DBMS_Presentation.pptx
dharaadhvaryu1992
 
PPTX
apidays Singapore 2025 - From Data to Insights: Building AI-Powered Data APIs...
apidays
 
PDF
Data Chunking Strategies for RAG in 2025.pdf
Tamanna
 
PPT
Data base management system Transactions.ppt
gandhamcharan2006
 
PPTX
apidays Munich 2025 - Building Telco-Aware Apps with Open Gateway APIs, Subhr...
apidays
 
PPTX
apidays Helsinki & North 2025 - From Chaos to Clarity: Designing (AI-Ready) A...
apidays
 
PDF
MusicVideoProjectRubric Animation production music video.pdf
ALBERTIANCASUGA
 
PDF
OPPOTUS - Malaysias on Malaysia 1Q2025.pdf
Oppotus
 
PDF
Product Management in HealthTech (Case Studies from SnappDoctor)
Hamed Shams
 
PDF
List of all the AI prompt cheat codes.pdf
Avijit Kumar Roy
 
PPTX
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
Exploring Multilingual Embeddings for Italian Semantic Search: A Pretrained a...
Sease
 
apidays Helsinki & North 2025 - How (not) to run a Graphql Stewardship Group,...
apidays
 
recruitment Presentation.pptxhdhshhshshhehh
devraj40467
 
Climate Action.pptx action plan for climate
justfortalabat
 
WEF_Future_of_Global_Fintech_Second_Edition_2025.pdf
AproximacionAlFuturo
 
Advanced_NLP_with_Transformers_PPT_final 50.pptx
Shiwani Gupta
 
R Cookbook - Processing and Manipulating Geological spatial data with R.pdf
OtnielSimopiaref2
 
apidays Helsinki & North 2025 - APIs in the healthcare sector: hospitals inte...
apidays
 
Early_Diabetes_Detection_using_Machine_L.pdf
maria879693
 
ER_Model_Relationship_in_DBMS_Presentation.pptx
dharaadhvaryu1992
 
apidays Singapore 2025 - From Data to Insights: Building AI-Powered Data APIs...
apidays
 
Data Chunking Strategies for RAG in 2025.pdf
Tamanna
 
Data base management system Transactions.ppt
gandhamcharan2006
 
apidays Munich 2025 - Building Telco-Aware Apps with Open Gateway APIs, Subhr...
apidays
 
apidays Helsinki & North 2025 - From Chaos to Clarity: Designing (AI-Ready) A...
apidays
 
MusicVideoProjectRubric Animation production music video.pdf
ALBERTIANCASUGA
 
OPPOTUS - Malaysias on Malaysia 1Q2025.pdf
Oppotus
 
Product Management in HealthTech (Case Studies from SnappDoctor)
Hamed Shams
 
List of all the AI prompt cheat codes.pdf
Avijit Kumar Roy
 
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
Ad

Google: Drive, Documents and Apps Script - How to work efficiently and happily

  • 1. Google: Drive, Documents and Apps Script GDG DevFest Pisa 2019 How to work efficiently and happily
  • 2. whoami? Alessandra Santi email: [email protected] Chartered Accountant and Auditor ● Linux User
  • 3. Table of Contents ● Google Drive ● Google Documents ● Sharing documents ● Google Apps Script ● Automate jobs Drive
  • 4. Table of Contents ● Google Drive ● Google Documents ● Sharing documents ● Google Apps Script ● Automate jobs Docs, sheets, forms, slides
  • 5. Table of Contents ● Google Drive ● Google Documents ● Sharing documents ● Google Apps Script ● Automate jobs Apps Script
  • 8. what is it? Drive container where: - to save, - to organize, - to manipulate, - to share files
  • 9. container where to save, organize, manipulate and share files
  • 10. container where to save, organize, manipulate and share files
  • 11. container where to save, organize, manipulate and share files zoom Right click
  • 12. container where to save, organize, manipulate and share files
  • 13. container where to save, organize, manipulate and share files
  • 14. container where to save, organize, manipulate and share files
  • 15. container where to save, organize, manipulate and share files
  • 16. container where to save, organize, manipulate and share files
  • 17. container where to save, organize, manipulate and share files
  • 18. Working with documents ● Docs ● Sheets ● Slides ● Forms ● ….
  • 19. Word processor and Spreadsheet
  • 21. Forms → like a Mask → to record data
  • 22. Slides → These slides with Slides :)
  • 24. With or WithOut Net Open files offline To turn on offline access: ● You must be connected to the internet. ● Use the Google Chrome browser. ● Don't use private browsing. ● Install and enable Google Docs offline Chrome extension. ● Make sure you have enough free space on your device. Open Google Docs, Sheets, and Slides offline 1. Open Chrome. Make sure you're signed in to Chrome. 2. Go to drive.google.com/drive/settings. 3. Check the box next to Sync Google Docs, Sheets ... files https://support.google.com/drive/answer/2375012?co=GENIE.Platform%3DDesktop&hl=en
  • 29. Apps Script Where to learn! https://developers.google.com/apps-script/
  • 31. Apps Script A lot of documentation! https://developers.google.com/apps-script/
  • 32. Apps Script A lot of documentation! Beginners: Ohhhh!!!! Title: Skrik - Author: Edvard Munch
  • 33. Apps Script Don’t worry! No Panic! ● https://developers.google.com/apps-script/overview ● https://developers.google.com/apps-script/articles/ Scripts run on Google’s Servers Nothing to install Help: Guides, Tutorials... Language: JavaScript
  • 34. Apps Script “You see, but you do not observe. The distinction is clear.” Sherlock Holmes Quote scripts
  • 35. Apps Script Observe code https://codelabs.developers.google.com/codelabs/apps-script-intro/#4 function sendMap() { var sheet = SpreadsheetApp.getActiveSheet(); var address = sheet.getRange('A1').getValue(); var map = Maps.newStaticMap().addMarker(address); GmailApp.sendEmail('[email protected]', 'Map', 'See below.', {attachments:[map]}) } function declaration class method
  • 36. Apps Script Observe code Manipulating sheets: Formatting Cells ● Add headers ● Customize background cells (color, fonts …) ● Adjust columns size ● …. Sheet: new style :)
  • 37. Apps Script Observe code Bounds Script Special Methods: ● getActiveSpreadsheet() ● getActiveSheet() ● getActiveRange() ● getActiveCell() ● setActiveSheet(sheet) ● setActiveRange(range) https://developers.google.com/apps-script/guides/bound Allow bound scripts to refer to their parent file without referring to the file's ID Let the script determine the user's current Sheet, selected Range of cells, or selected individual Cell Let the script change getActive* selections
  • 38. function formatStyle() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; //var sheet = ss.getSheetByName( 'Sheet1' ); var range1 = sheet.getRange( 'A1:C1' ); var range2 = sheet.getRange(2, 1, 1, 3); //(row, column, numRows, numColumns) range1.mergeAcross() .setBackground( 'green' ) .setValue( 'report' ) .setFontSize(12); range2.setBackground( '#3bf59b' ) .setValues( [['Name', 'LastName', 'Value']] ) .setFontSize(10); sheet.getRange(1, 1, 2, 3) .setBorder(true, true, true, true, true, true) /(top, left, bottom, right, vertical, horizontal) .setHorizontalAlignment( ['left', 'left', 'right'] ) .setVerticalAlignment( 'bottom' ) .setFontWeight( 'bold' ); var columnWidth = [150, 150, 80]; for ( var i = 0; i < columnWidth.length; i++ ) { sheet.setColumnWidth(i+1,columnWidth[i]); } sheet.setFrozenRows(2); SpreadsheetApp.flush(); } Observe code run = video1
  • 39. function formatStyle() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; //var sheet = ss.getSheetByName( 'Sheet1' ); var range1 = sheet.getRange( 'A1:C1' ); var range2 = sheet.getRange(2, 1, 1, 3); //(row, column, numRows, numColumns) range1.mergeAcross() .setBackground( 'green' ) .setValue( 'report' ) .setFontSize(12); range2.setBackground( '#3bf59b' ) .setValues( [['Name', 'LastName', 'Value']] ) .setFontSize(10); sheet.getRange(1, 1, 2, 3) .setBorder(true, true, true, true, true, true) /(top, left, bottom, right, vertical, horizontal) .setHorizontalAlignment( ['left', 'left', 'right'] ) .setVerticalAlignment( 'bottom' ) .setFontWeight( 'bold' ); var columnWidth = [150, 150, 80]; for ( var i = 0; i < columnWidth.length; i++ ) { sheet.setColumnWidth(i+1,columnWidth[i]); } sheet.setFrozenRows(2); SpreadsheetApp.flush(); } Observe code
  • 40. function formatStyle() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; //var sheet = ss.getSheetByName( 'Sheet1' ); var range1 = sheet.getRange( 'A1:C1' ); var range2 = sheet.getRange(2, 1, 1, 3); //(row, column, numRows, numColumns) range1.mergeAcross() .setBackground( 'green' ) .setValue( 'report' ) .setFontSize(12); range2.setBackground( '#3bf59b' ) .setValues( [['Name', 'LastName', 'Value']] ) .setFontSize(10); sheet.getRange(1, 1, 2, 3) .setBorder(true, true, true, true, true, true) /(top, left, bottom, right, vertical, horizontal) .setHorizontalAlignment( ['left', 'left', 'right'] ) .setVerticalAlignment( 'bottom' ) .setFontWeight( 'bold' ); var columnWidth = [150, 150, 80]; for ( var i = 0; i < columnWidth.length; i++ ) { sheet.setColumnWidth(i+1,columnWidth[i]); } sheet.setFrozenRows(2); SpreadsheetApp.flush(); } Observe code count from 0 (0, 1, 2) count from 0 (0, 1, 2)
  • 41. function onOpen(e) { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; //var sheet = ss.getSheetByName( 'Sheet1' ); var range1 = sheet.getRange( 'A1:C1' ); var range2 = sheet.getRange(2, 1, 1, 3); //(row, column, numRows, numColumns) range1.mergeAcross() .setBackground( 'green' ) .setValue( 'report' ) .setFontSize(12); range2.setBackground( '#3bf59b' ) .setValues( [['Name', 'LastName', 'Value']] ) .setFontSize(10); sheet.getRange(1, 1, 2, 3) .setBorder(true, true, true, true, true, true) /(top, left, bottom, right, vertical, horizontal) .setHorizontalAlignment( ['left', 'left', 'right'] ) .setVerticalAlignment( 'bottom' ) .setFontWeight( 'bold' ); var columnWidth = [150, 150, 80]; for ( var i = 0; i < columnWidth.length; i++ ) { sheet.setColumnWidth(i+1,columnWidth[i]); } sheet.setFrozenRows(2); SpreadsheetApp.flush(); } Observe code Trigger onOpen() open file
  • 42. Apps Script Observe code ● Add data ● Create and apply formulas ● Create charts ● Apply SQL queries ● ... Customize your work tools :)
  • 43. Observe code/** * A custom function that calculate tot price. * * @param {values} range of two cells * @return {tot_price} Un_Price * Q_ty */ function TOTPRICE(values) { var tot_pr = 1; for ( var i = 0; i < values[0].length; i++) { tot_pr *= values[0][i]; //tot_pr = tot_pr * values[0][i]; } return tot_pr; } Custom function Create a function with formula video2
  • 44. Observe code/** * A custom function that calculate tot price. * * @param {values} range of two cells * @return {tot_price} Un_Price * Q_ty */ function TOTPRICE(values) { var tot_pr = 1; for ( var i = 0; i < values[0].length; i++) { tot_pr *= values[0][i]; //tot_pr = tot_pr * values[0][i]; } return tot_pr; } Custom function Create a function with formula
  • 45. Observe codefunction addChart() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; var range1 = sheet.getRange("A1:B6") var chart = sheet.newChart() .setChartType(Charts.ChartType.LINE) .addRange(range1) .setPosition(1, 4, 0, 0) //(anchorRowPos,anchorColPos,offsetX, offsetY) .build(); sheet.insertChart(chart); } Embedded a Chart video3
  • 46. Observe codefunction addChart() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; var range1 = sheet.getRange("A1:B6") var chart = sheet.newChart() .setChartType(Charts.ChartType.LINE) .addRange(range1) .setPosition(1, 4, 0, 0) //(anchorRowPos,anchorColPos,offsetX, offsetY) .build(); sheet.insertChart(chart); } Embedded a Chart
  • 47. Observe code function addProfit() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sh = ss.getActiveSheet(); var range = sh.getRange(2, 3, 20, 2).getValues(); var profits = range.map( function(row) { return [ row[0] - row[1] ]; } ); sh.getRange(2, 5, profits.length, profits[0].length).setValues(profits); sh.getRange(1, 5).setValue("profits").setFontWeight('bold'); } .map Populate a Range of Values https://www.youtube.com/watch?v=985XJOeigpA
  • 48. Observe code function PROFIT(sales, cogs) { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sh = ss.getActiveSheet(); var profit = sales - cogs; return profit; } method .map
  • 49. Observe codefunction addProfit() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sh = ss.getActiveSheet(); var range = sh.getRange(2, 3, 20, 2).getValues(); var profits = range.map( function(row) { return [ row[0] - row[1] ]; } ); sh.getRange(2, 5, profits.length, profits[0].length).setValues(profits); sh.getRange(1, 5).setValue("profits").setFontWeight('bold'); } .map video4
  • 50. Apps Script attention … please! other considerations
  • 53. Drive: Ocr text in Docs attention … please! video5
  • 54. End Thank you for your attention! GDG DevFest Pisa 2019 - 13/04/2019 - Alessandra Santi - licence: CC BY-NC-SA