Office 加载项提示库是一组提示示例,可在开发 Office 加载项时与 GitHub Copilot 配合使用。GitHub Copilot是一个 AI 对程序员,可帮助你编写代码。 它作为许多代码编辑器(如 Visual Studio Code 和 Visual Studio)的扩展提供。 可以直接通过代码编辑器安装和启动扩展。
复制本文中的提示并将其输入到GitHub Copilot聊天中以开始试验。 还可以在代码编辑器中打开提示列表,方法是在 GitHub 上通过 Office 加载项提示GitHub Copilot从 GitHub 下载文件。
重要
本文中的提示旨在以英语与GitHub Copilot配合使用。 它们已经过测试,以确保 Copilot 返回相关的响应,但生成 AI 本质上可以返回可变响应。 在向用户发布或分发外接程序之前,请始终查看GitHub Copilot生成的代码的准确性。
我们建议你自定义自己的提示,以使用 GitHub Copilot 开发 Office 加载项。 若要向此提示库提供你的想法,请查看有关通过 GitHub 为 Office 加载项文档提供内容 的指导。 还可以通过 Office 加载项提示反馈中的调查共享提示和反馈。
提示示例
以下部分包含开发和发布加载项时针对多个方案的提示。
提示
在提示中切换出星号之间的短语,以试验相关方案。
入门指南
Show me the typical structure of an Office Add-in project and
explain the functionality of each file. Explain the steps and
commands to get started in *Visual Studio Code*.
创建加载项项目
将文档作为Word模板导入
Create an Office JavaScript add-in for *Word* to *import a
document as a template*. List the steps to follow in *Visual
Studio Code* to create the add-in and insert code snippets in
the correct files.
在 Excel 中创建自定义函数
Create an Office JavaScript Add-in for *Excel* to *create a
custom function in Excel*. List the steps to follow in *Visual
Studio Code* to create the add-in and insert code snippets in
the correct files.
在 PowerPoint 演示文稿幻灯片中插入图形
Create an Office JavaScript Add-in for *PowerPoint* to *insert
graphics into a presentation slide*. List the steps to follow in
*Visual Studio Code* to create the add-in and insert code snippets
in the correct files.
实现 Excel 加载项的功能
添加新的工作表
Add a new worksheet *at the end* using the Excel JavaScript API.
从表中获取数据
Retrieve the data in the range *A1:B3 on the first worksheet*
using the Excel JavaScript API.
创建图表
Insert a line chart titled *"My chart"* into the current worksheet
using the data *in the range A1:B3* using the Excel JavaScript API.
创建自定义函数以在 Excel 中执行计算
Create a JavaScript custom function in Excel that conducts a
calculation.
处理事件
Handle an event *when selection changes in worksheet* using
Excel JavaScript API.
创建形状
Create *a yellow square* shape in the worksheet using the Excel
JavaScript API.
将现有工作簿副本插入到当前工作簿中
Insert a workbook template as Base64 in the current workbook using
insertWorksheetsFromBase64 Excel JavaScript API.
实现Word加载项的功能
插入段落
Insert a paragraph with the content *"My paragraph"* at the start
of the document using the Word JavaScript API.
将样式应用于段落
Apply the style *"Heading1"* to the first paragraph in the document
using the Word JavaScript API.
更改字体
Change the font formatting of *the selected document text* using
the Word JavaScript API.
在文档中插入表格
Insert a table named "Sample table" with sample data in the
document using the Word JavaScript API.
插入内容控件
Insert a content control labeled *"Sample Content Control"* into the
first paragraph and *set the content control's color to red* using
the Word JavaScript API.
添加批注
Insert a comment into the document selection using the Word JavaScript API
将文档插入到目标文档中的特定位置
Import a file from local storage as a template to the current
document using the Word JavaScript insertFileFromBase64 API.
实现 Excel、PowerPoint 或Word加载项的功能
添加对话框
Show a dialog in the application *when a user clicks a button
in the add-in* using the Office JavaScript API.
获取访问令牌
Get an access token in an Office Add-in using the Office
JavaScript API to authenticate the user with external services
or APIs.
加载项发布指南
将加载项分发到组织
Tell me how to deploy and distribute the local Office JavaScript
add-in code to *all employees in my organization* after
development. Provide the steps to follow.
将加载项分发到外接程序存储
Tell me how to deploy and distribute the local Office JavaScript
add-in code to the *add-in store* after development. Provide the
steps to follow.