javascript - 无法从 office 365 word online 中的 word 表中检索内容控制
问题描述
我们有一个产品支持 O365 windows 和 mac 使用 office js。现在在同一产品上,我们将在线支持 O365 word。在我们的工作中,我们发现 O365 windows 和 word online 存在一个差异。我们有一个文档,它在内容控件内有一个单词表。
在word online中,我们无法检索word表内的内容控件,但是,我们可以检索O365 windows和mac桌面中的所有内容控件。
以下代码片段在 O365 窗口和 mac 中正常工作,但在 word 在线中不工作。
$("#run").click(() => tryCatch(run));
function run() {
return Word.run(function (context) {
var contentControls = context.document.contentControls
context.load(contentControls, "id,text,title,tag,placeholderText");
return context.sync().then(function () {
/*console.log('The selected text was "' + contentControls.items.length + '".');*/
contentControls.items.forEach((contentControl: Word.ContentControl) => {
console.log('The Content control id "' + contentControl.id + '".');
});
});
});
}
/** Default helper for invoking an action and handling errors. */
function tryCatch(callback) {
Promise.resolve()
.then(callback)
.catch(function (error) {
// Note: In a production add-in, you'd want to notify the user through your add-in's UI.
console.error(error);
});
}
解决方案
推荐阅读
- c++ - 为什么这个 Lambda 会编译?
- javascript - 从另一个函数设置组件的状态
- php - 未捕获的 mysqli_sql_exception:您的 SQL 语法有错误;检查与您的 MariaDB 服务器版本相对应的手册以获取正确的
- python - 如何使用pandas python根据给定的IP地址将大型excel文件拆分为多个工作表
- php - Laravel 上的“此集合实例上不存在属性 [titulo]”错误
- javascript - 如何使用两个 Json 数据呈现 HTML 表格
- javascript - 使用 JavaScript 控制文件的限制
- excel - 将多个工作表合并为一个工作表
- google-apps-script - 在其他单元格中的特定时间自动锁定/保护 Google 表格中的行/单元格
- c# - Specflow 设计器生成的代码使用旧的 specFlow 1.9.0.77