Excel Office 2016 JavaScript API-删除表过滤器按钮
在Office 2013版本的Office Javascript API中,我将创建一个如下表:Excel Office 2016 JavaScript API-删除表过滤器按钮,excel,office365,office-addins,office-js,Excel,Office365,Office Addins,Office Js,在Office 2013版本的Office Javascript API中,我将创建一个如下表: Office.context.document.setSelectedDataAsync( tbl, { coercianType: Office.CoercionType.Table, cellFormat: tableCellFormats, ta
Office.context.document.setSelectedDataAsync(
tbl, {
coercianType: Office.CoercionType.Table,
cellFormat: tableCellFormats,
tableOptions: { filterButton: false }
});
现在有了将范围转换为表的新方法,我遗漏了一件事。也就是说,如何在关闭过滤器按钮的情况下创建它。我没有看到Table.options属性,可以在其中设置filterbutton=false。(请参见下面的代码片段):
有人可以发布一个javascript代码片段来说明如何做到这一点吗?事实证明,我可以使用绑定来实现这一点。代码如下。我在Excel.Run中添加了一个.then(),以便在创建表之后,我可以获得添加绑定并设置表选项:
.then(function (ctx) {
Office.context.document.bindings.
addFromNamedItemAsync('tblRawEmpInfo', Office.BindingType.Table,
{ id: "tblRawEmpInfoBinding" }, function (asyncResult) {
if (asyncResult.status != Office.AsyncResultStatus.Failed) {
Office.select("bindings#tblRawEmpInfoBinding").setTableOptionsAsync({ filterButton: false });
return ctx.sync();
}
else
return ctx.sync();
});
希望这对某些人有所帮助,我不得不说,这个javascript api似乎正在进行中。我认为应该添加Table.options属性,我会将此注释添加到github站点。好吧,这很奇怪,但现在我有了多个表,即使绑定附加到了正确的表,设置应用于工作簿中第一个表的选项,而不是我绑定的表。奇怪。回到绘图板上。这可能是一只虫子吗?
.then(function (ctx) {
Office.context.document.bindings.
addFromNamedItemAsync('tblRawEmpInfo', Office.BindingType.Table,
{ id: "tblRawEmpInfoBinding" }, function (asyncResult) {
if (asyncResult.status != Office.AsyncResultStatus.Failed) {
Office.select("bindings#tblRawEmpInfoBinding").setTableOptionsAsync({ filterButton: false });
return ctx.sync();
}
else
return ctx.sync();
});