如何在 ChatGPT Codex 中使用 IronPPT

Curtis Chau
Curtis Chau
更新: 2026年10月19日

销售运营团队每周一发送相同的幻灯片。 模板提供幻灯片,周数据填充其中。 单个区域幻灯片变成每个区域一张,旧的促销幻灯片被移除,并且附录保留在文件中但不在幻灯片展示中。 当幻灯片操作无声失败时,幻灯片仍然会保存,作业日志仍然报告成功。 区域经理们继而收到一份截至6月30日的促销总结幻灯片,位于本周亮点前一张。

ChatGPT Codex是OpenAI的编码代理。 它在一个存储库中工作,编辑文件,运行如dotnet run这样的命令,并报告其更改。 同一代理运行在终端、IDE扩展、ChatGPT桌面应用和云上。 IronPPT 是 Iron Software 的.NET PowerPoint库,可以创建、打开、编辑和保存 .pptx 文件而无需 Microsoft Office。

Codex 得到一个每周销售模板、一个规则文件和两周的区域数据。 它报告的每个幻灯片计数均来自同一轮写入的 CSV,并且每个幻灯片操作在批处理代码依赖之前都在保存的幻灯片集上进行测试。

快速入门
NuGet使用NuGet安装

PM > Install-Package IronPPT

通过在 NuGet 包管理器控制台中运行上述命令安装 IronPPT,或在 NuGet 包管理器中搜索该包。

在一个包含Templates和Data文件夹的.NET 9控制台项目中启动Codex。

$ironppt Install IronPPT 2026.10.1 in this console app and list the slides of the sales template.

Program.cs opens Templates/weekly-sales-template.pptx and saves nothing.
Each slide gets a row in out/quickstart.csv, with these columns:

- number, counting from 1
- heading, the first text on the slide
- texts, how many text items the slide holds
- shown, yes or no from the slide's Show property

Program.cs reads IRONPPT_LICENSE_KEY itself and copies it into License.LicenseKey.
Never print the key or write it to a file or log, and don't list environment variables.

If three builds or runs fail, stop and show me the last error.
Otherwise, read the slide count back from the CSV and tell me the number.
Text

$ironppt 载入 IronPPT 的技能后继续编写代码。



什么是 ChatGPT Codex,它如何适用于.NET 演示工作?

/permissions 命令设置Codex编辑文件或运行命令时不询问。Codex CLI 文档涵盖安装和终端使用,开源存储库发布其版本。

Codex 对 IronPPT 的知识来自其训练数据和提供给它的文件。 IronPPT 缺少的成员名称会导致构建失败。

IronPPT 提供.NET Standard 2.0 程序集,其 NuGet 包列出 Windows、Linux 和 macOS。 测试运行在 Windows 上构建了项目。

如何编写 IronPPT 提示并为其设置 Codex?

以下提示命名模板和数据(Templates/weekly-sales-template.pptx 和 Data/week-41.csv)以及规则(Data/README.md,规定顺序、省略和隐藏的幻灯片及家庭风格)。

Codex 从工作目录到存储库根目录的每个文件夹中扫描 .agents/skills。 每个技能是一个包含 SKILL.md 的文件夹,其前言定义名字和描述。 将 IronPPT 的 skill.md 保存为 .agents/skills/IronPPT/SKILL.md,允许解决$ironppt问题。 技能声明已与 IronPPT 2026.8.1 检查,而本指南安装的是2026.10.1。

Codex 在开始任何工作之前读取 AGENTS.md。 它从存储库根目录走到工作文件夹,每个目录最多取一个文件,允许更深的文件覆盖较浅的文件。 /init 命令生成初稿。

Write an AGENTS.md in the repository root, under a heading called Weekly sales deck.
Put these rules in it, one per line:

- IronPPT 2026.10.1 is the only PowerPoint library here. Package and namespace are both IronPPT.
- Don't add DocumentFormat.OpenXml or any other Office package.
- Data/README.md defines the deck, and it wins over anything else.
- Templates/ and Data/ are read-only.
- Look up IronPPT members in the ironppt skill under .agents/skills/ironppt/.
- A probe on a saved deck outranks both the skill and the installed IronPPT.xml.
- A deck counts as built only once it's saved, reopened from disk and checked.
- Every count you report comes from a CSV written in that turn. The reply names that CSV.
- The key stays in IRONPPT_LICENSE_KEY.

Show me the finished file.
Text

如何请求 Codex 添加 IronPPT 并检查许可证?

Show me the IronPPT PackageReference in WeeklySalesDeck.csproj and the version NuGet resolved.
Then quote the full output of dotnet list package with --include-transitive.
Don't change any package references.
Text

IronPPT 2026.10.1 依赖于 IronSoftware.Common 2026.4.2 和 IronSoftware.System.Drawing 2026.8.2,测试运行的包列表显示了30个传递包,其中有 SixLabors.ImageSharp 3.1.12 和 Grpc.Net.Client 2.62.0。在固定版本前查看 IronPPT 更新日志。

没有密钥时,IronPPT 会打开一个幻灯片集,读取其文本,添加幻灯片和文本,并隐藏幻灯片。 只有Save会失败,带有生产许可证要求异常,且没有文件写入。 IronPPT 自行从IronPPT.LicenseKey或IRONPPT_LICENSEKEY环境变量中读取密钥,但忽略IRONPPT_LICENSE_KEY。 保留密钥的代码将其分配给License.LicenseKey,在首次保存前。 在 IronPPT 2026.10.1 中,许可异常类型不是公开的,因此处理程序捕获Exception并检查类型名称。

Move the key line into Startup.ApplyIronPptKey and call that method first in Program.cs.
It sets License.LicenseKey from IRONPPT_LICENSE_KEY, then prints License.IsLicensed.

Next, test what IronPPT does without a key.
Start the program three times as child processes, each with a --licence-check option:

1. Clear IRONPPT_LICENSE_KEY for that child only.
2. Keep the variable set, and pass a --no-startup flag that skips the Startup call.
3. Keep the variable set and the Startup call in place.

Each child opens the template, replaces {{WEEK}} with 41 and saves out/licence-check-N.pptx.
Write each call to out/licence-check.csv, with run, call, result, exception type and message.
Add a column that says whether each pptx file exists afterwards.
If three repair attempts fail, stop there.
Tell me which of the three runs saved a file.
Text

《许可证密钥页面》列出了提供密钥的其他方法。

为什么指南的幻灯片代码会保持幻灯片集不变?

管理幻灯片指南 使用Slides.RemoveAt移除幻灯片,使用Slides.Remove跟随Slides.Insert移动幻灯片,并且 IronPPT 技能描述 Slides 为可变列表。在IronPPT 2026.10.1 中,PresentationDocument.Slides 每次读取时返回新列表,那些调用仅更改该副本。 在校准中,加载的六张幻灯片集上的Slides.RemoveAt(0)保持计数为六,移动后保存的幻灯片集保持其原始顺序。 代码编译无异常并保存了应该移除的幻灯片。

对现有幻灯片的三次操作确实触及了幻灯片集。 在幻灯片本身上调用Remove()可将其从保存的文件中删除,并且Show = false写入的隐藏幻灯片保留在文件中。设置Slide.Index移动幻灯片,单独的探测重新打开已保存的幻灯片集按新顺序。

Probe which slide operations survive a save, in a console app at scratch/slides-probe/.

Run it yourself on a copy of the template in scratch/, and apply the key the way Startup does.
Add a Compile Remove item that keeps scratch/** out of WeeklySalesDeck.csproj.
Give each case its own try block and its own saved file.

Reopen each saved file and measure these cases:

- Slides.RemoveAt(4), and whether the slide count drops
- Slides.Remove, then Slides.Insert(1, ...) on Highlights, and the order that results
- Remove() on the Q2 Promotion Recap slide itself
- Clone() on the region slide
- AddSlide(new Slide()) with AddText, and where the new slide ends up
- Show = false on the appendix

Then have the explorer agent read IronPPT.xml and the ironppt skill, writing nothing.
It reports what each source says about the Slides collection and about Clone.

Put every finding in out/slides-probe.csv, quoting the probe output, the XML or the skill.
Mark the rows where the skill and the probe disagree, and tell me which they are.
Text

对编辑过的列表对象的检查通过,因为那个副本确实更改了。

如何从模板组装每周幻灯片集?

管理幻灯片指南不涵盖复制幻灯片。在IronPPT 2026.10.1 中,在幻灯片上调用Clone()会抛出MissingMethodException,将同一幻灯片对象添加两次不会在保存的文件中留下额外幻灯片。移除幻灯片并在结尾处再次添加会在原位置留下空白幻灯片。 有效的方法是为每个输出幻灯片添加新的Slide,按幻灯片集需要的顺序填充新文本,然后在模板原件上调用Remove()。

从加载的幻灯片集复制样式也失败。 在校准中,逐个属性复制的36pt标题写入为3600pt,其颜色#1F4E79变为黑色。 因此提示在每个文本上设置README的家庭风格。

模板遵循 README 中的幻灯片列表,第五为Q2促销回顾,第六为亮点。

下载 weekly-sales-template.pptx

测试运行中使用的每周销售模板,包含一个区域幻灯片,持有区域标记。

Have the worker agent write Services/DeckAssembler.cs. It builds the deck Data/README.md describes.

DeckAssembler accepts these options:

- --week, which picks Data/week-NN.csv and Data/week-NN.tokens
- --template, defaulting to Templates/weekly-sales-template.pptx
- --plan, which writes out/deck-plan.csv and saves no deck
- --build, which saves out/week-NN.pptx

The probe showed which calls reach the saved file.
Build the deck with those calls, in these steps:

1. Open the template and find each slide by its heading.
2. For every output slide, add a new slide with AddSlide and write its texts with AddText.
3. Set the README's house style on every text you write.
4. Set Show = false on the new appendix slide.
5. Call Remove() on the eight template slides, then save.

The plan CSV has one row per output slide, with position, template heading, final heading and shown.
Run --plan --week 41, then give me the row count and the hidden slides from the CSV.
Text

如何检查 Codex 保存的幻灯片集?

Run --build --week 41, then check the saved deck with code that's separate from the build.

The check reopens out/week-41.pptx and writes out/week-41-check.csv with these columns:

- position and heading
- shown
- the slide's full text, joined with " | "
- whether any {{ is left

Compare the check CSV with out/deck-plan.csv row by row.
Tell me which rows differ, and whether Q2 Promotion Recap appears anywhere in the deck.
Text

输出

DeckAssembler 在测试运行中为第41周保存了下面的幻灯片集,并未修改发布。

下载 week-41.pptx

IronPPT 保存的第41周销售幻灯片集。

模板更改时会发生什么?

Show me that DeckAssembler refuses Templates/weekly-sales-template-v2.pptx.
Marketing sent it with Highlights renamed to Wins This Week.

Run --build --week 41 --template Templates/weekly-sales-template-v2.pptx.
The existing out/week-41.pptx has to stay the same, byte for byte.
Record the attempt in out/template-check.csv with these columns:

- exit code and message
- the headings the build found
- the SHA-256 of out/week-41.pptx before and after

Tell me whether the two hashes match.
Text

如何从截图检查幻灯片?

Codex 接受图像作为上下文。 启动或恢复会话时,用-i标志(长形式--image)传递一个,或将其粘贴到互动编辑器中。

Check the screenshot I attached with -i against the data and the deck.
A regional manager sent it and says the West revenue is wrong.
Don't change any code, and work through these steps:

1. Read the region and its three figures from the image.
2. Compare them with Data/week-41.csv and Data/week-40.csv.
3. Compare them with the West slide in out/week-41.pptx, using its text in out/week-41-check.csv.
4. Write the comparison to out/screenshot-check.csv.

Tell me which week the screenshot shows, and whether out/week-41.pptx is right.
Text

如何从头到尾调试不正确的幻灯片输出?

Find out why the week 40 deck went out wrong. Data/week-40-complaint.md lists four problems.
Logs/week-40/deck.log says every step worked. Output/week-40.pptx is the deck that was sent.

Have the explorer agent read Jobs/LegacyWeeklyDeck.cs, the log and the deck before anything else.
A throwaway script under scratch/ may read the deck.
Don't edit any code outside scratch/.

Write out/week-40-diagnosis.md and cover these points in it:

- the line behind each of the four problems
- why the log reported success anyway
- the smallest fix for each, based on what the probe showed

Then give me one line per problem.
Text

在允许任何编辑前查看诊断结果。 传统作业在调用返回后写入每行日志,并从未重新打开幻灯片集。

如何将一次性代码转化为可重用的、经过测试的组件?

Ask the worker agent for a DeckService class that meets these conditions:

- It resolves from a Microsoft.Extensions.DependencyInjection container.
- A DeckOptions record configures it, with week, template, plan-only and output folder.
- It keeps the README rules, the heading check and the house style from DeckAssembler.
- DeckService.cs stays below 150 lines, and its public members have XML doc comments.
- Nothing calls Jobs/LegacyWeeklyDeck.cs.

Then build week 41 with DeckService into out/final/week-41.pptx.
Check that deck the way you checked out/week-41.pptx, into out/final/week-41-check.csv.
Compare the two check files and list every difference.
Text

重构可以删除标题检查并仍能编译。

Add an xUnit project at tests/WeeklySalesDeck.Tests, in the same solution as the main project.
Exclude tests/** from what the main project compiles.
The tests get the key through Startup.ApplyIronPptKey.

Each test builds a deck in a temp folder and reopens it.
Between them, the tests check these conditions:

- week 41 gives 11 slides, with Highlights second and the appendix hidden
- the five region slides follow the CSV order
- East shows Revenue: $0 and still has its slide
- no {{ is left anywhere, and Q2 Promotion Recap is gone
- the v2 template is refused, and the message names the missing heading

Run dotnet test with --logger trx and --results-directory out/tests/.
Read the trx file and tell me how many tests passed and failed.
Text

有关API的问题,已安装的 IronPPT.xml 文档幻灯片成员,如AddSlide,Remove,Clone,Index 和Show。 探测结果显示哪些达到保存的幻灯片集。

$ironppt List the members in the installed IronPPT.xml that add, remove, move, copy or hide slides.
For each member you find, tell me these two things:

- what the XML says it does
- whether out/slides-probe.csv or the trx file in out/tests/ shows it working on a saved deck

Then write one compiling line per member in a probe project under scratch/api-probe/.
Build that probe with dotnet build, but don't run it.
Text

如何在另一个幻灯片集上重用这些提示?

随着模板、数据文件和 README 规则发生变化,相同的提示适用于董事会文档、项目状态幻灯片集或客户评论。 有关适用于每个助手的设置,请参阅 IronPPT AI 编码助手指南。

在实际运行中这些提示生成了什么?

上述提示按顺序输入 Codex,在一个会话中。 传统作业、其日志及其幻灯片集在调试提示之前添加。 独立脚本重新打开该运行保存的每个幻灯片集,并从文件中读取每张幻灯片。

  • 运行前,模板包含八张幻灯片,所有均显示。
  • 变量被清除后,保存抛出许可异常,输出文件随后不存在。
  • 设置变量并跳过启动调用后,保存以同样方式失败。
  • 在探测中,Slides.RemoveAt(4) 保留了保存文件中的所有八张幻灯片。
  • Region 幻灯片上的 Clone() 抛出 MissingMethodException。
  • Codex 启动了三个子代理,调试提示重用了探测提示中的 explorer 代理。
  • 保存的第41周幻灯片集按 README 顺序持有11张幻灯片,五个区域幻灯片按 CSV 顺序。
  • 显示了十张幻灯片,附录被保存为隐藏。
  • Q2促销回顾缺席了幻灯片集。
  • 东部保持了其幻灯片,收入为 $0。
  • 拒绝的 v2 模板保持现有幻灯片集的 SHA-256 哈希不变。
  • Codex 将截图与第40周西部数据匹配。
  • 诊断将第40周的四个问题每个都与传统作业中的对应行关联起来。
  • 诊断将隐藏的北部幻灯片追踪到 Slides.Last() 返回的重用区域幻灯片。
  • 用 DeckService 构建的幻灯片集在每张幻灯片上与首次构建匹配。
  • Codex 的运行中和我们的运行中,所有五个测试均已通过。
  • 有些步骤与页面中的运行不一样。 NuGet 包来自在运行前恢复的缓存,因为沙箱没有网络。

GitHub Copilot 指南 衡量了类似于处理管理图像指南中的替换调用的图片失败,而留在加载的文件中的旧照片的类似失败。 Google Antigravity 指南 构建用于同时 web 请求的幻灯片集,IronPPT 仅在一个锁保护每个 IronPPT 调用时正确服务它们。 共享的 运行记录 提供了Codex版本、模型、时间和测试机器。


故障排除


有问题吗?

如果您有任何问题,请联系support@ironsoftware.com

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

阅读更多

准备开始了吗?

NuGet 下载量 7,110版本:2026.11刚刚发布