Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programatically open a excel document using javascript office api

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));
        }
});
like image 685
Nicu Avatar asked Aug 07 '26 08:08

Nicu


1 Answers

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)

like image 155
Michael Saunders Avatar answered Aug 08 '26 22:08

Michael Saunders



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!