哪些版本的 Office 2016 支持 Office.context.reqirements.isSetSupported()?
What versions of Office 2016 support Office.context.reqirements.isSetSupported()?
我们正在 运行ning Office 2016 16.0.6741.2063(延迟频道),分配 Office 365 API 工作正常(一些关于使用 docx 插入等的问题,但是 XML很好)
但是这段代码总是到 "blockUI and warning (if I take out (not) "!",那么就没问题了,所以在其余代码中不是错误)。
'WordApi' 以任何形式或形式失败(1.2,无版本,1、0.1 - 我都试过了!)
根据规范 2016 应该支持这个,但延迟通道似乎不支持?
关于如何制作这个的任何想法 运行(或在 JavaScript 中查找 office 版本的任何其他提示)
团队中的一些人使用的是 Office 15..n 版本,我正试图以此来提醒他们升级到 16..n 以减轻支持负担!
Office.initialize = function (reason) {
$(document).ready(function () {
if (! Office.context.requirements.isSetSupported('WordApi', 1.1)){
$.blockUI({message: "This Add-In only works with versions of Office 365 greater than 16, please ring the help doesk to get your version upgraded <br/><a href='https://www.office.com/1?auth=2&home=1&from=ShellLogo'><u>Or click here for Office 365</u></a>"});
}
else {
// If setSelectedDataAsync method is supported by the host application
// the UI buttons are hooked up to call the method else the buttons are removed
if (Office.context.document.setSelectedDataAsync) {
ExecuteOrDelayUntilScriptLoaded(addDocsAsYouGo, "sp.js");
ExecuteOrDelayUntilScriptLoaded(addDocsAsYouGoDefr, "sp.js");
if(!siteInitialised){
initialiseSharePointConnection();
}
if (!pathInitiliased){
clientContext.executeQueryAsync(function () {
filePath = oWebsite.get_serverRelativeUrl() + "/Shared Documents/addin/ContentDOCX/";
pathInitiliased = true;
});
}
}
}
});
};
启用插件的客户端的所有版本都支持此功能(即 2013、2016、Mac、在线等)您必须同意这会很讽刺(和 catch-22) 要求你知道你在哪个客户端,以便查询 API 将 [有效] 告诉你你在哪个客户端。
如果您没有看到此作品,请检查您使用的 Office.js 版本。添加 API 的方式追溯使其适用于 Office 2013(出厂时没有这个),但您必须使用最新(或接近)版本的 Office.js。引用 CDN 将是保证这一点的最佳方式。
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/Office.js" type="text/javascript"></script>
我找到了从 Word API 中提取 "feature" 列表的方法。
使用 div "id=resultpanel" 进行输出,这段代码为我提供了功能集:
Office.initialize = function (reason) {
$(document).ready(function () {
var sets = Office.context.requirements._setMap._sets;
for (var set in sets){
showNotification("Set type: " + set + " value " +sets[set] );
}
//if (! Office.context.requirements.isSetSupported('WordApi', 1.1)) {
//if ( Office.context.requirements.isSetSupported('WordApi', 1.2)){
// alert something
//}
//else {
// If setSelectedDataAsync method is supported by the host application
// the UI buttons are hooked up to call the method else the buttons are removed
if (Office.context.document.setSelectedDataAsync) {
ExecuteOrDelayUntilScriptLoaded(addDocsAsYouGo, "sp.js");
ExecuteOrDelayUntilScriptLoaded(addDocsAsYouGoDefr, "sp.js");
if(!siteInitialised){
initialiseSharePointConnection();
}
if (!pathInitiliased){
clientContext.executeQueryAsync(function () {
filePath = oWebsite.get_serverRelativeUrl() + "/Shared Documents/DOCXApproved/";
pathInitiliased = true;
});
}
}
//}
});
};
function showNotification(content) {
var resultpanel = document.getElementById("resultpanel");
var currentText = resultpanel.innerHTML;
currentText = currentText + "<br/>" + content;
resultpanel.innerHTML = currentText;
}
Office 365 在线版 Word 的输出为:
Set type: compressedfile value 1.1
Set type: documentevents value 1.1
Set type: file value 1.1
Set type: imagecoercion value 1.1
Set type: matrixcoercion value 1.1
Set type: ooxmlcoercion value 1.1
Set type: pdffile value 1.1
Set type: selection value 1.1
Set type: settings value 1.1
Set type: tablecoercion value 1.1
Set type: textcoercion value 1.1
Set type: textfile value 1.1
从 Word 桌面客户端版本 16.0.6741.2063 我得到:
Set type: compressedfile value 1.1
Set type: customxmlparts value 1.2
Set type: documentevents value 1.1
Set type: file value 1.1
Set type: htmlcoercion value 1.1
Set type: imagecoercion value 1.1
Set type: matrixbindings value 1.1
Set type: matrixcoercion value 1.1
Set type: ooxmlcoercion value 1.1
Set type: pdffile value 1.1
Set type: selection value 1.1
Set type: settings value 1.1
Set type: tablebindings value 1.1
Set type: tablecoercion value 1.1
Set type: textbindings value 1.1
Set type: textcoercion value 1.1
Set type: textfile value 1.1
Set type: wordapi value 1.3
Set type: wordapinewdoc value 1.2
使用此输出我可以决定在加载项上启用哪些功能!
然后用这个我也可以判断是Word在线还是桌面客户端
showNotification("url is: " + Office.context.document.url);
输出:
url is: https://<corp portal name>-my.sharepoint.com/personal/<my name>/Documents/Document15.docx
注意:企业门户名称和我的名字 将根据它所在的人和位置而改变 运行。文档 nn .docx 也发生了变化(它是添加到 OneDrive for business 的自动命名文件)。
在桌面客户端上这是空白。
我们正在 运行ning Office 2016 16.0.6741.2063(延迟频道),分配 Office 365 API 工作正常(一些关于使用 docx 插入等的问题,但是 XML很好)
但是这段代码总是到 "blockUI and warning (if I take out (not) "!",那么就没问题了,所以在其余代码中不是错误)。
'WordApi' 以任何形式或形式失败(1.2,无版本,1、0.1 - 我都试过了!) 根据规范 2016 应该支持这个,但延迟通道似乎不支持?
关于如何制作这个的任何想法 运行(或在 JavaScript 中查找 office 版本的任何其他提示)
团队中的一些人使用的是 Office 15..n 版本,我正试图以此来提醒他们升级到 16..n 以减轻支持负担!
Office.initialize = function (reason) {
$(document).ready(function () {
if (! Office.context.requirements.isSetSupported('WordApi', 1.1)){
$.blockUI({message: "This Add-In only works with versions of Office 365 greater than 16, please ring the help doesk to get your version upgraded <br/><a href='https://www.office.com/1?auth=2&home=1&from=ShellLogo'><u>Or click here for Office 365</u></a>"});
}
else {
// If setSelectedDataAsync method is supported by the host application
// the UI buttons are hooked up to call the method else the buttons are removed
if (Office.context.document.setSelectedDataAsync) {
ExecuteOrDelayUntilScriptLoaded(addDocsAsYouGo, "sp.js");
ExecuteOrDelayUntilScriptLoaded(addDocsAsYouGoDefr, "sp.js");
if(!siteInitialised){
initialiseSharePointConnection();
}
if (!pathInitiliased){
clientContext.executeQueryAsync(function () {
filePath = oWebsite.get_serverRelativeUrl() + "/Shared Documents/addin/ContentDOCX/";
pathInitiliased = true;
});
}
}
}
});
};
启用插件的客户端的所有版本都支持此功能(即 2013、2016、Mac、在线等)您必须同意这会很讽刺(和 catch-22) 要求你知道你在哪个客户端,以便查询 API 将 [有效] 告诉你你在哪个客户端。
如果您没有看到此作品,请检查您使用的 Office.js 版本。添加 API 的方式追溯使其适用于 Office 2013(出厂时没有这个),但您必须使用最新(或接近)版本的 Office.js。引用 CDN 将是保证这一点的最佳方式。
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/Office.js" type="text/javascript"></script>
我找到了从 Word API 中提取 "feature" 列表的方法。
使用 div "id=resultpanel" 进行输出,这段代码为我提供了功能集:
Office.initialize = function (reason) {
$(document).ready(function () {
var sets = Office.context.requirements._setMap._sets;
for (var set in sets){
showNotification("Set type: " + set + " value " +sets[set] );
}
//if (! Office.context.requirements.isSetSupported('WordApi', 1.1)) {
//if ( Office.context.requirements.isSetSupported('WordApi', 1.2)){
// alert something
//}
//else {
// If setSelectedDataAsync method is supported by the host application
// the UI buttons are hooked up to call the method else the buttons are removed
if (Office.context.document.setSelectedDataAsync) {
ExecuteOrDelayUntilScriptLoaded(addDocsAsYouGo, "sp.js");
ExecuteOrDelayUntilScriptLoaded(addDocsAsYouGoDefr, "sp.js");
if(!siteInitialised){
initialiseSharePointConnection();
}
if (!pathInitiliased){
clientContext.executeQueryAsync(function () {
filePath = oWebsite.get_serverRelativeUrl() + "/Shared Documents/DOCXApproved/";
pathInitiliased = true;
});
}
}
//}
});
};
function showNotification(content) {
var resultpanel = document.getElementById("resultpanel");
var currentText = resultpanel.innerHTML;
currentText = currentText + "<br/>" + content;
resultpanel.innerHTML = currentText;
}
Office 365 在线版 Word 的输出为:
Set type: compressedfile value 1.1
Set type: documentevents value 1.1
Set type: file value 1.1
Set type: imagecoercion value 1.1
Set type: matrixcoercion value 1.1
Set type: ooxmlcoercion value 1.1
Set type: pdffile value 1.1
Set type: selection value 1.1
Set type: settings value 1.1
Set type: tablecoercion value 1.1
Set type: textcoercion value 1.1
Set type: textfile value 1.1
从 Word 桌面客户端版本 16.0.6741.2063 我得到:
Set type: compressedfile value 1.1
Set type: customxmlparts value 1.2
Set type: documentevents value 1.1
Set type: file value 1.1
Set type: htmlcoercion value 1.1
Set type: imagecoercion value 1.1
Set type: matrixbindings value 1.1
Set type: matrixcoercion value 1.1
Set type: ooxmlcoercion value 1.1
Set type: pdffile value 1.1
Set type: selection value 1.1
Set type: settings value 1.1
Set type: tablebindings value 1.1
Set type: tablecoercion value 1.1
Set type: textbindings value 1.1
Set type: textcoercion value 1.1
Set type: textfile value 1.1
Set type: wordapi value 1.3
Set type: wordapinewdoc value 1.2
使用此输出我可以决定在加载项上启用哪些功能!
然后用这个我也可以判断是Word在线还是桌面客户端
showNotification("url is: " + Office.context.document.url);
输出:
url is: https://<corp portal name>-my.sharepoint.com/personal/<my name>/Documents/Document15.docx
注意:企业门户名称和我的名字 将根据它所在的人和位置而改变 运行。文档 nn .docx 也发生了变化(它是添加到 OneDrive for business 的自动命名文件)。
在桌面客户端上这是空白。