如何在PowerPoint中新增幻燈片

This article was translated from English: Does it need improvement?
Translated
View the article in English

在PowerPoint簡報中新增幻燈片是建立強大且引人入勝的簡報的一個重要部分。 使用IronPPT,您可以輕鬆地在簡報的末尾新增新幻燈片,自動化您的創意工作流程,使您輕鬆構建精美的幻燈片組。


新增幻燈片範例

在PowerPoint中新增幻燈片是一項相當容易的任務。 只需建立一個新的PresentationDocument物件(.pptx)。 然後,調用Save方法保存PowerPoint文件。

請注意預設情況下,新的簡報文件中已有一個現有的空白頁面。 該文件中的任何新頁面都在初始頁面之後新增

:path=/static-assets/ppt/content-code-examples/how-to/add-slide-add-slide.cs
using IronPPT;
using IronPPT.Models;

// Instantiate a new PresentationDocument object
var document = new PresentationDocument();

// Add a slide to the presentation
document.AddSlide(new Slide());

// Export the presentation to a PPTX file
document.Save("addSlides.pptx");
Imports IronPPT
Imports IronPPT.Models

' Instantiate a new PresentationDocument object
Dim document As New PresentationDocument()

' Add a slide to the presentation
document.AddSlide(New Slide())

' Export the presentation to a PPTX file
document.Save("addSlides.pptx")
$vbLabelText   $csharpLabel

PowerPoint結果

已新增一個幻燈片

新增幻燈片物件

新增幻燈片物件對於新增和分組特定幻燈片的元素非常有用。例如,某圖像需要與特定幻燈片分組。您可以建立一個幻燈片物件並新增圖像。 它的工作原理類似於我們之前的範例; 建立一個新的Slide類建立幻燈片物件。 確認後,我們將文字新增到新幻燈片上,最後使用AddSlide方法將新幻燈片新增到我們的文件中。

:path=/static-assets/ppt/content-code-examples/how-to/add-slide-add-slide-object.cs
using IronPPT;
using IronPPT.Models;

// Create a new presentation document
var document = new PresentationDocument();

// Create a new slide object
var slide = new Slide();

// Add text to the slide
slide.AddText("Hello World!");

// Add the slide object to the document using the AddSlide method
document.AddSlide(slide);

// Save the presentation as a PPTX file
document.Save("adding-slide-object.pptx");
Imports IronPPT
Imports IronPPT.Models

' Create a new presentation document
Dim document As New PresentationDocument()

' Create a new slide object
Dim slide As New Slide()

' Add text to the slide
slide.AddText("Hello World!")

' Add the slide object to the document using the AddSlide method
document.AddSlide(slide)

' Save the presentation as a PPTX file
document.Save("adding-slide-object.pptx")
$vbLabelText   $csharpLabel

PowerPoint結果

已新增一個幻燈片物件

新增多個幻燈片

透過使用簡單的for迴圈可以直觀地新增多個幻燈片。在下面的程式碼段中,現有文件被載入,並新增另外3個頁面。 概念仍然圍繞以編程方式操作腳本以充分利用IronPPT。

:path=/static-assets/ppt/content-code-examples/how-to/add-slide-multiple-slides.cs
using IronPPT;
using IronPPT.Models;

// Loading an existing PPTX file
var document = new PresentationDocument("adding-slide-object.pptx");

// Add 3 new slides to the presentation
for (int i = 0; i < 3; i++) {
    document.AddSlide(new Slide());
}

// Export the file
document.Save("addSlides.pptx");
Imports IronPPT
Imports IronPPT.Models

' Loading an existing PPTX file
Dim document As New PresentationDocument("adding-slide-object.pptx")

' Add 3 new slides to the presentation
For i As Integer = 0 To 2
    document.AddSlide(New Slide())
Next

' Export the file
document.Save("addSlides.pptx")
$vbLabelText   $csharpLabel

PowerPoint結果

已新增多個幻燈片

常見問題

如何使用IronPPT在PowerPoint中新增投影片?

要在PowerPoint中使用IronPPT新增投影片,請建立一個新的簡報文件物件(.pptx),使用`AddSlide`方法來新增單一投影片,然後使用`Save`方法儲存PowerPoint文件。

我可以使用 IronPPT 一次性新增多個投影片嗎?

可以,您可以使用簡單的`for`迴圈來新增您想要的投影片數量。

IronPPT中的投影片物件是什麼?

IronPPT中的投影片物件用於為特定的投影片新增和分組元素,如圖像或文字,然後使用`AddSlide`方法將其納入簡報中。

using IronPPT 可以向現有的 PowerPoint 檔案新增投影片嗎?

可以,您可以載入現有的 PowerPoint 檔案,並使用IronPPT新增新投影片。

開始使用IronPPT新增投影片的步驟有哪些?

要開始使用IronPPT,請下載程式庫,建立或打開PowerPoint檔案,使用`AddSlide`方法新增投影片,並匯出最終簡報。

IronPPT如何自動化投影片建立工作流程?

IronPPT通過允許您程式化地新增投影片、分組物件以及高效地管理簡報元素來自動化投影片建立。

IronPPT中新PowerPoint檔案的預設結構是什麼?

預設情況下,IronPPT中的新PowerPoint檔案包含一個現有的空白頁,任何新頁面都會新增在初始頁面之後。

IronPPT能否同時新增投影片及其內容?

可以,IronPPT可以處理新增投影片及內容,如文字或圖像,透過建立投影片物件並使用`AddSlide`方法。

Ahmad Sohail
全端開發人員

Ahmad是一位擁有C#、Python和網頁技術堅實基礎的全端開發人員。他對構建可擴展的軟體解決方案深感興趣,並喜歡探索設計和功能在現實世界應用中的結合。

加入Iron Software團隊之前,Ahmad曾致力於自動化專案和API整合,專注於提升性能和開發者體驗。

在空閒時間,他喜歡試驗UI/UX理念,為開放原始碼工具做出貢獻,偶爾也會潛心編寫技術文件和文章以簡化複雜的主題。

準備好開始了嗎?
Nuget 下載 5,616 | 版本: 2026.7 剛剛發布
Still Scrolling Icon

還在捲動?

想要快速證明? PM > Install-Package IronPPT
運行範例 觀察您的 PDF 變成可編輯文字。