我想在Word Online中使用以下代码打开base64编码文件。无法在Word Online中打开远程文件
function displayContents(myBase64) {
Word.run(function (context) {
console.log(Office.context.requirements.isSetSupported("WordApi", "1.1"));
// Create a proxy object for the document.
var thisDocument = context.document;
// Queue a command to clear the body contents.
thisDocument.body.clear();
thisDocument.body.insertFileFromBase64(myBase64, "replace");
// Create a proxy object for the default selection.
//var mySelection = thisDocument.getSelection();
// Queue a command to insert the file into the current document.
//mySelection.insertFileFromBase64(myBase64, "replace");
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
return context.sync();
})
.catch(function (error) {
console.log('Error: ' + JSON.stringify(error));
if (error instanceof OfficeExtension.Error) {
console.log('Debug info: ' + JSON.stringify(error.debugInfo));
}
});
}
这不起作用(使用body.insertFileFromBase64或myselection.insertFileFromBase64)。该代码在Word的常规版本中起作用。我收到以下错误:
错误: “名”: “OfficeExtension.Error”, “代码”: “GeneralException”, “消息”: “此浏览器不支持请求的API。” “traceMessages”:[], “debuginfo软”:{}} LoadOfficeDoc.js:51调试信息:{}
Office.context.requirements.isSetSupported( “WordApi”, “1.1”)返回true。
我做错了什么或者这个功能在线不可用?
感谢您澄清胡安,这个功能是否会在网络版本中成为可能? –
绝对!它很快就要来了! –
此修复程序现在正在运行! Office.context.requirements.isSetSupported('WordApi',1.1)和Office.context.requirements.isSetSupported('WordApi',1.2)现在都返回false。 –