[Copilot Studio] Tried generating .pptx/.xlsx from scratch with Code Interpreter
This page has been translated by machine translation. View original
Introduction
Hello, I'm Keema.
Last time, I inserted values into placeholders in a Word template to generate a report.
That approach fills in the blanks of a template, and is specific to Word.
So the theme of this article is: what do you do when you want to create PowerPoint or Excel files — complete with natively editable charts?
In this article, I explore whether the code interpreter (Python execution) can generate real .pptx / .xlsx files from scratch without a template, and I verified this with hands-on testing as of June 2026.
I also confirm whether the generated files are genuine files you can open and edit in Excel, rather than just images pasted in.
I hope this serves as a reference for those who want to automate the creation of PowerPoint and Excel documents.
This article is the 10th installment in a series about building agents in Copilot Studio.
The series as a whole aims to build an agent that handles "collection → aggregation → charts → insights → documentation" end to end, and this article covers the "documentation (PowerPoint / Excel)" part.
Target audience: Those who want to automatically generate editable PowerPoint / Excel documents with Copilot Studio
Series Article List
| # | Theme | Article |
|---|---|---|
| Part 1 | First Agent | Creating Your First Agent |
| Part 2 | Knowledge | Trying Knowledge-Grounded Answers Based on Files |
| Part 3 | Topics, Tools, Flows | Building "Behavior" with Topics, Tools, and Agent Flows |
| Part 4 | Templates, Autonomous Triggers, Multi-Agent | Expanding the Configuration with Templates, Autonomous Triggers, and Multi-Agent |
| Part 5 | Collection (How to Pass Data) | Comparing Methods for Giving an Agent KPI Data for Aggregation |
| Part 6 | Aggregation | Performing KPI Aggregation Deterministically Without Relying on an LLM |
| Part 7 | Charts | Displaying KPIs as Charts in Chat |
| Part 8 | Insights | Generating Insights from Aggregated Numbers |
| Part 9 | Documentation (Word) | Automatically Generating a Word Report by Inserting Values into a Template |
| Part 10 | Documentation (PowerPoint / Excel) | (This article) |
1. What We're Doing This Time
We'll have the code interpreter generate real PowerPoint / Excel files from scratch.
- Use the code interpreter to generate a
.xlsxfile with a natively editable bar chart embedded - Use the code interpreter to generate a
.pptxfile
For verification, I'll use the same aggregated ARR values for fiscal year 2025 from three fictional SaaS companies (CloudNova / StreamForge / Datapeak) used in previous installments (CloudNova 1,950 / StreamForge 1,300 / Datapeak 2,810 — all fictional).
2. The Difference Between Insertion and Native Generation
The previous article (Word) and this article (PowerPoint / Excel) use different approaches to file creation.
| Aspect | Previous: Document output (insertion) | This article: Code interpreter |
|---|---|---|
| Approach | Fill in {{field}} placeholders in a prepared template |
Build the file from scratch in Python |
| Supported formats | Word only | Word / Excel / PowerPoint / PDF |
| Charts | Range prepared in the template | Freely created in code (Excel produces natively editable charts) |
| Template | Required | Not required |
| Billing | Prompt execution (Copilot Credits) | Premium (Copilot Credits) |
The code interpreter can run Python to process Word / Excel / PowerPoint / PDF files.
Code interpreter is a Python execution engine integrated within Copilot Studio and prompt builder prompts. It allows users to run code in a secure, sandboxed environment to perform data analysis, process Word, Excel, PowerPoint and PDF files, and generate visualizations.
Source: FAQ for code interpreter | Microsoft Learn
For the generation in this article, enable "Code Interpreter" under "Settings" → "Generative AI" → "File Processing Capability" in the agent, then run it in the test chat.
Note that to use the code interpreter, user authentication must be enabled on the agent side. It will not work without authentication (such as Direct Line with No authentication).
To use code interpreter, you need to configure your agent, in agent settings, to use user authentication. For example, using Direct Line with No authentication selected doesn't work for scenarios using code interpreter.
Source: Use code interpreter in a prompt to generate and execute Python code | Microsoft Learn
3. Natively Generating Excel
In the test chat, I request the generation of an Excel file with a native chart summarizing the aggregated values.
Using only the 2025 ARR aggregated values for three companies, generate a single .xlsx file using openpyxl. Arrange the table and bar chart to fit on one screen for the blog. Make sure to execute all steps.
1. Create a sheet named "ARR Summary". Put headers "Company Name" and "ARR (millions JPY)" in A1:B1, and enter CloudNova 1950 / StreamForge 1300 / Datapeak 2810 in A2:B4.
2. Format the header row (A1:B1) with a dark navy background and white bold text. Apply number format (#,##0) to column B. Set column A width to 16 and column B width to 14.
3. Use openpyxl.chart.BarChart and Reference to create a vertical bar chart with values=B2:B4 and categories=A2:A4. Set the title to "2025 ARR Comparison (millions JPY)", hide the legend, and set the size to width=11 · height=7 (cm). Embed it at cell D1 using add_chart (a native chart with cell references, not an image).
4. Save the file, then report the "sheet list," "number of charts," and "chart anchor cell and size" before returning the .xlsx download link.
Do not use any values not listed here.
The code interpreter executed openpyxl (a Python library for manipulating Excel files) and generated the .xlsx file.
The response shows an execution report (sheet list, number of charts, chart anchor cell and size), and a download link for ARR_2025_comparison.xlsx is returned.

Excel generation response. As instructed, it reports "Sheet list = ARR Summary / Number of charts = 1 / Anchor = D1 / Size = width 11cm × height 7cm," and a download link for ARR_2025_comparison.xlsx is shown.
When downloaded and opened, it was a genuinely editable native Excel file with a bar chart placed to the right of the data table.
The bar chart is a BarChart object with cell references (B2:B4), not an image, so you can edit the series color, axes, and chart type directly in Excel.

Opened ARR_2025_comparison.xlsx. The data table (with header formatting and number separators) is on the left, and the native bar chart with cell references is on the right. Everything fits on one screen as specified.
One thing I noticed here.
The bar chart generated this time had neither company name labels on the horizontal axis nor value labels on the bars (as seen in the image above, three bars are displayed but it's impossible to tell from the chart alone which bar belongs to which company).
In openpyxl, data labels are off by default, and category labels on the horizontal axis won't appear unless the category reference (set_categories) is properly applied, so if not explicitly specified, charts tend to come out without labels like this.
While the chart is natively editable, it may not be presentation-ready as-is, and if labels are needed, they must be added through instructions or code.
4. Natively Generating PowerPoint
Similarly, I had it generate a PowerPoint file from scratch.
I passed the 2025 KPI data for three companies and had it build a three-slide presentation using python-pptx.
Using only the following 2025 fiscal year KPIs (in millions JPY and %), generate a PowerPoint comparing three companies using python-pptx. The structure should be three slides: a title slide, an ARR bar chart, and insights. Name the file 2025_KPI_Comparison.pptx, and return a .pptx download link when done. Do not use any values not listed here.
CloudNova: ARR 1950, NRR 120, Operating Profit Margin 13.5
StreamForge: ARR 1300, NRR 109, Operating Profit Margin 1.0
Datapeak: ARR 2810, NRR 128, Operating Profit Margin 19.0
The code interpreter executed python-pptx (a Python library for manipulating PowerPoint files).
The response explained that it generated 2025_KPI_Comparison.pptx with three slides — a title slide, an ARR bar chart, and insights — and a download link was returned.
Only the values provided (ARR, NRR, and operating profit margin for CloudNova / StreamForge / Datapeak) were used, and no values not provided were introduced.

PowerPoint generation response. On the left is the executed python-pptx code; on the right, the slide structure (title slide, ARR bar chart, key insights) and the data used (only the 2025 fiscal year values provided) are shown, with a download link for 2025_KPI_Comparison.pptx.
Unlike the Word fill-in approach (previous article), the slides are assembled without a template.
When downloaded and opened, three slides had been created as described. Let's look at them in order.
The title slide is a simple layout with just a title and the three target companies.

Slide 1 (Title). "2025 Fiscal Year SaaS KPI Comparison Report" and the three target companies (CloudNova / StreamForge / Datapeak).
The second slide is a bar chart of ARR.
Even though it's also a bar chart, this chart created with python-pptx was generated with both company name labels on the horizontal axis and value labels on the bars (in contrast to the Excel chart in Step 3, which had neither axis labels nor values).

Slide 2 (ARR bar chart). CloudNova 1,950 / StreamForge 1,300 / Datapeak 2,810. Company names on the horizontal axis and values on each bar are displayed, making the chart presentation-ready on its own.
The third slide contains insights.
Based on the ARR, NRR, and operating profit margin provided, comments comparing the three companies were generated as bullet points.

Slide 3 (Key Insights). Comments aligned with the provided numbers: "Datapeak leads in all metrics," "StreamForge has a low operating profit margin, indicating a profitability challenge," and "CloudNova is a balanced performer."
Even when creating the same "native bar chart" in Excel (openpyxl) and PowerPoint (python-pptx), the resulting appearance is not necessarily the same.
Whether labels appear depends on whether the generated code sets up categories and data labels. If you need a chart that's ready to use in a presentation as-is, it's safer to include axis labels, value labels, and legend settings in your instructions.
6. Caveats: Generation Time and Distribution
There are two caveats to keep in mind when using native generation.
The first is generation time.
In my environment, both PowerPoint and Excel took more than one minute (roughly 1 to 1.5 minutes) to generate.
Agent flow tools must respond synchronously within 100 seconds.
Respond to the agent within the 100-second action limit. Optimize the flow logic, queries, and the amount of data returned so that a typical run is below this 100-second limit.
Source: Add an agent flow or workflow as a tool to an agent | Microsoft Learn
Since file generation can take around 100 seconds, placing it directly in a synchronous flow risks a timeout.
It's safer to use file generation directly in the test chat or agent chat.
Session timeouts for long-running tasks
Source: FAQ for code interpreter | Microsoft Learn
The second is distribution.
Generated files are only accessible during the session, so to reliably deliver them to users, you should save them to OneDrive or similar and return a sharing link. This will be covered in the distribution article.
7. Summary
Using the code interpreter, you can generate PowerPoint / Excel files from scratch without a template.
In particular, Excel files embed charts in a native format with data references rather than images, so recipients can edit them directly in Excel.
Before deploying this in production, you should be aware that generation takes on the order of minutes, distributing the generated files requires additional handling, and it is a premium-billed feature.