Google Apps Script ããã£åå¼·ä¼ UIå¨ãã®å®è£ æ¹æ³ ç´¹ä»
ä»æµè¡ã®ãµã¼ãã¼ãµã¤ãJSã¨ããã¨ï¼ 10人ä¸9人以ä¸ãnode.jsã¨ããä»æ¥ãã®é ã§ããããããéããã§ããããï¼node.jsåãã§ããããã¹ã´ã¤ã¹ã´ã¤ãã´ã¤ã¹ã¼ã§ããã§ãå®éä½ã«ä½¿ãã¾ãããï¼ã¾ãé¢ç½ãã§ãããã
ã§ã話ã¯å¤ãã£ã¦GASã§ããGASã¨ã¯ãGoogle Apps Scriptã®ç¥ã§Google Docsã®ã¹ãã¬ããã·ã¼ãã®æ©è½ã®ä¸ã¤ã§ããã¹ãã¬ããã·ã¼ãã«æå±ããå½¢ã§ä¿åããã¾ããå®è¡ã¯Googleã®ãµã¼ãã¼ä¸ã§è¡ããçµæãè¿ãã¾ãããGASã®ç¹å¾´ã®ä¸ã¤ã§ãGoogleå å¤ã®ã®æ§ã ãªãµã¼ãã¹ã®ãã¼ã¿ã«ã¢ã¯ã»ã¹ãããã¨ãåºæ¥ã¾ãã
- ã«ã¬ã³ãã¼
- ã³ã³ã¿ã¯ã
- ã¡ã¼ã«ï¼éä¿¡ã®ã¿ï¼
- ãµã¤ã
- ããã
- Docs
- UrlFetch
- xml
- Jdbc
ãªã©ãªã©ã§ããåå以ä¸ã®ãµã¼ãã¹ã¯ç¡æã¢ã«ã¦ã³ãã§å©ç¨å¯è½ã§ãã
ä»æ¥ã®ããã£GASåå¼·ä¼ã§ãUi Servicesãããã£ãã®ã§ç´¹ä»ãã¾ããï¼è¦ãã¬ãã¢ã¢ã«ã¦ã³ãgmail.comã¢ã«ã¦ã³ãã§OKï¼
Ui Servicesã使ãã¨ãããããªUIãã¹ãã¬ãã·ã¼ãä¸ã«ä½æãããã¨ãã§ããããã«ãªãã¾ãã
ãããªã¦ã£ã³ãã¦ãä½æããããã®ã³ã¼ãã¯
function myFunction() { var mydoc = SpreadsheetApp.getActiveSpreadsheet(); // ã¢ããªãä½æ var app = UiApp.createApplication().setTitle('GAS UI').setHeight(250).setWidth(200); // è¦ç´ ãä½æ var btn = app.createButton('btn'); // button var pushbtn = app.createPushButton('push btn').setWidth('100'); // push button var radiobtn1 = app.createRadioButton('radio btn'); var radiobtn2 = app.createRadioButton('radio btn'); var flxpnl = app.createFlexTable(); var file = app.createFileUpload(); // radioã«è¦ç´ ã追å radiobtn1.setText('radio1'); radiobtn2.setText('radio2'); // ãã¿ã³æ¼ä¸æç¨ã®ãã³ãã©ãä½æ var handler = app.createServerClickHandler('pushedBtn'); btn.addClickHandler(handler); // Verticalããã«ãä½æ var pnl = app.createVerticalPanel(); // ããã«ã«è¦ç´ ã追å pnl.add(btn); pnl.add(pushbtn); pnl.add(radiobtn1); pnl.add(radiobtn2); pnl.add(file); // ã¢ããªã«ããã«ã追å app.add(pnl); // ã¢ããªã表示ããã mydoc.show(app); } function pushedBtn(){ var app = UiApp.getActiveApplication(); var mail_add = Session.getUser().getEmail(); app.close(); Browser.msgBox('ã¡ã¼ã«ãããã¾ãã'); sendMail(mail_add); Browser.msgBox('ã¡ã¼ã«ãããã¾ããï¼'); } function sendMail(sendToAdd){ Browser.msgBox(sendToAdd); var dd = new Date(); var myFiles = [{fileName:"my_document.html", content:"Insert any HTML content here"}] MailApp.sendEmail(sendToAdd, "Attachment example", "Here is my document", {attachments: myFiles}); Logger.log("INFO: " + dd.toLocaleTimeString() + " " + "send to address: " + sendToAdd) };
詳細説æ
âGAS UIâã¨ããã¿ã¤ãã«ã®å¹ 200ã縦250ãµã¤ãºã®ã¢ããªãä½æããã
var app = UiApp.createApplication().setTitle('GAS UI').setHeight(250).setWidth(200);
ãã¿ã³ããã©ã¸ãªã®è¦ç´ ãä½æãã¦ãããã«ã«è¿½å ãã¦ãã¢ããªã«ããã«ã追å ããããããããã¿ã¼ã³ã
ãã¿ã³ã«ã¤ãã³ãã追å ããã«ã¯
var btn = app.createButton('btn'); var handler = app.createServerClickHandler('pushedBtn'); btn.addClickHandler(handler);
ãã¿ã³ãä½æãã¦ããã³ãã©ã¼ãä½æãã¯ãªãã¯ã¤ãã³ãã«ãã³ãã©ã¼ãç»é²ãããã¤ãã³ããçºçããã¨"pushedBtn"ãå¼ã°ããã®ã§ãã¡ã½ãããä½æãã¨ããï¼ä»åã¯ã¡ã¼ã«ãéä¿¡ããããã«ãã¦ã¿ãï¼
function pushedBtn(){ var app = UiApp.getActiveApplication(); var mail_add = Session.getUser().getEmail(); app.close(); Browser.msgBox('ã¡ã¼ã«ãããã¾ãã'); sendMail(mail_add); Browser.msgBox('ã¡ã¼ã«ãããã¾ããï¼'); } function sendMail(sendToAdd){ Browser.msgBox(sendToAdd); var dd = new Date(); var myFiles = [{fileName:"my_document.html", content:"Insert any HTML content here"}] MailApp.sendEmail(sendToAdd, "Attachment example", "Here is my document", {attachments: myFiles}); Logger.log("INFO: " + dd.toLocaleTimeString() + " " + "send to address: " + sendToAdd) };
ãµã¼ãã¼ãµã¤ãã§åãã®ã§ãprintããã°ãåºæ¥ãªãã®ã§Loggerã使ç¨ããã
Logger.log('hogehoge')
ãããä»è¾¼ãã°ããã°ãä½æãããããã°ãè¦ãããã«ã¯ãã¡ãã¥ã¼ãã¼ï¼è¡¨ç¤ºï¼ãã°ããé²è¦§å¯è½
Let's GAS!!