【问题标题】:Office 2016 JavaScript API - Remove Table Filter ButtonsOffice 2016 JavaScript API - 删除表格筛选器按钮
【发布时间】:2016-02-04 15:52:54
【问题描述】:

在 Office Javascript API 的 Office 2013 版本中,我将创建如下表:

Office.context.document.setSelectedDataAsync(
   tbl, {
                        coercianType: Office.CoercionType.Table,
                        cellFormat: tableCellFormats,
                        tableOptions: { filterButton: false }
          });

现在有了将范围转换为表格的新方法,我缺少一件事。也就是说,如何在关闭过滤器按钮的情况下创建它。我没有看到可以设置 filterbutton = false 的 Table.options 属性。 (见下面的sn-p):

Excel.run(function (ctx) {
    ctx.workbook.tables.add('Sheet1!A1:E7', true);
    return ctx.sync();
}).catch(function (error) {
    console.log(error);
});

有人可以发布一个关于如何做到这一点的 javascript sn-p 吗?

【问题讨论】:

    标签: excel office365 office-addins office-js


    【解决方案1】:

    事实证明,我能够使用绑定来完成此操作。代码如下。我在 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 站点。

    【讨论】:

    • 好吧,这很奇怪,但现在我有多个表,即使绑定附加到正确的表,设置选项应用于工作簿中的第一个表,而不是我所在的表也绑定。奇怪的。回到绘图板。这可能是一个错误吗?
    猜你喜欢
    • 2017-01-16
    • 2017-03-16
    • 1970-01-01
    • 1970-01-01
    • 2021-12-17
    • 2013-12-10
    • 1970-01-01
    • 2012-07-18
    相关资源
    最近更新 更多