Aspose.Slides  for C++

PPT Formats Charts in C++

Native and high performance PPT document charts using server-side Aspose.Slides for C++ APIs, without the use of any software like Microsoft or Adobe PDF.

Create PPT File Charts Using C++

In order to search PPT file, we’ll use

Aspose.Slides for C++

API which is a feature-rich, powerful and easy to use document searching API for C++ platform. You can download its latest version directly, just open


package manager, search for Aspose.Slides.Cpp and install. You may also use the following command from the Package Manager Console.


PM> Install-Package Aspose.Slides.Cpp

How to Create PPT Files Charts in C++

A basic document charting with Aspose.Slides for C++ APIs can be done with just few lines of code.

  1. Instantiate Presentation class.

  2. Access first slide.

  3. Add chart with default data

  4. Set the index of chart data sheet.

  5. Get the chart data workbook.

  6. Set chart Title.

  7. Delete default generated series and categories.

  8. Add series and categories.

  9. Take first chart series and populate data.

  10. Set fill color for series.

  11. Save PPT file.

System Requirements

Aspose.Slides for C++ supports on all major platforms and Operating Systems. Please make sure that you have the following prerequisites.

  • Microsoft Windows or a compatible OS with C++ Runtime Environment for Windows 32 bit, Windows 64 bit and Linux 64 bit.
  • Aspose.Slides for C++ DLL referenced in your project.

Create PPT Files Chart - C++

// Output File Path.
const String outputFilePath = u"OutputDirectory\\column_chart.ppt";

// Instantiate Presentation class
SharedPtr<Presentation> pres = MakeObject<Presentation>();

// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);

// Add chart with default data
SharedPtrv<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::ClusteredColumn, 0, 0, 500, 500);

// Setting the index of chart data sheet
int defaultWorksheetIndex = 0;

// Getting the chart data workbook
SharedPtr<IChartDataWorkbook> fact = chart->get_ChartData()->get_ChartDataWorkbook();

// Setting chart Title
chart->get_ChartTitle()->AddTextFrameForOverriding(u"Sample Title");

// Delete default generated series and categories
int s = chart->get_ChartData()->get_Series()->get_Count();
s = chart->get_ChartData()->get_Categories()->get_Count();

// Add series
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 1, ObjectExt::Box<System::String>(u"Series 1")), chart->get_Type());
chart->get_ChartData()->get_Series()->Add(fact->GetCell(defaultWorksheetIndex, 0, 2, ObjectExt::Box<System::String>(u"Series 2")), chart->get_Type());

// Add categories
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 1, 0, ObjectExt::Box<System::String>(u"Category 1")));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 2, 0, ObjectExt::Box<System::String>(u"Category 2")));
chart->get_ChartData()->get_Categories()->Add(fact->GetCell(defaultWorksheetIndex, 3, 0, ObjectExt::Box<System::String>(u"Category 3")));

// Take first chart series
SharedPtr<IChartSeries> series = chart->get_ChartData()->get_Series()->idx_get(0);

// Populate series data
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 1, 1, ObjectExt::Box(20)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 2, 1, ObjectExt::Box(50)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 3, 1, ObjectExt::Box(30)));

// Setting fill color for series

// Take second chart series
series = chart->get_ChartData()->get_Series()->idx_get(1);

// Populate series data
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 1, 2, ObjectExt::Box(30)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 2, 2, ObjectExt::Box(10)));
series->get_DataPoints()->AddDataPointForBarSeries(fact->GetCell(defaultWorksheetIndex, 3, 2, ObjectExt::Box(60)));

// Setting fill color for series

// First label will be show Category name
SharedPtr<IDataLabel> lbl = series->get_DataPoints()->idx_get(0)->get_Label();

lbl = series->get_DataPoints()->idx_get(1)->get_Label();

// Show value for third label
lbl = series->get_DataPoints()->idx_get(2)->get_Label();

// Save PPT file
pres->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Ppt);  

  • About Aspose.Slides for C++ API

    Generate PPT documents charts right now by visiting our

    Live Demos website

    . The live demo has the following benefits

    Online PPT Chart Creation Live Demos

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

      No need to download Aspose API.
      No need to write any code.
      Just upload your PPT files.
      Chart will be created instantly.

    PPT What is PPT File Format?

    A file with PPT extension represents PowerPoint file that consists of a collection of slides for displaying as SlideShow. It specifies the Binary File Format used by Microsoft PowerPoint 97-2003. A PPT file can contain several different types of information such as text, bulleted points, images, multimedia and other embedded OLE objects. Microsoft came up with newer file format for PowerPoint, known as PPTX, from 2007 onwards that is based on Office OpenXML and is different from this binary file format. Several other application programs such as OpenOffice Impress and Apple Keynote can also create PPT files.

    Read More

    Other Supported Charting Formats

    Using C++, one can easily deal charing with different formats including.

    PPTX (Open XML presentation Format)