{"id":1040,"date":"2011-12-13T16:59:26","date_gmt":"2011-12-13T07:59:26","guid":{"rendered":"http:\/\/www.ka-net.org\/blog\/?p=1040"},"modified":"2011-12-15T10:33:18","modified_gmt":"2011-12-15T01:33:18","slug":"excel-services-javascript-api%e3%82%92%e8%a9%a6%e3%81%97%e3%81%a6%e3%81%bf%e3%81%be%e3%81%97%e3%81%9f2","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=1040","title":{"rendered":"Excel Services JavaScript API\u3092\u8a66\u3057\u3066\u307f\u307e\u3057\u305f(2)"},"content":{"rendered":"<p>\u524d\u56de\u306e<a href=\"\/\/www.ka-net.org\/blog\/?p=969\" title=\"Excel Services JavaScript API\u3092\u8a66\u3057\u3066\u307f\u307e\u3057\u305f(1)\" target=\"_blank\">\u8a18\u4e8b<\/a>\u3067\u3001JavaScript\u30b3\u30fc\u30c9\u3092\u8cbc\u308a\u4ed8\u3051\u3066Excel\u30ef\u30fc\u30af\u30d6\u30c3\u30af\u3092Web\u30da\u30fc\u30b8\u306b\u57cb\u3081\u8fbc\u3080\u3068\u3053\u308d\u307e\u3067\u78ba\u8a8d\u3057\u307e\u3057\u305f\u3002<br \/>\n\u4eca\u56de\u306f\u3044\u3088\u3044\u3088\u8cbc\u308a\u4ed8\u3051\u305f\u30d6\u30c3\u30af\u3092JavaScript\u3067\u64cd\u4f5c\u3057\u3066\u307f\u307e\u3059\u3002<br \/>\n<!--more--><\/p>\n<p>\u307e\u305a\u306f\u7fd2\u3046\u3088\u308a\u6163\u308c\u308d\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u30b5\u30f3\u30d7\u30eb\u30da\u30fc\u30b8\u300c<a href=\"http:\/\/www.excelmashup.com\/APIBrowser#example105\" title=\"Read formatted value from selected cell\" target=\"_blank\">Read formatted value from selected cell<\/a>\u300d\u306e\u30b3\u30fc\u30c9\u3092\u307b\u307c\u305d\u306e\u307e\u307e\u4f7f\u3063\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">&lt;input type=&quot;button&quot; value=&quot;\u30af\u30ea\u30c3\u30af\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot; onclick=&quot;execute();&quot;&gt;&lt;\/input&gt;\r\n&lt;script type=&quot;text\/javascript&quot; src=&quot;http:\/\/r.office.microsoft.com\/r\/rlidExcelWLJS?v=1&amp;kip=1&quot;&gt;&lt;\/script&gt;\r\n&lt;script type=&quot;text\/javascript&quot;&gt;\r\n    \/\/ run the Excel load handler on page load\r\n    if (window.attachEvent) {\r\n        window.attachEvent(&quot;onload&quot;, loadEwaOnPageLoad);\r\n    } else {\r\n        window.addEventListener(&quot;DOMContentLoaded&quot;, loadEwaOnPageLoad, false);\r\n    }\r\n\r\n    function loadEwaOnPageLoad() {\r\n        var fileToken = &quot;SD92A165759188B352!264\/-7880906317294423214\/&quot;;\r\n        var props = {\r\n            item: &quot;'Sheet1'!A1:C3&quot;,\r\n            uiOptions: {\r\n                showDownloadButton: false,\r\n                showGridlines: false,\r\n                selectedCell: &quot;'Sheet1'!B2&quot;,\r\n                showParametersTaskPane: false\r\n            },\r\n            interactivityOptions: {\r\n                allowTypingAndFormulaEntry: false,\r\n                allowParameterModification: false,\r\n                allowSorting: false,\r\n                allowFiltering: false,\r\n                allowPivotTableInteractivity: false\r\n            }\r\n        };\r\n        Ewa.EwaControl.loadEwaAsync(fileToken, &quot;myExcelDiv&quot;, props, onEwaLoaded);\r\n    }\r\n\r\n    function onEwaLoaded() {\r\n        \/\/document.getElementById(&quot;loadingdiv&quot;).style.display = &quot;none&quot;;\r\n    }\r\n    \/\/ This sample gets the value in the highlighted cell. \r\n    \/\/ Try clicking on different cells then running the sample.\r\n\r\n    function execute() {\r\n        \/\/ Get unformatted range values (getValuesAsync(1,...) where 1 = Ewa.ValuesFormat.Formatted)\r\n        ewa.getActiveWorkbook().getActiveCell().getValuesAsync(1, getRangeValues, null);\r\n    }\r\n\r\n    function getRangeValues(asyncResult) {\r\n        \/\/ Get the value from asyncResult if the asynchronous operation was successful.\r\n        if (asyncResult.getCode() == 0) {\r\n            \/\/ Get the value in active cell (located at row 0, column 0 of the\r\n            \/\/ range which consists of a single cell (the &quot;active cell&quot;)).\r\n            alert(&quot;Result: &quot; + asyncResult.getReturnValue()&#x5B;0]&#x5B;0]);\r\n        } else {\r\n            alert(&quot;Operation failed with error message &quot; + asyncResult.getDescription() + &quot;.&quot;);\r\n        }\r\n    }\r\n&lt;\/script&gt;\r\n&lt;div id=&quot;myExcelDiv&quot; style=&quot;width: 300px; height: 100px&quot;&gt;&lt;\/div&gt;<\/pre>\n<p>\u30fb\u30fb\u30fb\u300c<strong>\u30af\u30ea\u30c3\u30af\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/strong>\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u3082\u52d5\u4f5c\u3057\u307e\u305b\u3093\u3002<br \/>\n\u3084\u306f\u308a\u6700\u521d\u304b\u3089\u4e0a\u624b\u304f\u306f\u3044\u304b\u306a\u3044\u3067\u3059\u306d\u30fb\u30fb\u30fb\u3002<\/p>\n<p>\u300c<a href=\"http:\/\/www.excelmashup.com\/APIBrowser#example105\" title=\"Read formatted value from selected cell\" target=\"_blank\">Read formatted value from selected cell<\/a>\u300d\u306e\u30b5\u30f3\u30d7\u30eb\u306f\u3001\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af(<strong>execute<\/strong>\u3092\u5b9f\u884c)\u3059\u308b\u3068\u30a2\u30af\u30c6\u30a3\u30d6\u30bb\u30eb\u306e\u5024\u3092alert\u3067\u8868\u793a\u3059\u308b\u3001\u3068\u3044\u3046\u3082\u306e\u3067\u3059\u304c\u3001\u4e0a\u8a18\u30b3\u30fc\u30c9\u306f\u3069\u3046\u3084\u3089execute\u95a2\u6570\u304c\u4e0a\u624b\u304f\u52d5\u4f5c\u3057\u3066\u3044\u306a\u3044\u3088\u3046\u3067\u3059\u3002<br \/>\n\u305d\u3053\u3067execute\u95a2\u6570\u306e\u4e2d\u8eab\u3092\u898b\u3066\u307f\u308b\u3068\u6b21\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">ewa.getActiveWorkbook().getActiveCell().getValuesAsync(1, getRangeValues, null);<\/pre>\n<p>\u3053\u308c\u3092\u898b\u308b\u3068\u3001<\/p>\n<p><strong>1. ewa(\u30aa\u30d6\u30b8\u30a7\u30af\u30c8?)\u306egetActiveWorkbook\u30e1\u30bd\u30c3\u30c9\u3067\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30ef\u30fc\u30af\u30d6\u30c3\u30af\u3092\u53d6\u5f97<\/strong><br \/>\n<strong>2. 1.\u3067\u53d6\u5f97\u3057\u305f\u30ef\u30fc\u30af\u30d6\u30c3\u30af\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306egetActiveCell\u30e1\u30bd\u30c3\u30c9\u3067\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30bb\u30eb\u3092\u53d6\u5f97<\/strong><br \/>\n<strong>3. 2.\u3067\u53d6\u5f97\u3057\u305f\u30bb\u30eb(Range?)\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306egetValuesAsync\u30e1\u30bd\u30c3\u30c9\u3067\u30bb\u30eb\u306e\u5024\u3092\u53d6\u5f97<\/strong><\/p>\n<p>\u3068\u3044\u3046\u3088\u3046\u306a\u52d5\u4f5c\u3092\u3059\u308b\u306e\u3067\u306f\u306a\u3044\u304b\u3068\u63a8\u6e2c\u3067\u304d\u307e\u3059\u304c\u3001\u305d\u3082\u305d\u3082\u3053\u306e\u300c<span style=\"color: #ff0000; font-weight: bold;\">ewa<\/span>\u300d\u3068\u3044\u3046\u306e\u306f\u3069\u3053\u304b\u3089\u6765\u3066\u3044\u308b\u306e\u304b\uff1f<br \/>\n\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u4e2d\u306b\u306f\u305d\u308c\u3063\u307d\u3044\u8a18\u8ff0\u306f\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\n\u4ed5\u65b9\u304c\u7121\u3044\u306e\u3067\u300c<strong>getActiveWorkbook<\/strong>\u300d\u30e1\u30bd\u30c3\u30c9\u3092\u624b\u304c\u304b\u308a\u306bMSDN\u306e\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u3092\u8abf\u3079\u3066\u307f\u308b\u3068\u3001\u3061\u3083\u3093\u3068\u8a18\u8ff0\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">function ewaApplicationReady()\r\n{\r\n    \/\/ Get a reference to the EWA.\r\n    ewa = Ewa.EwaControl.getInstances().getItem(0);\r\n    \/\/ Display the Workbook path.\r\n    alert(ewa.getActiveWorkbook().getWorkbookPath());\r\n}<\/pre>\n<p>\u300c<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ee660085.aspx\" title=\"Ewa.EwaControl.getActiveWorkbook()\" target=\"_blank\">Ewa.EwaControl.getActiveWorkbook()<\/a>\u300d\u3088\u308a<\/p>\n<p>\u300c<span style=\"color: #ff0000; font-weight: bold;\">ewa = Ewa.EwaControl.getInstances().getItem(0);<\/span>\u300d\u3001\u3053\u306e\u90e8\u5206\u3067Ewa.EwaControl\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u5f97(EWA(Excel Web Access) Web \u30d1\u30fc\u30c4\u3078\u306e\u53c2\u7167\u3092\u53d6\u5f97)\u3057\u3066\u304a\u304b\u306a\u3044\u3068\u3044\u3051\u306a\u304b\u3063\u305f\u308f\u3051\u3067\u3059\u306d\u3002<br \/>\n\u305d\u308c\u3067\u306f\u6539\u3081\u3066\u30b3\u30fc\u30c9\u3092\u8cbc\u308a\u4ed8\u3051\u3001\u300c<strong>\u30af\u30ea\u30c3\u30af\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/strong>\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">&lt;input type=&quot;button&quot; value=&quot;\u30af\u30ea\u30c3\u30af\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot; onclick=&quot;execute();&quot;&gt;&lt;\/input&gt;\r\n&lt;script type=&quot;text\/javascript&quot; src=&quot;http:\/\/r.office.microsoft.com\/r\/rlidExcelWLJS?v=1&amp;kip=1&quot;&gt;&lt;\/script&gt;\r\n&lt;script type=&quot;text\/javascript&quot;&gt;\r\n    \/\/ run the Excel load handler on page load\r\n    if (window.attachEvent) {\r\n        window.attachEvent(&quot;onload&quot;, loadEwaOnPageLoad);\r\n    } else {\r\n        window.addEventListener(&quot;DOMContentLoaded&quot;, loadEwaOnPageLoad, false);\r\n    }\r\n\r\n    function loadEwaOnPageLoad() {\r\n        var fileToken = &quot;SD92A165759188B352!264\/-7880906317294423214\/&quot;;\r\n        var props = {\r\n            item: &quot;'Sheet1'!A1:C3&quot;,\r\n            uiOptions: {\r\n                showDownloadButton: false,\r\n                showGridlines: false,\r\n                selectedCell: &quot;'Sheet1'!B2&quot;,\r\n                showParametersTaskPane: false\r\n            },\r\n            interactivityOptions: {\r\n                allowTypingAndFormulaEntry: false,\r\n                allowParameterModification: false,\r\n                allowSorting: false,\r\n                allowFiltering: false,\r\n                allowPivotTableInteractivity: false\r\n            }\r\n        };\r\n        Ewa.EwaControl.loadEwaAsync(fileToken, &quot;myExcelDiv&quot;, props, onEwaLoaded);\r\n    }\r\n\r\n    function onEwaLoaded() {\r\n        \/\/document.getElementById(&quot;loadingdiv&quot;).style.display = &quot;none&quot;;\r\n    }\r\n    \/\/ This sample gets the value in the highlighted cell. \r\n    \/\/ Try clicking on different cells then running the sample.\r\n\r\n    function execute() {\r\n        ewa = Ewa.EwaControl.getInstances().getItem(0);\r\n        \/\/ Get unformatted range values (getValuesAsync(1,...) where 1 = Ewa.ValuesFormat.Formatted)\r\n        ewa.getActiveWorkbook().getActiveCell().getValuesAsync(1, getRangeValues, null);\r\n    }\r\n\r\n    function getRangeValues(asyncResult) {\r\n        \/\/ Get the value from asyncResult if the asynchronous operation was successful.\r\n        if (asyncResult.getCode() == 0) {\r\n            \/\/ Get the value in active cell (located at row 0, column 0 of the\r\n            \/\/ range which consists of a single cell (the &quot;active cell&quot;)).\r\n            alert(&quot;Result: &quot; + asyncResult.getReturnValue()&#x5B;0]&#x5B;0]);\r\n        } else {\r\n            alert(&quot;Operation failed with error message &quot; + asyncResult.getDescription() + &quot;.&quot;);\r\n        }\r\n    }\r\n&lt;\/script&gt;\r\n&lt;div id=&quot;myExcelDiv&quot; style=&quot;width: 300px; height: 100px&quot;&gt;&lt;\/div&gt;<\/pre>\n<p><a href=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Ewa2_01.png\"><img loading=\"lazy\" decoding=\"async\" src=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Ewa2_01-300x222.png\" alt=\"\" title=\"Ewa2_01\" width=\"300\" height=\"222\" class=\"alignnone size-medium wp-image-1044\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Ewa2_01-300x222.png 300w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Ewa2_01-290x214.png 290w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Ewa2_01-150x111.png 150w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Ewa2_01.png 490w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>alert\u3067\u30a2\u30af\u30c6\u30a3\u30d6\u30bb\u30eb\u306e\u5024\u300c<strong>Hello, world!<\/strong>\u300d\u304c\u8868\u793a\u3055\u308c\u3001\u4eca\u5ea6\u306f\u4e0a\u624b\u304f\u3044\u304d\u307e\u3057\u305f\u3002<br \/>\n\u3053\u308c\u3067\u4f55\u3068\u306a\u304fJavaScript\u306b\u3088\u308b\u30d6\u30c3\u30af\u64cd\u4f5c\u304c\u63b4\u3081\u3066\u304d\u307e\u3057\u305f\u3002<\/p>\n<p><input type=\"button\" value=\"\u30af\u30ea\u30c3\u30af\u3057\u3066\u304f\u3060\u3055\u3044\u3002\" onclick=\"execute();\"><\/input><br \/>\n<script type=\"text\/javascript\" src=\"http:\/\/r.office.microsoft.com\/r\/rlidExcelWLJS?v=1&#038;kip=1\"><\/script><br \/>\n<script type=\"text\/javascript\">\n    \/\/ run the Excel load handler on page load\n    if (window.attachEvent) {\n        window.attachEvent(\"onload\", loadEwaOnPageLoad);\n    } else {\n        window.addEventListener(\"DOMContentLoaded\", loadEwaOnPageLoad, false);\n    }<\/p>\n<p>    function loadEwaOnPageLoad() {\n        var fileToken = \"SD92A165759188B352!264\/-7880906317294423214\/\";\n        var props = {\n            item: \"'Sheet1'!A1:C3\",\n            uiOptions: {\n                showDownloadButton: false,\n                showGridlines: false,\n                selectedCell: \"'Sheet1'!B2\",\n                showParametersTaskPane: false\n            },\n            interactivityOptions: {\n                allowTypingAndFormulaEntry: false,\n                allowParameterModification: false,\n                allowSorting: false,\n                allowFiltering: false,\n                allowPivotTableInteractivity: false\n            }\n        };\n        Ewa.EwaControl.loadEwaAsync(fileToken, \"myExcelDiv\", props, onEwaLoaded);\n    }<\/p>\n<p>    function onEwaLoaded() {\n        \/\/document.getElementById(\"loadingdiv\").style.display = \"none\";\n    }\n    \/\/ This sample gets the value in the highlighted cell. \n    \/\/ Try clicking on different cells then running the sample.<\/p>\n<p>    function execute() {\n        ewa = Ewa.EwaControl.getInstances().getItem(0);\n        \/\/ Get unformatted range values (getValuesAsync(1,...) where 1 = Ewa.ValuesFormat.Formatted)\n        ewa.getActiveWorkbook().getActiveCell().getValuesAsync(1, getRangeValues, null);\n    }<\/p>\n<p>    function getRangeValues(asyncResult) {\n        \/\/ Get the value from asyncResult if the asynchronous operation was successful.\n        if (asyncResult.getCode() == 0) {\n            \/\/ Get the value in active cell (located at row 0, column 0 of the\n            \/\/ range which consists of a single cell (the \"active cell\")).\n            alert(\"Result: \" + asyncResult.getReturnValue()[0][0]);\n        } else {\n            alert(\"Operation failed with error message \" + asyncResult.getDescription() + \".\");\n        }\n    }\n<\/script><\/p>\n<div id=\"myExcelDiv\" style=\"width: 300px; height: 100px\"><\/div>\n","protected":false},"excerpt":{"rendered":"\u524d\u56de\u306e\u8a18\u4e8b\u3067\u3001JavaScript\u30b3\u30fc\u30c9\u3092\u8cbc\u308a\u4ed8\u3051\u3066Excel\u30ef\u30fc\u30af\u30d6\u30c3\u30af\u3092Web\u30da\u30fc\u30b8\u306b\u57cb\u3081\u8fbc\u3080\u3068\u3053\u308d\u307e\u3067\u78ba\u8a8d\u3057\u307e\u3057\u305f\u3002 \u4eca\u56de\u306f\u3044\u3088\u3044\u3088\u8cbc\u308a\u4ed8\u3051\u305f\u30d6\u30c3\u30af\u3092JavaScript\u3067\u64cd\u4f5c\u3057\u3066\u307f\u307e\u3059\u3002","protected":false},"author":1,"featured_media":7111,"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":[4,41],"tags":[38,39,40,140],"class_list":["post-1040","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-office","category-excel-services-ecmascript","tag-office-web-apps","tag-excel-web-app","tag-excelmashup","tag-excel-services-ecmascript"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-Excel.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-gM","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1040","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=1040"}],"version-history":[{"count":10,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1040\/revisions"}],"predecessor-version":[{"id":1052,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1040\/revisions\/1052"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7111"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1040"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1040"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}