{"id":2456,"date":"2012-11-14T15:21:26","date_gmt":"2012-11-14T06:21:26","guid":{"rendered":"http:\/\/www.ka-net.org\/blog\/?p=2456"},"modified":"2013-05-29T11:22:43","modified_gmt":"2013-05-29T02:22:43","slug":"javascript-api-for-office%e3%83%89%e3%82%ad%e3%83%a5%e3%83%a1%e3%83%b3%e3%83%88%e3%82%92%e3%83%90%e3%82%a4%e3%83%88%e9%85%8d%e5%88%97%e3%81%a8%e3%81%97%e3%81%a6%e5%8f%96%e5%be%97%e5%be%8cbase64","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=2456","title":{"rendered":"[Office\u7528\u30a2\u30d7\u30ea]\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u30d0\u30a4\u30c8\u914d\u5217\u3068\u3057\u3066\u53d6\u5f97\u5f8cBase64\u30a8\u30f3\u30b3\u30fc\u30c9\u3059\u308b"},"content":{"rendered":"<p>Word\u3068PowerPoint\u304c\u5bfe\u8c61\u306b\u306a\u308a\u307e\u3059\u304c\u3001<span style=\"color: #ff0000; font-weight: bold;\">getFileAsync<\/span>\u30e1\u30bd\u30c3\u30c9\u306efileType\u30d1\u30e9\u30e1\u30fc\u30bf\u306b<span style=\"color: #ff0000; font-weight: bold;\">&#8220;compressed&#8221;<\/span>\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u30d0\u30a4\u30c8\u914d\u5217(OOXML\u30d5\u30a9\u30fc\u30de\u30c3\u30c8(docx,pptx))\u3068\u3057\u3066\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n    &lt;head&gt;\r\n        &lt;meta charset=&quot;UTF-8&quot;&gt;\r\n        &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=Edge&quot;&gt;\r\n        &lt;script src=&quot;http:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.7.2\/jquery.min.js&quot;&gt;&lt;\/script&gt;\r\n        &lt;script src=&quot;https:\/\/appsforoffice.microsoft.com\/lib\/1.0\/hosted\/office.js&quot;&gt;&lt;\/script&gt;\r\n        &lt;script&gt;\r\n            Office.initialize = function(reason){}\r\n            $(function(){\r\n                $(&quot;#btnOK&quot;).click(function(){\r\n                    \/\/1MB(1048576\u30d0\u30a4\u30c8)\u3054\u3068\u306b\u30b9\u30e9\u30a4\u30b9\u3057\u3066\u6587\u66f8\u3092\u53d6\u5f97\r\n                    Office.context.document.getFileAsync(&quot;compressed&quot;, {sliceSize:1048576}, function(result){\r\n                        if(result.status == &quot;succeeded&quot;){\r\n                            var myFile = result.value;\r\n                            $(&quot;#result&quot;).empty();\r\n                            $(&quot;#size&quot;).text(&quot;Size:&quot; + myFile.size + &quot;byte.&quot;);\r\n                            for (var i=0; i&lt;myFile.sliceCount; i++){\r\n                                myFile.getSliceAsync(i, function(result){\r\n                                    if(result.status == &quot;succeeded&quot;){\r\n                                        sendSlice(result.value);\r\n                                    }\r\n                                });\r\n                            }\r\n                            myFile.closeAsync(function(result){\r\n                                if(result.status == &quot;succeeded&quot;){\r\n                                    $(&quot;#status&quot;).text(&quot;Status:File closed.&quot;);\r\n                                } else {\r\n                                    $(&quot;#status&quot;).text(&quot;Status:File couldn't be closed.&quot;);\r\n                                }\r\n                            });\r\n                        }\r\n                    });\r\n                });\r\n            });\r\n            \r\n            function sendSlice(slice){\r\n                 var data = slice.data;\r\n                 if(data){\r\n                     $(&quot;#result&quot;).append('&lt;span&gt;index of the file slice:' + slice.index + '&lt;\/span&gt;&lt;br&gt;&lt;textarea rows=&quot;4&quot; cols=&quot;30&quot;&gt;' + OSF.OUtil.encodeBase64(data) + '&lt;\/textarea&gt;&lt;br&gt;');\r\n                 }\r\n            }\r\n        &lt;\/script&gt;\r\n    &lt;\/head&gt;\r\n    &lt;body&gt;\r\n        &lt;input id=&quot;btnOK&quot; type=&quot;button&quot; value=&quot;OK&quot;&gt;&lt;br&gt;\r\n        &lt;span id=&quot;size&quot;&gt;Size:&lt;\/span&gt;&lt;br&gt;\r\n        &lt;span id=&quot;status&quot;&gt;Status:&lt;\/span&gt;&lt;br&gt;\r\n        &lt;div id=&quot;result&quot;&gt;&lt;\/div&gt;\r\n    &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p><a href=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Office2013_29_01.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Office2013_29_01-300x178.jpg\" alt=\"\" title=\"Office2013_29_01\" width=\"300\" height=\"178\" class=\"alignnone size-medium wp-image-2457\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Office2013_29_01-300x178.jpg 300w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Office2013_29_01-290x172.jpg 290w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Office2013_29_01-150x89.jpg 150w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Office2013_29_01.jpg 858w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u4e0a\u8a18\u30b3\u30fc\u30c9\u3067\u306f<span style=\"color: #ff0000; font-weight: bold;\">sliceSize<\/span>\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u30b9\u30e9\u30a4\u30b9\u30b5\u30a4\u30ba\u30921MB\u306b\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u6307\u5b9a\u3057\u306a\u3044\u5834\u5408\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30b9\u30e9\u30a4\u30b9\u30b5\u30a4\u30ba4MB(4194304\u30d0\u30a4\u30c8)\u304c\u9069\u7528\u3055\u308c\u307e\u3059\u3002<br \/>\n\u307e\u305f\u3001\u4e0a\u8a18\u30b3\u30fc\u30c9\u3067\u306f\u53d6\u5f97\u3057\u305f\u30d0\u30a4\u30c8\u914d\u5217\u3092Base64\u30a8\u30f3\u30b3\u30fc\u30c9\u3057\u3066textarea\u306e\u5024\u3068\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u3053\u306e\u30a8\u30f3\u30b3\u30fc\u30c9\u3055\u308c\u305f\u5024\u3092\u30d0\u30a4\u30ca\u30ea\u5909\u63db\u3059\u308b\u3068\u3001\u4e0b\u56f3\u306e\u3088\u3046\u306bOOXML\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Office2013_29_02.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Office2013_29_02-300x178.jpg\" alt=\"\" title=\"Office2013_29_02\" width=\"300\" height=\"178\" class=\"alignnone size-medium wp-image-2458\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Office2013_29_02-300x178.jpg 300w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Office2013_29_02-290x172.jpg 290w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Office2013_29_02-150x89.jpg 150w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/Office2013_29_02.jpg 858w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><strong>\u30fbDocument.getFileAsync method (apps for Office)<\/strong><br \/>\n<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/office\/jj715284.aspx\" title=\"Document.getFileAsync method (apps for Office)\" target=\"_blank\">http:\/\/msdn.microsoft.com\/en-us\/library\/office\/jj715284.aspx<\/a><br \/>\n<strong>\u30fbFileType enumeration (apps for Office)<\/strong><br \/>\n<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/office\/jj220084.aspx\" title=\"FileType enumeration (apps for Office)\" target=\"_blank\">http:\/\/msdn.microsoft.com\/en-us\/library\/office\/jj220084.aspx<\/a><br \/>\n<strong>\u30fbFile.getSliceAsync method (apps for Office)<\/strong><br \/>\n<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/office\/jj715281.aspx\" title=\"File.getSliceAsync method (apps for Office)\" target=\"_blank\">http:\/\/msdn.microsoft.com\/en-us\/library\/office\/jj715281.aspx<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"Word\u3068PowerPoint\u304c\u5bfe\u8c61\u306b\u306a\u308a\u307e\u3059\u304c\u3001getFileAsync\u30e1\u30bd\u30c3\u30c9\u306efileType\u30d1\u30e9\u30e1\u30fc\u30bf\u306b&#8220;compressed&#8221;\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u30d0\u30a4\u30c8\u914d\u5217(OOXML\u30d5\u30a9\u30fc [&hellip;]","protected":false},"author":1,"featured_media":7119,"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":[130,4,79],"tags":[74,77],"class_list":["post-2456","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apps-for-office","category-office","category-office2013","tag-office-2013","tag-apps-for-office"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-OfficeAddins.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-DC","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2456","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=2456"}],"version-history":[{"count":6,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2456\/revisions"}],"predecessor-version":[{"id":3095,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2456\/revisions\/3095"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7119"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2456"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2456"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2456"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}