How to set Series Datalabel show?

Workbook wb = new Workbook("C:/Labels.xlsx");
Chart chart = wb.getWorksheets().get(0).getCharts().get(0);
SeriesCollection nSeries = chart.getNSeries();
for (int i = 0; i < nSeries.getCount(); i++) {
Series series = nSeries.get(i);
series.getDataLabels().setShowValue(true);
}
wb.calculateFormula();
wb.save("C:/Labels2.xlsx");


But Datalabels not added. How to make all series's datalabes show?

Hi Xiong,


Thank you for contacting Aspose support.

I have evaluated the presented scenario while using the latest version of Aspose.Cells for Java 8.7.0, and I was not able to show the chart’s data labels. This is because the chart in the provided spreadsheet is not valid. As you can see from the attached snapshot that the chart’s data range is empty. Could you please provide details on the origin of the specified file? Have you built it using Aspose.Cells APIs? If yes, please share your complete code for the generation.

Please note the chart’s data is too complex to show in char data textbox


You can select each series and edit it to show you the reference.


And I can add datalabel in MS Excel 2013 by click datalabel checkbox, see my screenshot.


How I can do this using Aspose Cells?

This file isn’t created by aspose.


I just want to modification by aspose.

Hi Xiong,


Thank you for the information.

Please set the DataLabels.Deleted property to false as demonstrated below. It should enable/show the missing data labels.

Java

Workbook wb = new Workbook(dir + “Labels.xlsx”);
Chart chart = wb.getWorksheets().get(0).getCharts().get(0);
SeriesCollection nSeries = chart.getNSeries();
for (int i = 0; i < nSeries.getCount(); i++)
{
Series series = nSeries.get(i);
series.getDataLabels().setDeleted(false);
}
wb.calculateFormula();
wb.save(dir + “Labels2.xlsx”);