Ich habe ein .NET MVC-Projekt für Word online. Das Add-In wird erfolgreich gestartet, aber es lädt nicht "Home.js", das Office.initialize aufruft, um Daten in den Wortkörper einzufügen. HierOffice.js Funktion funktioniert nicht in MVC-Anwendung für Word Online
ist _Layout.cshtml:
<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>
Und Home.js:
(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));
}
}
})();
Danke.
Ich möchte auch das eckige Bootstrapping-Problem kommentieren. Ich habe versucht, Winkel der Anwendung vollständig herauszunehmen, und das Problem besteht weiter. – michaelmilone
Wird home.js überhaupt geladen? Wenn Sie zum Beispiel eine console.log an die Spitze stellen, wird es gedruckt? Wenn ja, wenn Sie eine console.log als erste Zeile in Office.initialze einfügen, wird es gedruckt? –
danke für die Antwort. Ja, es druckt. – michaelmilone