Excel 用の Copilot スキルを作成する (プレビュー)

カスタム スキルを作成して、AI エージェントと Excel 用 Copilot の複雑なタスクを実行できます。 必要に応じて、これらのスキルで Office JavaScript ライブラリ (Office.js) を使用できます。

注:

Excel のカスタム スキルはプレビュー段階です。 運用スキルでは使用しないでください。

スキルを作成するための主なガイダンスは、「Copilot Cowork用プラグインをビルドする」にあります。 この記事のコンテキストは Microsoft Coworkを参照していますが、ガイダンスは通常、Copilot で実行されているエージェントに接続できるすべてのカスタム スキルに適用されます。

ビルド 内容」セクションから始めて、「 プラグインをゼロからビルドする」に進みます。

この記事では、Office.js を使用して Excel ブックを操作するスキルを作成するための補足ガイダンスのみを提供します。

手順 1 の補足

手順 1: 最初のスキルを作成するを補完するには、次の手順に従います。

  1. SKILL.md ファイルの YAML フロントマッターには、excel タグを含む metadata.tags プロパティと、必要に応じてその他のタグを含めます。 次に例を示します。

    name: my-excel-skill
    description: |
      Use this skill in Excel to ... 
    metadata:
      version: 1.0.0
      tags: excel
    
  2. ほとんどの Excel スキルでは、出力は、チャットや CLI インターフェイスではなくブックに含める必要があります。 そのため、 SKILL.md ファイルの [出力形式] セクションの代わりに、[ブックの出力] セクションがあります。 次に例を示します。

    ## Workbook output
    
    Produce a dashboard sheet with the following characteristics:
    
    - It should be named "My Skill Output".
    - ... other characteristics here.
    
  3. SKILL.mdに「避ける一般的な落とし穴」セクションを含めます。 次に例を示します。

    ## Common pitfalls to avoid
    
    - Do not search broadly for unrelated sheets or columns.
    - Do not invent missing data.
    - Do not claim to be finished when the current environment can't update the workbook.
    

手順 2 の補足

  1. Office.js で API を呼び出し、スキルの \scripts フォルダーに配置する JavaScript スクリプトを作成します。 各スクリプトは、ユーザーまたはエージェントからのそれ以上の操作を行わずに、完了まで実行する必要があります。 任意の Office.js API を呼び出すことができますが、通常、スクリプトは、次の編集された例のように、 Excel.runの単一の非同期呼び出しで構成されます。

    await Excel.run(async (context) => {
       ...
       await context.sync();
    });
    

    重要

    スクリプトは、Office.onReadyを呼び出したり、Office.initializeを定義したりしないでください。 Excel の Copilot では、ランタイムが自動的に作成され、Office.js が初期化されます。

  2. スキルがブックと対話する方法にいくつかの境界を課すリソースとして、2 つのマークダウン ファイルを含めます。

    1. 最初のリソースでは、スキルが出力を追加する前に、既存のブックをクリーンアップまたは正規化する方法について説明する必要があります。 これらの手順は、一般的な Excel のベスト プラクティスではなく、スキルが対処するシナリオに固有です。 次の例は、2 つのアメリカの大学間の運動的なライバル関係に関するデータを含むダッシュボードを作成するスキルの例です。

      # Workbook data guardrails
      
      Use this reference to improve data quality before the scenario skill generates an output.
      
      ## Core principles
      
      - Start from workbook labels already present in the workbook.
      - Search only for the exact missing sheet or column names the scenario needs.
      - Ask precise questions instead of inventing scores, quotes, colors, or team metadata.
      
      ## Search rules
      
      - Prefer exact names such as `Game Results`, `Player Stats`, `Team Stats`, `Quotes Colors`, `Team Profiles`, `Roster Recruiting`, or `Opponent PPG`.
      - If a required field is missing, ask for the exact replacement label instead of broad keyword guesses.
      - Stop searching once the needed data for this scenario is located.
      
      ## Organization playbook
      
      - If the workbook is messy, ask the user to rename sheets or headers before analysis.
      - Use one sheet for game results, one for player or team stats, and one for branding or quotes when possible.
      - Don't assume one table can serve multiple scenarios.
      
      ## Quality checks
      
      - Confirm the selected school, season range, metric choice, and other custom hooks before generating output.
      - Keep caveats visible for limited games, freshman samples, or incomplete rows.
      - Label synthetic rows clearly when they are used.
      
      
    2. 2 番目のリソースでは、次の操作を行う必要があります。

      • スキルを使用するときに Copilot が常に従う必要がある一般的な品質規則を提供します。
      • スキルのスクリプトを呼び出すタイミングと、呼び出すべきではないタイミングについて説明します。
      • ユーザーが Excel の外部で Copilot でスキルを呼び出した場合の対処方法を説明し、実行しないでください。

      次に例を示します。

      # Excel vs non-Excel execution guidance
      
      ## When the skill runs inside Excel
      
      - Prefer workbook-native ranges, named tables, and Office.js helpers already available in the current session.
      - Keep the output focused on workbook changes, sheet creation, chart updates, and branded formatting.
      - Use the workbook as the primary source of truth.
      
      ## When the skill runs outside Excel
      
      - Treat the workbook as a data file and provide the exact next steps, schema assumptions, and missing inputs.
      - Avoid claiming that charts or sheets were completed unless the current environment can perform the action.
      - Ask the user to open the workbook in Excel or provide the exact labels needed for the scenario.
      
      ## Quality checks for either environment
      
      - Confirm the execution mode before generating output.
      - State clearly what was completed and what still needs user or workbook action.
      - Never invent missing data or pretend a workbook update succeeded.
      
      ## When to use the scripts folder
      
      - Run `scripts/my-first-script.js` when, and only when, the user asks for ... 
      - Run `scripts/another-script.js` when, and only when, the user asks for ...
      - Use these scripts after the workbook context is ready for shape and sheet generation, not during an analysis-only pass.
      - If the current environment is outside Excel, explain the workbook steps and do not attempt to execute the Office.js scripts.
      

手順 4 の補足

  1. スキルは Office.js から API を呼び出しますが、マニフェストに "extensions" セクションは必要ありません。 Excel の Copilot は、ランタイムを自動的に作成し、Office.js を読み込み、スキルでスクリプトを実行します。

    注:

    ランタイムは "extensions" 要素で明示的に構成されていないため、マニフェストには "extensions.requirements.capabilities" キーがないため、ランタイムを特定の要件セットをサポートする Excel のバージョンに制限する方法はありません。 ユーザーのチャネルが、スキルのスクリプトで呼び出される API をサポートしていない Excel のバージョンを持っている可能性は低いですが、理論的には可能です。 このような呼び出しの効果は未定義です。

  2. スキル プラグインは Microsoft 365 用のアプリであり、Microsoft 365 用の統合マニフェストとパッケージで実装されているため、カスタム スキルを、Teams タブや Office アドインなど、Microsoft 365 用の他の種類のアプリと同じマニフェストとパッケージに含めることができます。 ただし、スキル スクリプトはオンラインでホストされていないアプリ パッケージ内にあるため、スキルと他のアプリの間で Office.js コードを共有することはできません。 スキルと他のアプリの両方で実行する必要がある場合は、2 つ以上のファイルでコードを複製する必要があります。

手順 7 の補足

各テスト セッションの後にスキルをクリーンアンインストールすることが重要です。 次の手順に従ってください。

  1. Teams を開き、スキルのインストールに使用した資格情報と同じ資格情報でサインインしていることを確認します。
  2. [アプリ] ボタンを選択します。プラス記号がボックスに表示されます。
  3. [ アプリ ] ウィンドウで、[ アプリの管理] を選択します。
  4. アプリの一覧でアドインを見つけます。 SKILL.md ファイルの YAML frontmatter の name プロパティに指定された名前があります。
  5. アプリの一覧からアドインを選択して、その行を展開します。
  6. ごみ箱のアイコンを選択し、プロンプトで [削除 ] を選択します。