2017-07-04 95 views
1

我制作了一个Office插件,其中有两个功能区按钮。每个按钮链接到不同的TaskpaneId,并点击每个按钮打开一个不同的taskpane:并排打开两个任务窗格

<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插件,其中两个任务窗格可以同时侧(我一起展示忘记了哪个加载项是)。我不时需要这个,有没有人知道如何实现这一点?

回答

0

Script Lab就是这样一个加载项。您只需创建两个不同的按钮,其中ShowTaskpane动作与不同的ID。从脚本实验室的督促清单

例子: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

+0

对不起迈克尔,它在Excel Online中工作吗?我不能在Excel Online中并排放置两个脚本实验室的任务栏... – SoftTimur

+0

您不能将它们并排放置,但您会看到它们是垂直选项卡。所以你实际上可以打开两个,只是一次只能看到一个。如果你想要更多的UI灵活性,我建议你在https://officespdev.uservoice.com/上提出问题 –