Create a Chart in a Microsoft PowerPoint Presentation

Creating a Chart

The code examples below describe the process of adding a simple 3D clustered column chart using VSTO. You create a presentation instance, add a default chart to it. Then use Microsoft Excel workbook to access and modify chart data along with setting chart properties. Lastly, save the presentation.

VSTO Example

Using VSTO, the following steps are performed:

  1. Create an instance of a Microsoft PowerPoint presentation.
  2. Add a blank slide to the presentation.
  3. Add a 3D clustered column chart and access it.
  4. Create a new Microsoft Excel Workbook instance and load chart data.
  5. Access the chart data worksheet using Microsoft Excel Workbook instancefromworkbook.
  6. Set the chart range in the worksheet and remove series 2 and 3 from the chart.
  7. Modify the chart category data in the chart data worksheet.
  8. Modify chart series 1 data in the chart data worksheet.
  9. Now, access the chart title and setthefontrelatedproperties.
  10. Access the chart value axis and set the major unit, minor units, max value and min values.
  11. Access the chart depth or series axis and remove that as in this example, onlyoneserieisused.
  12. Now, set the chart rotation angles in X and Y direction.
  13. Save the presentation.
  14. Close the instances of Microsoft Excel and PowerPoint.

The output presentation, created with VSTO

todo:image_alt_text

Aspose.Slides for Java Example

Using Aspose.Slides for Java, the following steps are performed:

  1. Create an instance of a Microsoft PowerPoint presentation.
  2. Add a blank slide to the presentation.
  3. Add a 3D clustered column chart and access that.
  4. Access the chart data worksheet using a Microsoft Excel Workbook instancefromworkbook.
  5. Remove unused series 2 and 3.
  6. Access chart categories and modify the labels.
  7. Accesseries1 and modify the series values.
  8. Now, access the chart title and set the font properties.
  9. Access the chart value axis and set the major unit, minor units, max value and min values.
  10. Now, set the chart rotation angles in X and Y direction.
  11. Save the presentation to PPTX format.

The output presentation, created with Aspose.Slides

todo:image_alt_text