Create MS PowerPoint Presentations in C#

MS PowerPoint presentations allow you to create slide shows containing text, images, charts, animations, and other elements. Various additional formatting options let you make your presentations more appealing. In this post, you will come to know how to create PowerPoint PPT PPTX in C# . You will learn how to insert text, tables, images, and charts in PowerPoint PPT in programmatically in C# .

  • C# PowerPoint API
  • Create a PowerPoint Presentation
  • Open an Existing PowerPoint Presentation
  • Add Slide to a Presentation
  • Add Text to Presentation’s Slide
  • Create a Table in Presentation
  • Create a Chart in Presentation
  • Add an Image in Presentation

C# API to Create PowerPoint PPT - Free Download #

Aspose.Slides for .NET is a presentation manipulation API that lets you create and manipulate PowerPoint documents from within your .NET applications. The API provides nearly all possible features required to implement basic as well as advanced PowerPoint automation features. You can either download the API or install it via NuGet .

Create a PowerPoint PPT in C# #

Let’s start by creating an empty PowerPoint PPT/PPTX presentation using Aspose.Slides for .NET. The following are the steps to do so.

  • Create an instance of the Presentation class.
  • Save it as PPTX using Presentation.Save(String, SaveFormat) method.

The following code sample shows how to create a PowerPoint presentation in C#.

Open an Existing PowerPoint Presentation in C# #

You don’t need to put extra efforts in order to open an existing PowerPoint presentation. Simply provide the path of the PPTX file to the constructor of the Presentation class and you are done. The following code sample shows how to open an existing PPTX presentation.

Add a Slide to PPT in C# #

Once you have created the presentation, you can start adding the slides to it. The following are the steps to add a slide in the presentation using Aspose.Slides for .NET.

  • Instantiate ISlideCollection class by setting a reference to the Presentations.Slides property.
  • Add an empty slide to the presentation using Slide.AddEmptySlide(ILayoutSlide) method exposed by ISlideCollection object
  • Save the presentation file using the Presentation.Save(String, SaveFormat) method.

The following code sample shows how to add a slide in a PowerPoint presentation using C#.

Insert Text in a PPT Slide using C# #

Now we can add content to the slides in the PowerPoint presentation. Let’s first add a piece of text to the slide using the following steps.

  • Create a new presentation using the Presentation class.
  • Obtain the reference of the slide in the presentation.
  • Add an IAutoShape with ShapeType as Rectangle at a specified position of the slide.
  • Obtain the reference of that newly added IAutoShape object.
  • Add a TextFrame to the AutoShape containing the default text.
  • Save the presentation as a PPTX file.

The following code sample shows how to add text to slide in a presentation using C#.

Create Table in a PPT Presentation using C# #

Aspose.Slides for .NET provides an easy way to create a table in the presentation document. The following are the steps for it.

  • Obtain the reference of a slide by using its index.
  • Define arrays of columns with width and rows with height.
  • Add a table to the slide using Slide.Shapes.AddTable() method exposed by IShapes object and get the reference to the table in ITable instance.
  • Iterate through each cell to apply the formatting.
  • Add text to the cells using Table.Rows[][].TextFrame.Text property.

The following code sample shows how to create table in a slide of PowerPoint presentation.

Create Chart in a PowerPoint PPT using C# #

The following are the steps to add a chart in PowerPoint presentation using C#.

  • Obtain the reference of a slide by index.
  • Add a chart with the desired type using ISlide.Shapes.AddChart(ChartType, Single, Single, Single, Single) method.
  • Add a chart title.
  • Access the chart data worksheet.
  • Clear all the default series and categories.
  • Add new series and categories.
  • Add new chart data for chart series.
  • Set fill color for chart series.
  • Add chart series labels.

The following code sample shows how to add chart in a presentation using C#.

Learn more about the presentation charts here .

Add an Image in PowerPoint Presentation #

The following are the steps to add images in the presentation slide.

  • Create a new presentation using Presentation class.
  • Read SVG image using File.ReadAllText(String path) method.
  • Add image to slide using Presentation.Slides[0].Shapes.AddPictureFrame(ShapeType shapeType, float x, float y,float width, float height, IPPImage image) method.
  • Save the presentation.

The following code sample shows how to add image to a presentation in C#.

C# .NET PowerPoint API - Get a Free License #

You can use Aspose.Slides for .NET without evaluation limitations by getting a free temporary license .

Conclusion #

In this article, you have learned how to create PowerPoint PPT presentations from scratch using C#. In addition, you have seen how to add slides, text, tables, images, and charts in new or existing PPTX presentations. You can learn more about the API using the documentation .

  • Protect PowerPoint PPTX Presentations using C#
  • Create MS PowerPoint Presentations in ASP.NET
  • Convert PowerPoint PPTX/PPT to PNG Images in C#
  • Set Slide Background in PowerPoint Presentations using C#
  • Generate Thumbnails for PowerPoint PPTX or PPT using C#
  • Apply Animation to Text in PowerPoint using C#
  • Split PowerPoint Presentations using C#

Tip: Besides the creation of slides or presentations, Aspose.Slides provides many features that allow you to work with presentations. For example, using its own APIs, Aspose developed a free online viewer for Microsoft PowerPoint Presentations .

Aspose Knowledge Base

Find advice and answers for most commonly faced scenarios.

Find Answers by API

  • Aspose.Total Product Family
  • Aspose.Words Product Family
  • Aspose.PDF Product Family
  • Aspose.Cells Product Family
  • Aspose.Email Product Family
  • Aspose.Slides Product Family
  • Aspose.BarCode Product Family
  • Aspose.Diagram Product Family
  • Aspose.Tasks Product Family
  • Aspose.OCR Product Family
  • Aspose.Note Product Family
  • Aspose.CAD Product Family
  • Aspose.3D Product Family
  • Aspose.HTML Product Family
  • Aspose.GIS Product Family
  • Aspose.ZIP Product Family
  • Aspose.Page Product Family
  • Aspose.PSD Product Family
  • Aspose.OMR Product Family
  • Aspose.PUB Product Family
  • Aspose.SVG Product Family
  • Aspose.Finance Product Family
  • Aspose.Drawing Product Family
  • Aspose.Font Product Family
  • Aspose.TeX Product Family

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#

  • Download and install Aspose.Slides for .NET package from the NuGet
  • Use Aspose.Slides , Aspose.Slides.Export and System.Drawing namespaces in your project
  • Create an empty presentation by using the instance of the Presentation class
  • Add a slide with a Blank Layout type inside the presentation slides collection
  • Add a Rectangle AutoShape inside the newly created slide
  • Add a text frame inside added shape and set its textual properties
  • 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.

Updated on 10 May 2022

IMAGES

  1. How to create a PowerPoint presentation using C# and embed a Picture to

    create presentation using c#

  2. C# Helper: Create a PowerPoint presentation from a Word document in C#

    create presentation using c#

  3. How to create a PowerPoint presentation using C# and embed a Picture to

    create presentation using c#

  4. PPT

    create presentation using c#

  5. Creating Classes and Objects in C# using Visual Studio

    create presentation using c#

  6. OpenCv & EmguCv C# Tutorial 01

    create presentation using c#

VIDEO

  1. Create a C# Application from Start to Finish Complete Course Обрезка 04

  2. School Management System Part 10

  3. How To Generate Presentations With In Minutes Using GAMMA AI ( Hindi Tutorial )

  4. Data types and Operators in C#

  5. How to Create Presentation Slides with Zero Design Skills

  6. How to create Circle animation in C PROGRAM

COMMENTS

  1. C#/VB.NET

    Install Free Spire.Presentation for .NET. Method 1: Download Free Spire.Presentation and unzip the package somewhere on your disk to find the “BIN” folder. Free Spire.Presentation has the DLLs ...

  2. How to Create PowerPoint Presentation using C#

    Steps to Create PowerPoint Presentation using C#. Download and install Aspose.Slides for .NET package from the NuGet. Use Aspose.Slides, Aspose.Slides.Export and System.Drawing namespaces in your project. Create an empty presentation by using the instance of the Presentation class. Add a slide with a Blank Layout type inside the presentation ...