# Add Charts to PPT Presentations using Java

> Add charts to PPT presentations in Java. Use Aspose.Slides for Java to create chart series, categories, data labels, and formatting.

Source: https://products.aspose.com/slides/java/chart/ppt/
Updated: 2026-08-11



## Create Charts in PPT Files Using Java

Use [Aspose.Slides for Java](/slides/java/) to create and format charts in `PPT` presentations. The API provides chart objects such as `IChart`, `IChartDataWorkbook`, `IChartSeries`, and `IDataLabel`. You can install the `aspose-slides` package in a Maven-based project by adding the repository and dependency below.

### Repository

```xml
<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://releases.aspose.com/java/repo/</url>
</repository>
```

### Dependency

```xml
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-slides</artifactId>
    <version>version of aspose-slides API</version>
    <classifier>jdk17</classifier>
</dependency>
```

## How to Create Charts in PPT Files in Java

Create charts in PPT files with Aspose.Slides for Java.

Create a `Presentation` object.

Get the first `ISlide` from the presentation.

Add an `IChart` object with default data.

Set the chart title and data label options.

Get the `IChartDataWorkbook` object and clear default series and categories.

Add new chart series and categories.

Populate series data and set series fill colors.

Create custom data labels for the chart series.

Save the presentation with the chart.

## System Requirements

Aspose.Slides for Java supports major desktop and server platforms. Make sure that your project has these prerequisites.

-  Microsoft Windows, Linux, macOS, or another OS with a supported Java Runtime Environment.
-  Get the latest version of Aspose.Slides for Java from [Maven](https://releases.aspose.com/java/repo/).

### Create a PPT Chart - Java

```java
Presentation presentation = new Presentation();
try {
    ISlide slide = presentation.getSlides().get_Item(0);
    IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 0, 0, 500, 500);

    chart.getChartTitle().addTextFrameForOverriding("Sales by quarter");
    chart.getChartTitle().getTextFrameForOverriding().getTextFrameFormat().setCenterText(NullableBool.True);
    chart.getChartTitle().setHeight(20);
    chart.setTitle(true);

    chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat().setShowValue(true);

    int defaultWorksheetIndex = 0;
    IChartDataWorkbook chartDataWorkbook = chart.getChartData().getChartDataWorkbook();

    chart.getChartData().getSeries().clear();
    chart.getChartData().getCategories().clear();

    chart.getChartData().getSeries().add(chartDataWorkbook.getCell(defaultWorksheetIndex, 0, 1, "Series 1"), chart.getType());
    chart.getChartData().getSeries().add(chartDataWorkbook.getCell(defaultWorksheetIndex, 0, 2, "Series 2"), chart.getType());

    chart.getChartData().getCategories().add(chartDataWorkbook.getCell(defaultWorksheetIndex, 1, 0, "Category 1"));
    chart.getChartData().getCategories().add(chartDataWorkbook.getCell(defaultWorksheetIndex, 2, 0, "Category 2"));
    chart.getChartData().getCategories().add(chartDataWorkbook.getCell(defaultWorksheetIndex, 3, 0, "Category 3"));

    IChartSeries firstSeries = chart.getChartData().getSeries().get_Item(0);
    firstSeries.getDataPoints().addDataPointForBarSeries(chartDataWorkbook.getCell(defaultWorksheetIndex, 1, 1, 20));
    firstSeries.getDataPoints().addDataPointForBarSeries(chartDataWorkbook.getCell(defaultWorksheetIndex, 2, 1, 50));
    firstSeries.getDataPoints().addDataPointForBarSeries(chartDataWorkbook.getCell(defaultWorksheetIndex, 3, 1, 30));
    firstSeries.getFormat().getFill().setFillType(FillType.Solid);
    firstSeries.getFormat().getFill().getSolidFillColor().setColor(java.awt.Color.RED);

    IChartSeries secondSeries = chart.getChartData().getSeries().get_Item(1);
    secondSeries.getDataPoints().addDataPointForBarSeries(chartDataWorkbook.getCell(defaultWorksheetIndex, 1, 2, 30));
    secondSeries.getDataPoints().addDataPointForBarSeries(chartDataWorkbook.getCell(defaultWorksheetIndex, 2, 2, 10));
    secondSeries.getDataPoints().addDataPointForBarSeries(chartDataWorkbook.getCell(defaultWorksheetIndex, 3, 2, 60));
    secondSeries.getFormat().getFill().setFillType(FillType.Solid);
    secondSeries.getFormat().getFill().getSolidFillColor().setColor(java.awt.Color.GREEN);

    IDataLabel firstDataLabel = secondSeries.getDataPoints().get_Item(0).getLabel();
    firstDataLabel.getDataLabelFormat().setShowCategoryName(true);

    IDataLabel secondDataLabel = secondSeries.getDataPoints().get_Item(1).getLabel();
    secondDataLabel.getDataLabelFormat().setShowSeriesName(true);

    IDataLabel thirdDataLabel = secondSeries.getDataPoints().get_Item(2).getLabel();
    thirdDataLabel.getDataLabelFormat().setShowValue(true);
    thirdDataLabel.getDataLabelFormat().setShowSeriesName(true);
    thirdDataLabel.getDataLabelFormat().setSeparator("/");

    presentation.save("chart-presentation.ppt", SaveFormat.Ppt);
} finally {
    presentation.dispose();
}
```

## About Aspose.Slides for Java API

Create `PPT` charts online by visiting our [Live Demos website](https://products.aspose.app/slides/chart). The live demo has the following benefits:

A PPT file is a Microsoft PowerPoint 97-2003 presentation file. It stores slides, text, images, multimedia, charts, and embedded objects in the binary PowerPoint file format used before the Open XML PPTX format.

## Other Supported Charting Formats

- [PPTX](/slides/java/chart/pptx/) — Open XML Presentation Format
