google-apps-script 1 #google- apps-script
Advanced Google Apps Script Programming #1 https://goo.gl/I8 oktl วทิ ยากร นายคณกรณ์ หอศริ ิธรรม นายศริ ิพงษ์ ศริ ิวรรณ นายเกรียงไกร หนูทองคาํ มหาวทิ ยาลัยสงขลานครินทร ์ WUNCA 32nd @ Suranaree University of Technology 22 January 2559
Advanced Google Apps Script Programming #1 Introduction to Google Apps Script: ปูพ้นื ฐานสําหรบั ผูที่ไมเคยใช Google Apps Scripts มากอน เริม่ จากคําสง่ั พน้ื ฐานในการเขยี นโปรแกรม การวนลูป เงื่อนไข ไปจนกระท่ังการเขียน Function ตอบแบบสํารวจ http://goo.gl/forms/lxyuj8mjwG https://sysadmin.psu.ac.th/2015/05/06/gasws-1/ https://sysadmin.psu.ac.th/2015/05/07/gasws-1-01/ ●Google Apps Scripts Workshop – Level 1 ●เรมิ่ ตนใชงาน GAS Editor ●ล็อกอิน Google Account แลวไปท่ี Google Drive ● ●ตงั้ ช่ือ GASWS1 ●ต้งั ช่ือ myproject1 กด OK. WUNCA 32n d @ Suranaree University of Technology 22 January 2559 1/18
Advanced Google Apps Script Programming #1 ●ต้งั ชอื่ myscript1 ●แกไข myFunction() โดยเพ่ิมขอความ ●กดปมุ File -> Save หรอื กดปมุ ctrl + s ●เมนู Run > myFunction ●ดผู ลไดที่ เมนู View > Logs หรือ กดปุม Ctrl+Enter ●สราง function myForLoop ดงั น ี้ WUNCA 32nd @ Suranaree University of Technology 22 January 2559 2/18
Advanced Google Apps Script Programming #1 ●เมนู File > New > Script File WUNCA 32nd @ Suranaree University of Technology 22 January 2559 3/18
Advanced Google Apps Script Programming #1 ●ตง้ั ชอ่ื myscript2 ●สราง function myDate ดงั น ี้ ●การตงั้ เวลาให project ทาํ งานสามารถเลือกไดจากเมนู Resources > All yours triggers ●การทํา comment สามารถใชสัญลักษณ // หรือ /* คลายกับลกั ษณะการคอมเมนทในภาษา C WUNCA 32nd @ Suranaree University of Technology 22 January 2559 4/18
Advanced Google Apps Script Programming #1 Workshop 1: เขียนอานขอมลู กับ Google Sheets เกีย่ วกบั ใชงาน Google Sheets เปนฐานขอมลู ●อาน/เขยี นขอมลู กับ Google Sheets https://sysadmin.psu.ac.th/2015/05/06/gasws-1-03/ ●สราง script ใหมชือ่ myscript3 โดย เมนู File > New > Script File ●ตัง้ ชอ่ื myscript3 ●เมนู Run > insertData1 WUNCA 32n d @ Suranaree University of Technology 22 January 2559 5/18
Advanced Google Apps Script Programming #1 ●สรางตัวแปร v3 โดยใสขอมูลสวนตวั WUNCA 32nd @ Suranaree University of Technology 22 January 2559 6/18
Advanced Google Apps Script Programming #1 กดปมุ Run -> Insertdata1 ดูผลลัพธในแฟม Sheet ●สราง function insertData2() ตามนี้ WUNCA 32nd @ Suranaree University of Technology 22 January 2559 7/18
Advanced Google Apps Script Programming #1 ●ตองการให Run ทุกนาที เลอื กเมนู Resource -> All your triggers ●ดูผลลพั ธจาก Sheet จะเหน็ การเปลีย่ นแปลง ●Google limitQuotas for Google Services https://developers.google.com/apps-script/guides/services/quotas?hl=en ●สราง function readData1() ตามนี้ ●เปดเมนู Tools > Script Editor… WUNCA 32n d @ Suranaree University of Technology 22 January 2559 8/18
Advanced Google Apps Script Programming #1 ● สร้าง Sheet ใหม ่ ช่ือ “ReadData” โดยกดป่ ุมเคร่ืองหมาย + ●เปดแฟม https://docs.google.com/spreadsheets/d/1oztRXjC2KJzrqC3LtiRnUPrEgohX4VTYHixylv tCdzY/edit?usp=sharing ● สร้าง function insertData3() ตามน้ี WUNCA 32nd @ Suranaree University of Technology 22 January 2559 9/18
Advanced Google Apps Script Programming #1 https://sysadmin.psu.ac.th/2015/05/15/gasws-1-05/ แทนท่ีขอความ ดวยคาใน Google Sheets ● ใน Google Sheet: GASWS1 ● สร้าง Sheet ใหม ่ ช่ือ “Salary” ● ใน 5 คน ขอให้ 1 คนเป็น ○ คณกรณ์ หอศริ ิธรรม [email protected] ○ สร้าง Sheet ใหม ่ ช่ือ “Template” ○ ใสข่ อ้ มูล ○ A1: เรียน คุณ{Firstname} {Lastname} ○ A2: จะมี {SalaryDetail} จาํ นวน {Salary} บาท โอนให้คุณในวันท่ี {TransferDate} ○ A3: จึงเรียนมาเพ่ือทราบ ○ A4: การเงนิ ○ เมนู Tools > Script Editor… ○ เมนู File > New > Script File ○ ตัง้ ช่ือ: myscript5 WUNCA 32n d @ Suranaree University of Technology 22 January 2559 10/18
Advanced Google Apps Script Programming #1 https://sysadmin.psu.ac.th/2015/05/18/gasws-1-06/ สราง Google Docs ใหมใน Google Drive แลวต้ังชอ่ื ตามตองการ จากนั้น ใสขอความตอไปนลี้ งไป เรียน คุณ{Firstname} {Lastname} จะมี {SalaryDetail} จาํ นวน {Salary} บาท โอนให้คุณในวันท่ี {TransferDate} จึงเรียนมาเพ่ือทราบ การเงนิ Reference https://developers.google.com/appsscript/ WUNCA 32nd @ Suranaree University of Technology 22 January 2559 11/18
Advanced Google Apps Script Programming #1 Workshop 2: การสราง Mail Merge พ้นื ฐาน จากขอมลู ใน Google Sheets สามารถสรางจดหมายเวียนไดอยางไร https://sysadmin.psu.ac.th/2015/05/20/gasws-1-07/ WUNCA 32n d @ Suranaree University of Technology 22 January 2559 12/18
Advanced Google Apps Script Programming #1 Workshop 3: การสราง SelfDestroy Email จาก Google Sheets สามารถนํามาสรางเปน Google Docs หรอื PDF แลวสง email เมอื่ ผูอานอานจดหมายเสร็จแลว จะทาํ ลายตวั เองในเวลาทก่ี าํ หนดได https://sysadmin.psu.ac.th/2015/05/22/top-secret/ WUNCA 32n d @ Suranaree University of Technology 22 January 2559 13/18
Advanced Google Apps Script Programming #1 Workshop 4: การเก็บขอมูลจาก Web Page แลวนําไปวเิ คราะห ตองการเก็บขอมูลท่ที างเวบ็ ไซตมกี ารเปล่ยี นแปลงในชวงเวลาหนง่ึ ๆเปนประจํา จะตง้ั เวลาใหระบบไปเกบ็ ขอมลู แลวนํามาเขียนลง Google Sheets เพอื่ วิเคราะหไดอยางไร https://sysadmin.psu.ac.th/2015/05/06/gasws-1-04/ https://sysadmin.psu.ac.th/2015/05/14/gas-web-data-extract/ http://www.bloomberg.com/quote/WGHCEPA:ID WUNCA 32n d @ Suranaree University of Technology 22 January 2559 14/18
Advanced Google Apps Script Programming #1 Demo 5: การใชงาน API ตางๆ สําหรับ API ตางๆทเ่ี ปนประโยชนเพือ่ ไปใชงานตอไป พรอมตัวอยางทนี่ าสนใจ https://sysadmin.psu.ac.th/2015/05/22/gasws-1-08/ https://sysadmin.psu.ac.th/2014/10/11/googleappsscript-googlesheet-websitemoni toring/ https://sysadmin.psu.ac.th/2014/11/02/googlesheets-newaccount-suborganization- gas/ https://sysadmin.psu.ac.th/2015/09/08/google-classroom-manager/ WUNCA 32nd @ Suranaree University of Technology 22 January 2559 15/18
Advanced Google Apps Script Programming #1 Demo 6: การใชรวมกับ Google BigQuery มีขอมลู ขนาดมากกวา 1 TB ใน Google BigQuery สามารถสงผลการคนหาออกมาวเิ คราะหสรุปผลดวย Google Sheets ไดอยางไร https://goo.gl/3XYjMR WUNCA 32nd @ Suranaree University of Technology 22 January 2559 16/18
Advanced Google Apps Script Programming #1 Demo 7: การใชรวมกบั Google Prediction API การใชงาน Machine Learning ดวย Google Prediction API บน Google Sheets https://cloud.google.com/prediction/docs?hl=en WUNCA 32nd @ Suranaree University of Technology 22 January 2559 17/18
Search
Read the Text Version
- 1 - 19
Pages: