Syncfusion Feedback

Work with Charts Using Syncfusion .NET PowerPoint Library

The Syncfusion® .NET PowerPoint Library allows you to create, remove, and customize 75+ types of charts in PowerPoint presentations using C#, without Microsoft PowerPoint or interop dependencies.

Watch this video to learn how to create charts in a PowerPoint using the Syncfusion .NET PowerPoint library.

Watch the video

Create PowerPoint charts using C#

Learn how to create and customize charts in PowerPoint presentations programmatically using C# with the Syncfusion .NET PowerPoint library. This guide demonstrates adding various chart types and populating data to visualize information effectively.

Step 1: Create a new project

Start by creating a new C# Console Application project.

Step 2: Install the NuGet package

Add the Syncfusion.Presentation.Net.Core package to your project from NuGet.org.

Step 3: Add required namespaces to create PowerPoint charts

Add the following namespaces to your Program.cs file:

using Syncfusion.OfficeChart;
using Syncfusion.Presentation;

Step 4: Create a PowerPoint presentation

Create a new presentation and add a blank slide.

Run

//Create a new instance of PowerPoint Presentation file
IPresentation pptxDoc = Presentation.Create();
//Add a blank slide to the Presentation
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);

Step 5: Add a chart and populate data

Add a clustered column chart to the slide and populate it with sales data.

//Add chart to the slide with position and size
IPresentationChart chart = slide.Charts.AddChart(100, 10, 700, 500);
//Specify the chart title
chart.ChartTitle = "Sales Analysis";
//Set chart data - Row1
chart.ChartData.SetValue(1, 2, "Jan");
chart.ChartData.SetValue(1, 3, "Feb");
chart.ChartData.SetValue(1, 4, "March");

//Set chart data - Row2
chart.ChartData.SetValue(2, 1, 2010);
chart.ChartData.SetValue(2, 2, 60);
chart.ChartData.SetValue(2, 3, 70);
chart.ChartData.SetValue(2, 4, 80);

//Set chart data - Row3
chart.ChartData.SetValue(3, 1, 2011);
chart.ChartData.SetValue(3, 2, 80);
chart.ChartData.SetValue(3, 3, 70);
chart.ChartData.SetValue(3, 4, 60);

//Set chart data - Row4
chart.ChartData.SetValue(4, 1, 2012);
chart.ChartData.SetValue(4, 2, 60);
chart.ChartData.SetValue(4, 3, 70);
chart.ChartData.SetValue(4, 4, 80);

//Create a new chart series with the name
IOfficeChartSerie seriesJan = chart.Series.Add("Jan");
//Set the data range of chart series – start row, start column, end row, end column
seriesJan.Values = chart.ChartData[2, 2, 4, 2];
//Create a new chart series with the name
IOfficeChartSerie seriesFeb = chart.Series.Add("Feb");
//Set the data range of chart series – start row, start column, end row, end column
seriesFeb.Values = chart.ChartData[2, 3, 4, 3];
//Create a new chart series with the name
IOfficeChartSerie seriesMarch = chart.Series.Add("March");
//Set the data range of chart series – start row, start column, end row, end column
seriesMarch.Values = chart.ChartData[2, 4, 4, 4];
//Set the data range of the category axis
chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 4, 1];
//Specify the chart type
chart.ChartType = OfficeChartType.Column_Clustered;

Step 6: Save the PowerPoint presentation

Save the presentation with the chart to a file stream.

//Save the PowerPoint presentation
FileStream outputStream = new(Path.GetFullPath(@"Output/Output.pptx"), FileMode.Create, FileAccess.ReadWrite);
pptxDoc.Save(outputStream);
//Close the output stream and presentation
outputStream.Close();
pptxDoc.Close();

Get started quickly by downloading the installer and checking license information on the Downloads page.

Syncfusion .NET PowerPoint Library Resources

Explore these resources for comprehensive guides, knowledge base articles, insightful blogs, and ebooks.