Create PPT Charts in C#

Build .NET applications that create charts in presentation files using server-side Aspose.Slides APIs.

Create PPT Charts Using C#

Use Aspose.Slides for .NET to create charts in PPT presentations. Install the package from NuGet or use the following Package Manager Console command.

Command

PM> Install-Package Aspose.Slides.NET

Create a Chart in PPT - C#

using var presentation = new Presentation();

var slide = presentation.Slides[0];
var chart = slide.Shapes.AddChart(ChartType.ScatterWithSmoothLines, 0, 0, 400, 400);
var defaultWorksheetIndex = 0;
var chartDataWorkbook = chart.ChartData.ChartDataWorkbook;

chart.ChartData.Series.Clear();
chart.ChartData.Series.Add(chartDataWorkbook.GetCell(defaultWorksheetIndex, 1, 1, "Series 1"), chart.Type);
chart.ChartData.Series.Add(chartDataWorkbook.GetCell(defaultWorksheetIndex, 1, 3, "Series 2"), chart.Type);

var firstSeries = chart.ChartData.Series[0];
firstSeries.DataPoints.AddDataPointForScatterSeries(
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 2, 1, 1),
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 2, 2, 3));
firstSeries.DataPoints.AddDataPointForScatterSeries(
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 3, 1, 2),
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 3, 2, 10));
firstSeries.Type = ChartType.ScatterWithStraightLinesAndMarkers;
firstSeries.Marker.Size = 10;
firstSeries.Marker.Symbol = MarkerStyleType.Star;

var secondSeries = chart.ChartData.Series[1];
secondSeries.DataPoints.AddDataPointForScatterSeries(
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 2, 3, 5),
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 2, 4, 2));
secondSeries.DataPoints.AddDataPointForScatterSeries(
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 3, 3, 3),
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 3, 4, 1));
secondSeries.DataPoints.AddDataPointForScatterSeries(
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 4, 3, 2),
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 4, 4, 2));
secondSeries.DataPoints.AddDataPointForScatterSeries(
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 5, 3, 5),
    chartDataWorkbook.GetCell(defaultWorksheetIndex, 5, 4, 1));
secondSeries.Marker.Size = 10;
secondSeries.Marker.Symbol = MarkerStyleType.Circle;

presentation.Save("AsposeScatterChart.ppt", SaveFormat.Ppt);

How to Create Charts in PPT Files Using C#

Create a chart in a PPT presentation with Aspose.Slides for .NET in a few lines of code.

  1. Create a Presentation object.
  2. Get the target slide from presentation.Slides.
  3. Call the AddChart method to add a chart to the slide.
  4. Add chart series and data points with IChartDataWorkbook.
  5. Save the presentation as a PPT file.

System Requirements

Aspose.Slides for .NET supports major platforms and operating systems. Make sure that your environment includes the following prerequisites.

  • A supported operating system with .NET or Mono installed.
  • A development environment such as Microsoft Visual Studio.
  • Aspose.Slides for .NET referenced in your project. Install it from NuGet or download it by using the Download button above.

Built with Aspose.Slides

Create PPT Charts Online

The free Aspose.Slides Chart app is built with Aspose.Slides for .NET, the same API as the code above. Open it and see what the API can do with your own PPT files.

  • Runs in your browser, nothing to install.
  • See how Aspose.Slides builds charts before you write code.
  • Build a chart from Excel or table data.
  • Download it as a PPT file or an image.

What is PPT File Format?

A PPT file stores a PowerPoint 97-2003 presentation in the binary file format. It can contain slides with text, charts, images, multimedia, and embedded objects.

Read More

Other Supported Chart Formats

Using C#, you can also create charts in other formats.