【问题标题】:Two open taskpanes side by side两个并排打开的任务窗格
【发布时间】:2017-07-04 03:38:36
【问题描述】:

我正在制作一个具有两个功能区按钮的 Office 加载项。每个按钮都链接到不同的TaskpaneId,单击每个按钮会打开不同的任务窗格:

<bt:Urls>
    <bt:Url id="Contoso.Taskpane1.Url" DefaultValue="https://localhost:3000/addin/page1" />
    <bt:Url id="Contoso.Taskpane2.Url" DefaultValue="https://localhost:3000/addin/page2" />
</bt:Urls>

我似乎看到过一些 Office 加载项,其中两个任务窗格可以同时并排显示(我忘记了加载项到底是哪个)。我有时需要这个,有谁知道如何实现这个?

【问题讨论】:

    标签: ms-office office-js office-addins office-app


    【解决方案1】:

    Script Lab 就是这样的插件之一。您需要做的就是创建两个不同的按钮,它们有一个ShowTaskpane 操作和不同的ID。

    来自 Script Lab 的产品清单的示例:https://github.com/OfficeDev/script-lab/blob/master/manifests/script-lab-prod.xml

                <Control xsi:type="Button" id="PG.CodeCommand">
                  <Label resid="PG.CodeCommand.Label" />
                  <Supertip>
                    <Title resid="PG.CodeCommand.TipTitle" />
                    <Description resid="PG.CodeSupertip.Desc" />
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="PG.Icon.Code.16" />
                    <bt:Image size="32" resid="PG.Icon.Code.32" />
                    <bt:Image size="80" resid="PG.Icon.Code.80" />
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <TaskpaneId>Office.AutoShowTaskpaneWithDocument</TaskpaneId>  
                            <===== A taskpane ID. This one is a "special" one that allows the taskpane
                                   to auto-open if a document is marked as belonging to the add-in.
    
                    <SourceLocation resid="PG.Code.Url" />
                    <Title resid="PG.CodeCommand.Title" />
                  </Action>
                </Control>
                <Control xsi:type="Button" id="PG.RunCommand">
                  <Label resid="PG.RunCommand.Label" />
                  <Supertip>
                    <Title resid="PG.RunCommand.TipTitle" />
                    <Description resid="PG.RunSupertip.Desc" />
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="PG.Icon.Run.16" />
                    <bt:Image size="32" resid="PG.Icon.Run.32" />
                    <bt:Image size="80" resid="PG.Icon.Run.80" />
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                            <===== Whereas this one dosn't specify a taskpane ID,
                                   and so it is different by default (but probably
                                   should be explicit, come to think of it...)
    
                    <SourceLocation resid="PG.Run.Url" /> 
                    <Title resid="PG.RunCommand.Title" />
                  </Action>
                </Control>
    

    特别是关于自动打开,请参阅https://dev.office.com/docs/add-ins/design/automatically-open-a-task-pane-with-a-document。

    【讨论】:

    • 抱歉,Michael,它在 Excel Online 中有效吗?我不能在 Excel Online 中并排放置 Script Lab 的 2 个任务窗格...
    • 您不能将它们并排放置,但您会看到它们是垂直标签的。所以你实际上可以打开两个,只是一次只能看到一个。如果您想要更多的 UI 灵活性,我建议您在 officespdev.uservoice.com 上提出问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-19
    相关资源
    最近更新 更多