ソース(TestApp_NameSet.html)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js"></script>
<script src="https://appsforoffice.microsoft.com/lib/1.0/hosted/office.js"></script>
<script>
Office.initialize = function (reason) {
$('#msgline').html('done !');
$(document).ready(function () {
$('#execbtn').click(function(){
var docUrl = 'https://spreadsheets.google.com/feeds/cells/' +
$('#dockey').val() +
'/od6/public/basic/' +
$('#doccell').val() +
'?alt=json-in-script';
$.ajax({
url : docUrl,
dataType : 'jsonp',
jsonp : 'callback',
beforeSend:function(xhr){
$('#msgline').html('getting from Google ...');
},
success : function(data, status){
$('#msgline').html('done !');
if(data.entry.content.type == 'text')
Office.context.document.setSelectedDataAsync(data.entry.content.$t);
},
error : function(){
$('#msgline').html('error.');
}
});
});
});
};
</script>
</head>
<body>
<div style="font-weight:bold">Google Data Picker</div>
<p>
公開している Google Spreadsheet からデータを取得し、
選択中のセルに挿入します</p>
<div>
Document key:
<input type="text" id="dockey" /><br />
Cell number:
<input type="text" id="doccell" value="R1C1" /><br />
<input type="button" id="execbtn" value="Execute !" />
</div>
<p id="msgline" style="background-color:gray;">initializing ...</p>
</body>
</html>
マニュフェストファイル
<?xml version="1.0" encoding="UTF-8"?>
<!--Created:cb85b80c-f585-40ff-8bfc-12ff4d0e34a9-->
<OfficeApp
xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="ContentApp">
<Id>8CFD3187-0DA1-4665-8442-BC35F5432557</Id>
<Version>1.0.0.0</Version>
<ProviderName>Subaru Kokubun</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="TestApp" />
<Description DefaultValue="This is a test app."/>
<Hosts>
<Host Name="Workbook" />
</Hosts>
<DefaultSettings>
<SourceLocation DefaultValue="http://localhost/TestApp_NameSet.html" />
<RequestedWidth>400</RequestedWidth>
<RequestedHeight>400</RequestedHeight>
</DefaultSettings>
<Permissions>ReadWriteDocument</Permissions>
</OfficeApp>