Setting Number Format for Chart Data Cell using Aspose.Slides

Aspose.Slides - Setting Number Format for Chart Data Cell

Aspose.Slides for Java provides a simple API for managing chart data format:

  1. Create an instance of the Presentation class.
  2. Obtain a slide’s reference by its index.
  3. Add a chart with default data along with the any of desired type (this example usesChartType.ClusteredColumn).
  4. Set the preset number format from the possible preset values.
  5. Traverse through the chart data cell in every chart series and set the chart data number format.
  6. Save the presentation.
  7. Set the custom number format.
  8. Traverse through chart data cell inside every chart series and setting a different chart data number format.
  9. Save the presentation.


 // Instantiate the presentation//Instantiate the presentation

Presentation pres = new Presentation();

// Access the first presentation slide

ISlide slide = pres.getSlides().get_Item(0);

// Adding a defautlt clustered column chart

IChart chart = slide.getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 500, 400);

// Accessing the chart series collection

IChartSeriesCollection series = chart.getChartData().getSeries();

// Setting the preset number format

// Traverse through every chart series

for (IChartSeries ser : series)


    // Traverse through every data cell in series

    for (IChartDataPoint cell : ser.getDataPoints())


	// Setting the number format

	cell.getValue().getAsCell().setPresetNumberFormat((byte) 10); // 0.00%



// Saving presentation + "AsposePresetNumberFormat.pptx", SaveFormat.Pptx);

Download Running Code

Download Sample Code