{"id":4284,"date":"2014-03-21T23:15:18","date_gmt":"2014-03-21T14:15:18","guid":{"rendered":"http:\/\/www.ka-net.org\/blog\/?p=4284"},"modified":"2014-03-24T16:22:51","modified_gmt":"2014-03-24T07:22:51","slug":"google-apps-script%e3%82%b5%e3%82%a4%e3%83%89%e3%83%90%e3%83%bc%e3%81%8b%e3%82%89%e7%94%bb%e5%83%8f%e3%82%92%e3%83%89%e3%82%ad%e3%83%a5%e3%83%a1%e3%83%b3%e3%83%88%e3%81%ab%e6%8c%bf%e5%85%a5%e3%81%99","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=4284","title":{"rendered":"[Google Apps Script]\u30b5\u30a4\u30c9\u30d0\u30fc\u304b\u3089\u753b\u50cf\u3092\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u633f\u5165\u3059\u308b(\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8)"},"content":{"rendered":"<p><span style=\"color: #ff0000; font-weight: bold;\">2014\/3\/24 \u8ffd\u8a18\uff1a<\/span><br \/>\n&#8220;<em>\u6587\u66f8<\/em>&#8220;\u306e\u5834\u5408\u306e\u51e6\u7406\u3082\u8003\u3048\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p><strong>\u30fb[Google Apps Script]\u30b5\u30a4\u30c9\u30d0\u30fc\u304b\u3089\u753b\u50cf\u3092\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u633f\u5165\u3059\u308b(\u6587\u66f8)<\/strong><br \/>\n<a href=\"\/\/www.ka-net.org\/blog\/?p=4293\" title=\"[Google Apps Script]\u30b5\u30a4\u30c9\u30d0\u30fc\u304b\u3089\u753b\u50cf\u3092\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u633f\u5165\u3059\u308b(\u6587\u66f8)\" target=\"_blank\">\/\/www.ka-net.org\/blog\/?p=4293<\/a><\/p>\n<p>\u30d1\u30d6\u30ea\u30c3\u30af\u30c9\u30e1\u30a4\u30f3\u306e\u753b\u50cf\u3092\u691c\u7d22\u30fb\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u308bWeb\u30b5\u30fc\u30d3\u30b9\u300c<a href=\"http:\/\/pixabay.com\/ja\/\" title=\"\u7121\u6599\u306e\u5199\u771f - Pixabay\" target=\"_blank\">Pixabay<\/a>\u300d\u306e<a href=\"http:\/\/pixabay.com\/api\/docs\/\" title=\"Pixabay API Documentation\" target=\"_blank\">API<\/a>\u3092\u5229\u7528\u3057\u3066\u3001\u30b5\u30a4\u30c9\u30d0\u30fc\u4e0a\u3067\u5165\u529b\u3057\u305f\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u5143\u306bPixabay\u3067\u691c\u7d22\u3092\u884c\u3044\u3001\u30d2\u30c3\u30c8\u3057\u305f\u753b\u50cf\u3092\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u633f\u5165\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u8003\u3048\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<ol>\n<li>\u30b5\u30a4\u30c9\u30d0\u30fc\u4e0a\u306e\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u306b\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066Enter\u30ad\u30fc\u3092\u62bc\u3057\u307e\u3059\u3002<\/li>\n<p><a href=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_07_01.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_07_01.jpg\" alt=\"GoogleAppsScript_07_01\" width=\"658\" height=\"243\" class=\"alignnone size-full wp-image-4285\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_07_01.jpg 658w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_07_01-300x110.jpg 300w\" sizes=\"auto, (max-width: 658px) 100vw, 658px\" \/><\/a><\/p>\n<li>Pixabay\u3067\u691c\u7d22\u3057\u3066\u30d2\u30c3\u30c8\u3057\u305f\u753b\u50cf\u304c\u30b5\u30a4\u30c9\u30d0\u30fc\u4e0a\u306b\u8868\u793a\u3055\u308c\u308b\u306e\u3067\u3001\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u633f\u5165\u3057\u305f\u3044\u753b\u50cf\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/li>\n<p><a href=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_07_02.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_07_02.jpg\" alt=\"GoogleAppsScript_07_02\" width=\"598\" height=\"648\" class=\"alignnone size-full wp-image-4286\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_07_02.jpg 598w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_07_02-276x300.jpg 276w\" sizes=\"auto, (max-width: 598px) 100vw, 598px\" \/><\/a><\/p>\n<li>\u9078\u629e\u3057\u3066\u3044\u308b\u30bb\u30eb\u306b\u753b\u50cf\u304c\u633f\u5165\u3055\u308c\u307e\u3059\u3002<\/li>\n<p><a href=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_07_03.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_07_03.jpg\" alt=\"GoogleAppsScript_07_03\" width=\"1064\" height=\"671\" class=\"alignnone size-full wp-image-4287\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_07_03.jpg 1064w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_07_03-300x189.jpg 300w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_07_03-1024x645.jpg 1024w\" sizes=\"auto, (max-width: 1064px) 100vw, 1064px\" \/><\/a>\n<\/ol>\n<p><span style=\"color: #ff0000; font-weight: bold;\">\u203b API\u3092\u5229\u7528\u3059\u308b\u306b\u306f\u30e6\u30fc\u30b6\u30fc\u540d\u3068API\u30ad\u30fc\u304c\u5fc5\u8981\u3067\u3042\u308b\u305f\u3081\u3001\u4e8b\u524d\u306b <a href=\"http:\/\/pixabay.com\/ja\/accounts\/register\/\" target=\"_blank\">http:\/\/pixabay.com\/ja\/accounts\/register\/<\/a> \u304b\u3089\u30b5\u30a4\u30f3\u30a2\u30c3\u30d7\u3057\u3066\u53d6\u5f97\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/span><\/p>\n<p><strong>\u30fb\u30b3\u30fc\u30c9.gs<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var ui = SpreadsheetApp.getUi();\r\nvar html = HtmlService.createHtmlOutputFromFile('Pixabay').setTitle('Pixabay\u304b\u3089\u753b\u50cf\u3092\u633f\u5165').setWidth(300);\r\n\r\nfunction onOpen(e){\r\n    ui.showSidebar(html);\r\n}\r\n\r\nfunction searchPixabayPhoto(txt){\r\n    var content = '';\r\n    var user = ''; \/\/Pixabay\u306e\u30e6\u30fc\u30b6\u30fc\u540d\u3092\u3053\u3053\u306b\u5165\u529b\r\n    var key = ''; \/\/Pixabay\u306eAPI\u30ad\u30fc\u3092\u3053\u3053\u306b\u5165\u529b\r\n    var url = 'http:\/\/pixabay.com\/api\/?username=' + user + '&amp;key=' + key + '&amp;lang=ja&amp;image_type=all&amp;orientation=all&amp;order=popular&amp;search_term=' + encodeURIComponent(txt);\r\n    var res = UrlFetchApp.fetch(url);\r\n    var data = JSON.parse(res.getContentText());\r\n    if(parseFloat(data.totalHits) &lt; 1){\r\n        content = '&lt;h3&gt;\u5199\u771f\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002&lt;\/h3&gt;';\r\n    }else{\r\n        content = '&lt;ol&gt;';\r\n        data.hits.forEach(function(item){\r\n            content += '&lt;li&gt;&lt;img src=&quot;' + item.previewURL + '&quot; alt=&quot;' + item.webformatURL + '&quot; title=&quot;\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u753b\u50cf\u3092\u633f\u5165\u3057\u307e\u3059\u3002&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;' + item.pageURL + '&quot; target=&quot;_blank&quot; title=&quot;\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u5199\u771f\u306e\u30da\u30fc\u30b8\u3092\u958b\u304d\u307e\u3059\u3002&quot;&gt;PageURL&lt;\/a&gt;&lt;\/li&gt;&lt;\/ul&gt;&lt;\/li&gt;';\r\n        });\r\n        content += '&lt;\/ol&gt;';\r\n    }\r\n    html.append(content);\r\n    ui.showSidebar(html); \/\/\u30b5\u30a4\u30c9\u30d0\u30fc\u518d\u63cf\u753b\r\n}\r\n\r\nfunction insertPixabayPhoto(url){\r\n    var sht = SpreadsheetApp.getActiveSheet();\r\n    var cell = sht.getActiveCell();\r\n    sht.insertImage(url, cell.getColumn(), cell.getRow());\r\n}<\/pre>\n<p><strong>\u30fbPixabay.html<\/strong><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;html&gt;\r\n    &lt;head&gt;\r\n        &lt;meta charset=&quot;UTF-8&quot;&gt;\r\n        &lt;link rel=&quot;stylesheet&quot; href=&quot;https:\/\/ssl.gstatic.com\/docs\/script\/css\/add-ons.css&quot;&gt;\r\n        &lt;style&gt;\r\n            #main{padding:20px;}\r\n            img:hover{cursor:pointer;}\r\n        &lt;\/style&gt;\r\n        &lt;script src=&quot;\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.11.0\/jquery.min.js&quot;&gt;&lt;\/script&gt;\r\n        &lt;script&gt;\r\n            $(function(){\r\n                $(&quot;#q&quot;).keypress(function(e){\r\n                    switch(e.which){\r\n                        case 13: \/\/Enter\u30ad\u30fc\u5165\u529b\u6642\u306e\u51e6\u7406\r\n                            google.script.run.searchPixabayPhoto($(this).val());\r\n                            break;\r\n                    }\r\n                });\r\n                \r\n                $(&quot;img&quot;).click(function(){\r\n                    google.script.run.insertPixabayPhoto($(this).attr(&quot;alt&quot;));\r\n                });\r\n            });\r\n        &lt;\/script&gt;\r\n    &lt;\/head&gt;\r\n    &lt;body&gt;\r\n        &lt;div id=&quot;main&quot;&gt;\r\n            &lt;input id=&quot;q&quot; type=&quot;text&quot; title=&quot;\u30ad\u30fc\u30ef\u30fc\u30c9\u5165\u529b\u5f8cEnter\u30ad\u30fc\u3092\u62bc\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot;&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<ul>\n<li>Class UrlFetchApp<\/li>\n<li style=\"list-style-type:none;\"><a href=\"https:\/\/developers.google.com\/apps-script\/reference\/url-fetch\/url-fetch-app?hl=ja\" target=\"_blank\" title=\"Class UrlFetchApp\">https:\/\/developers.google.com\/apps-script\/reference\/url-fetch\/url-fetch-app?hl=ja<\/a><\/li>\n<li>insertImage(url, column, row)<\/li>\n<li style=\"list-style-type:none;\"><a href=\"https:\/\/developers.google.com\/apps-script\/reference\/spreadsheet\/sheet?hl=ja#insertImage%28String,Integer,Integer%29\" target=\"_blank\" title=\"insertImage(url, column, row)\">https:\/\/developers.google.com\/apps-script\/reference\/spreadsheet\/sheet?hl=ja#insertImage%28String,Integer,Integer%29<\/a><\/li>\n<\/ul>\n<h4>\u3010\u7de8\u96c6\u5f8c\u8a18\u3011<\/h4>\n<p>\u4eca\u56de\u306e\u8a18\u4e8b\u3067\u7d39\u4ecb\u3057\u3066\u3044\u308b\u306e\u306f\u3001Office \u7528\u30a2\u30d7\u30ea\u3067\u3044\u3046\u3068\u3053\u308d\u306e\u300c<a href=\"http:\/\/office.microsoft.com\/ja-jp\/store\/WA103436788.aspx\" title=\"Bing Image Search - Store - Office.com\" target=\"_blank\">Bing Image Search<\/a>\u300d\u306e\u3088\u3046\u306a\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3059\u3002<\/p>\n<p>\u6700\u521d\u306fOffice \u7528\u30a2\u30d7\u30ea\u3068\u540c\u69d8\u3001HTML\u5074\u3067getJSON\u3092\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3088\u3046\u3068\u3057\u305f\u306e\u3067\u3059\u304c\u3001\u3053\u306e\u65b9\u6cd5\u3067\u306f\u4e0a\u624b\u304f\u51e6\u7406\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002<br \/>\n\u7d50\u5c40GAS\u5074\u3067UrlFetchApp.fetch\u3067\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3001insertImage\u3067\u753b\u50cf\u3092\u633f\u5165\u3059\u308b\u3053\u3068\u306b\u3057\u305f\u306e\u3067\u3059\u304c\u3001\u4eca\u56de\u306e\u3088\u3046\u306bGAS\u5074\u3068HTML\u5074\u306e\u51e6\u7406\u3092\u4e0a\u624b\u3044\u3053\u3068\u5206\u3051\u308c\u3070\u3001\u8272\u3005\u3068\u9762\u767d\u3044\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u4f5c\u308c\u305d\u3046\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"2014\/3\/24 \u8ffd\u8a18\uff1a &#8220;\u6587\u66f8&#8220;\u306e\u5834\u5408\u306e\u51e6\u7406\u3082\u8003\u3048\u3066\u307f\u307e\u3057\u305f\u3002 \u30fb[Google Apps Script]\u30b5\u30a4\u30c9\u30d0\u30fc\u304b\u3089\u753b\u50cf\u3092\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u633f\u5165\u3059\u308b(\u6587\u66f8) \/\/www.ka-net.org\/ [&hellip;]","protected":false},"author":1,"featured_media":7113,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[126],"tags":[],"class_list":["post-4284","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-google"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-Google.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-176","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4284"}],"version-history":[{"count":4,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4284\/revisions"}],"predecessor-version":[{"id":4299,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4284\/revisions\/4299"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7113"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}