Word用の.NET MVCプロジェクトがオンラインです。アドインは正常に起動しますが、Office.initializeを呼び出してWordの本文にデータを挿入する "Home.js"は読み込まれません。Office.js関数がWord OnlineのMVCアプリケーションで動作しない
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
@Styles.Render("~/bundles/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body ng-app="">
<div class="container">
@RenderBody()
</div>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/Scripts/Office/1/office.js")
@Scripts.Render("~/Scripts/Home.js")
@Scripts.Render("~/bundles/bootstrap")
@Scripts.Render("~/Scripts/angular.min.js")
</body>
</html>
そしてHome.js:ここ
は_Layout.cshtmlある
(function() {
"use strict";
Office.initialize = function (reason) {
$(document).ready(function() {
if (!Office.context.requirements.isSetSupported('WordApi', '1.1')) {
return;
}
loadSampleData();
});
};
function loadSampleData() {
// Run a batch operation against the Word object model.
Word.run(function (context) {
// Create a proxy object for the document body.
var body = context.document.body;
// Queue a commmand to clear the contents of the body.
body.clear();
// Queue a command to insert text into the end of the Word document body.
body.insertText("This is a sample text inserted in the document",
Word.InsertLocation.end);
// Synchronize the document state by executing the queued commands, and return a promise to indicate task completion.
return context.sync();
})
.catch(errorHandler);
}
function errorHandler(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
}
})();
ありがとうございました。
また、角度ブートストラップの問題についてもお答えしたいと思います。私はアプリケーションの角度を完全に取り除こうとしましたが、問題は解決しません。 – michaelmilone
home.jsの読み込みはまったくですか?つまり、一番上にconsole.logを置くと、それは印刷されますか?はいの場合、console.logをOffice.initialzeの最初の行に置くと印刷されますか?返信ありがとうございます。 –
はい、印刷されます。 – michaelmilone