How to Create PowerPoint Presentation using C#

In this simple tutorial, we will show how to create PowerPoint Presentation using C# along with the detailed steps to set up the environment on your end. While working in C# create PowerPoint presentation using simple steps without any reliance on PowerPoint. Moreover, the provided example can be seamlessly used on all .NET supported platforms.

Steps to Create PowerPoint Presentation using C#

  1. Download and install Aspose.Slides for .NET package from the NuGet
  2. Use Aspose.Slides, Aspose.Slides.Export and System.Drawing namespaces in your project
  3. Create an empty presentation by using the instance of the Presentation class
  4. Add a slide with a Blank Layout type inside the presentation slides collection
  5. Add a Rectangle AutoShape inside the newly created slide
  6. Add a text frame inside added shape and set its textual properties
  7. Save the presentation as PPTX on the disk using the Save method

The above steps in C# create PPTX file without any dependence on MS PowerPoint. The process starts by creating a presentation using the Presentation class instance, which is then followed by adding a blank slide and an autoshape inside the slide. Subsequently, the text is added and formatted inside the added shape before saving the presentation file as PPTX on the disk.

Code to Generate PowerPoint Presentation in C#

By using the above example in C# Presentation in PPTX format has been saved on the disk. The SaveFormat enumerator also gives the options to save the presentation in PPT, PPS, PPSX, ODP, POT and POTX formats. You can also customize the text using different options exposed by the PortionFormat and ParagraphFormat classes which include setting the options like bullets, margins, indentations, highlighting and text strike-through.

Earlier, we have witnessed how to save slide as SVG in C# in another how-to topic. However, in this topic, we have explored how using C# PowerPoint presentation in different formats can be generated.

 English