Hi I am unable to make changes to the IPortionFormat of an IDataLabel to Bold the font, change the color, and change the font type. I’ve been research, looking over, and even updated to the latest version of aspose slides in my java springboot project and it is still not working.
Screenshot 2025-10-29 at 10.40.13 PM.png (244.1 KB)
Screenshot 2025-10-29 at 10.39.55 PM.png (76.1 KB)
@hekp100
It seems you’re having trouble modifying the IPortionFormat of an IDataLabel in Aspose.Slides to change the font style, color, and type. Here’s a basic example of how to achieve this in Java:
import com.aspose.slides.*;
public class ModifyDataLabel {
public static void main(String[] args) {
// Load your presentation
Presentation presentation = new Presentation("your_presentation.pptx");
// Access the first slide
ISlide slide = presentation.getSlides().get_Item(0);
// Access the first shape (assuming it's a chart with data labels)
IChart chart = (IChart) slide.getShapes().get_Item(0);
// Access the data label
IDataLabel dataLabel = chart.getChartData().getSeries().get_Item(0).getDataLabels();
// Modify the font properties
IPortionFormat portionFormat = dataLabel.getTextFormat().getPortions().get_Item(0).getPortionFormat();
portionFormat.setBold(true);
portionFormat.setFontColor(Color.RED); // Change to your desired color
portionFormat.setFontHeight(12); // Set your desired font size
// Save the modified presentation
presentation.save("modified_presentation.pptx", SaveFormat.Pptx);
}
}
Ensure that you are accessing the correct data label and that the chart has data labels enabled. If you continue to face issues, please verify that the chart type supports data labels and that the version of Aspose.Slides you are using is compatible with your code.
For additional assistance, consider checking the official Aspose documentation or community forums for similar issues and solutions.
@hekp100,
I was unable to reproduce the problem you encountered. The following code example works fine with Aspose.Slides for Java 25.10:
Presentation presentation = new Presentation("sample.pptx");
ISlide slide = presentation.getSlides().get_Item(0);
IChart chart = (IChart) slide.getShapes().get_Item(0);
IChartSeries chartSeries = chart.getChartData().getSeries().get_Item(0);
IChartDataPoint dataPoint = chartSeries.getDataPoints().get_Item(0);
IChartPortionFormat portionFormat = dataPoint.getLabel().getDataLabelFormat().getTextFormat().getPortionFormat();
portionFormat.setFontBold(NullableBool.True);
portionFormat.getFillFormat().setFillType(FillType.Solid);
portionFormat.getFillFormat().getSolidFillColor().setColor(Color.green);
portionFormat.setLatinFont(new FontData("Arial"));
portionFormat.setFontHeight(20);
presentation.save("output.pptx", SaveFormat.Pptx);
presentation.dispose();
Files:
files.zip (77.5 KB)
More examples:
Create or Update PowerPoint Presentation Charts in Java|Aspose.Slides Documentation
Chart Formatting|Aspose.Slides Documentation
I hope this will help you. If the issue persists, please share the presentation file and standalone code example to reproduce the issue. Then, we will do our best to help you.