使用JavaScript Office API以编程方式打开Excel文档 [英] Programatically open a excel document using javascript office api

查看:653
本文介绍了使用JavaScript Office API以编程方式打开Excel文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用javascript office API以编程方式打开文档?

How to programatically open a document using javascript office api ?

是否可以使用javascript office api插入文档,还是可以访问文档xml?像这样

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));
        }
});

推荐答案

在Word中,加载项可以使用

In Word an add-in can insert an entire document with the Document.insertFileFromBase64() method.

在Excel中,此API不可用.或者,您可以启用文件下载而不是替代文件的下载:例如,您可以向文件添加HTML链接,然后让用户下载它,也可以使用JavaScript触发下载.

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(Office加载项的PM)

-Michael (PM for Office add-ins)

这篇关于使用JavaScript Office API以编程方式打开Excel文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆