Reputation: 3526
How to programatically open a document using javascript office api ?
Is there a way to insert a document using javascript office api Or to get access to the document xml ? Something like this
Excel.run(function (ctx) {
var application = ctx.workbook.application;
application.load('newXmlWorkbook', worbookInXmlFormat);
return ctx.sync().then(function() {
console.log(application.calculationMode);
});
}).catch(function(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});
Upvotes: 3
Views: 4273
Reputation: 2668
In Word an add-in can insert an entire document with the Document.insertFileFromBase64() method.
In Excel this API isn't available. As an alternative, you can enable a download of the file instead of a replacement: for example, you can add an HTML link to the file and let the user download it or you can trigger the download yourself in JavaScript.
-Michael (PM for Office add-ins)
Upvotes: 3