Wie man Folien in PowerPoint mit C# verwaltet | IronPPT

How to Manage Slides in PowerPoint

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

Eine Folie ist eine einzelne Seite oder ein Bildschirm in einer Präsentation. Sie dient als grundlegender Baustein zur Organisation und Darstellung von Inhalten. Folien werden verwendet, um Informationen visuell zu vermitteln und können Text, Bilder, Diagramme, Tabellen, Videos, Audio, Animationen und andere Designelemente enthalten.

als-Überschrift:2(Schnellstart: Einfach eine Folie mit IronPPT entfernen, neu ordnen oder ausblenden)

Hier ist ein einzeiliges Beispiel, das zeigt, wie man die erste Folie unmittelbar nach dem Hinzufügen entfernt. IronPPT erleichtert Entwicklern häufige Aktionen wie die Verwaltung von Folien, sodass Sie sich auf Inhalte statt auf Tools konzentrieren können.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronPPT with NuGet Package Manager

    PM > Install-Package IronPPT

  2. Copy and run this code snippet.

    new PresentationDocument().AddSlide().Slides[0].Remove();
  3. Deploy to test on your live environment

    Start using IronPPT in your project today with a free trial
    arrow pointer
class="hsg-featured-snippet">

Minimaler Workflow (5 Schritte)

  1. Laden Sie eine C#-Bibliothek zur Verwaltung von Folien in PPT herunter
  2. Fügen Sie Folien mit der AddSlide-Methode hinzu
  3. Erhalten Sie vollständige Kontrolle über Folien mit Folieneigenschaften
  4. Entfernen, neu ordnen und ausblenden von Folien mit einer einzigen Codezeile
  5. Exportieren Sie die endgültige PowerPoint-Präsentation

Folie hinzufügen

Fügen Sie mühelos eine neue Folie zur Präsentation hinzu, indem Sie die AddSlide-Methode verwenden. Neue Folien werden am Ende der aktuellen Folienliste angehängt, sodass Sie Ihre Präsentation nahtlos erweitern können.

:path=/static-assets/ppt/content-code-examples/how-to/manage-slide-add-slide.cs
// Ensure you have the necessary using directives for any external libraries or namespaces.
using IronPPT;

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

// Add three slides to the presentation.
// The AddSlide method creates a new slide and adds it to the list of slides in the document.
document.AddSlide();  // Add first slide
document.AddSlide();  // Add second slide
document.AddSlide();  // Add third slide

// Save the presentation to a file named "addSlides.pptx".
// The Save method takes a file path as an argument and writes the current state of the presentation to this file.
document.Save("addSlides.pptx");
' Ensure you have the necessary using directives for any external libraries or namespaces.
Imports IronPPT

' Instantiate a new PresentationDocument object.
Private document = New PresentationDocument()

' Add three slides to the presentation.
' The AddSlide method creates a new slide and adds it to the list of slides in the document.
document.AddSlide() ' Add first slide
document.AddSlide() ' Add second slide
document.AddSlide() ' Add third slide

' Save the presentation to a file named "addSlides.pptx".
' The Save method takes a file path as an argument and writes the current state of the presentation to this file.
document.Save("addSlides.pptx")
$vbLabelText   $csharpLabel

Folie entfernen

Löschen Sie unerwünschte Folien mit der Remove-Methode. Diese Funktion stellt sicher, dass Sie Ihre Inhalte schnell verfeinern und unnötige Folien entfernen können, ohne die Gesamtstruktur zu stören.

Hinweis:Alle Folienpositionsindexe folgen der Null-basierten Indizierung.

:path=/static-assets/ppt/content-code-examples/how-to/manage-slide-remove-slide.cs
// Import the IronPPT namespace to handle PowerPoint presentations
// Assuming IronPPT is a fictional or placeholder library. Substitute with actual library as needed
using IronPPT;

// Create a new instance of the PresentationDocument class, assuming PresentationDocument 
// is a part of IronPPT that helps create or modify PowerPoint presentations
var document = new PresentationDocument();

// Add a new slide to the presentation, assuming the Add method adds a new slide to the collection
document.Slides.Add(new Slide());

// Check if there is at least one slide before attempting to remove
if (document.Slides.Count > 0)
{
    // Remove the first slide from the presentation's list of slides
    document.Slides.RemoveAt(0);
}

// Save the modified presentation to a file named "removeSlide.pptx"
// The Save method will write the current state of the presentation to the specified file
document.Save("removeSlide.pptx");
' Import the IronPPT namespace to handle PowerPoint presentations
' Assuming IronPPT is a fictional or placeholder library. Substitute with actual library as needed
Imports IronPPT

' Create a new instance of the PresentationDocument class, assuming PresentationDocument 
' is a part of IronPPT that helps create or modify PowerPoint presentations
Private document = New PresentationDocument()

' Add a new slide to the presentation, assuming the Add method adds a new slide to the collection
document.Slides.Add(New Slide())

' Check if there is at least one slide before attempting to remove
If document.Slides.Count > 0 Then
	' Remove the first slide from the presentation's list of slides
	document.Slides.RemoveAt(0)
End If

' Save the modified presentation to a file named "removeSlide.pptx"
' The Save method will write the current state of the presentation to the specified file
document.Save("removeSlide.pptx")
$vbLabelText   $csharpLabel

Folie neu anordnen

Ordnen Sie die Reihenfolge der Folien neu, um den Ablauf Ihrer Präsentation besser anzupassen. Das Neuordnen von Folien ist einfach und effizient, sodass es leicht ist, die Reihenfolge der Ideen zu aktualisieren oder sich an neue Anforderungen anzupassen.

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

var document = new PresentationDocument();

// Adding a new slide to the document.
document.AddSlide();

// To reorder slides, we must remove the slide from its current position 
// and then insert it back at the desired position. 

// Capture the slide to be moved. 
// Assuming we want to move the first slide in this case.
var slideToMove = document.Slides[0];

// Remove the slide from its current position.
document.Slides.Remove(slideToMove);

// Add the slide back at the desired index (for example, index 1).
// Ensure the desired index is valid and within the range of the current slides.
if (document.Slides.Count >= 1) // Check if there is at least one slide to insert into.
{
    document.Slides.Insert(1, slideToMove);
}

// Save the presentation with the reordered slide.
// Ensure a valid file path and name are provided.
document.Save("reorderSlide.pptx");
Imports IronPPT

Private document = New PresentationDocument()

' Adding a new slide to the document.
document.AddSlide()

' To reorder slides, we must remove the slide from its current position 
' and then insert it back at the desired position. 

' Capture the slide to be moved. 
' Assuming we want to move the first slide in this case.
Dim slideToMove = document.Slides(0)

' Remove the slide from its current position.
document.Slides.Remove(slideToMove)

' Add the slide back at the desired index (for example, index 1).
' Ensure the desired index is valid and within the range of the current slides.
If document.Slides.Count >= 1 Then ' Check if there is at least one slide to insert into.
	document.Slides.Insert(1, slideToMove)
End If

' Save the presentation with the reordered slide.
' Ensure a valid file path and name are provided.
document.Save("reorderSlide.pptx")
$vbLabelText   $csharpLabel

Folie ausblenden

Blenden Sie bestimmte Folien aus, während Sie sie in der Präsentation behalten. Ausgeblendete Folien werden während der Diashow nicht angezeigt, bleiben jedoch für die Bearbeitung oder Verwendung in zukünftigen Präsentationen zugänglich.

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

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

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

// Hide the first slide by setting its visibility to false
document.Slides[0].Visible = false;

// Save the presentation to a file named 'hideSlide.pptx'
document.Save("hideSlide.pptx");
Imports IronPPT

' Create a new presentation document
Private document = New PresentationDocument()

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

' Hide the first slide by setting its visibility to false
document.Slides(0).Visible = False

' Save the presentation to a file named 'hideSlide.pptx'
document.Save("hideSlide.pptx")
$vbLabelText   $csharpLabel
Curtis Chau
Technischer Autor

Curtis Chau hat einen Bachelor-Abschluss in Informatik von der Carleton University und ist spezialisiert auf Frontend-Entwicklung mit Expertise in Node.js, TypeScript, JavaScript und React. Leidenschaftlich widmet er sich der Erstellung intuitiver und ästhetisch ansprechender Benutzerschnittstellen und arbeitet gerne mit modernen Frameworks sowie der Erstellung gut strukturierter, optisch ansprechender ...

Weiterlesen
Bereit anzufangen?
Nuget Downloads 3,171 | Version: 2025.11 gerade veröffentlicht