PNG JPG BMP TIFF PPT
Aspose.Slides  for .NET
PPT

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

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. Select an ISlide object from the presentation.

  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.

  • Microsoft Windows or a compatible operating system with .NET Framework, .NET Core, Windows Azure, Mono, or Xamarin.
  • 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.
 

Create PPT Files Chart - 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);
 
  • About Aspose.Slides for .NET API

    Aspose.Slides for .NET can read, write, manipulate, and convert presentation documents to formats such as PDF, XPS, HTML, TIFF, and ODP. You can create charts and diagrams in presentation files or generate them from data.

    Online PPT Chart Creation Live Demos

    Generate charts in PPT documents by visiting the Live Demos website . The live demo has the following benefits.

      No need to download Aspose API.
      No need to write any code.
      Upload your PPT files.
      Charts are created instantly.

    PPT 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 Charting Formats

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

    PPTX (Open XML Presentation Format)