We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Set datalabel text

Hi everyone,


I’m working with aspose_cells version 7.3.4.4.
and i’m trying to create excel file with xls format.

I’m trying to set the datalabel of a a chart using this :

charts.add(ChartType.COLUMN_3_D_STACKED,5,0,20,10);
chart = charts.get(chartIndex);
serieses = chart.getNSeries();
serieses.add(“A1:B3”, true);

for (int i = 0; i < chart.getNSeries().getCount(); i++){
datalabels = chart.getNSeries().get(i).getDataLabels();
datalabels.setShowValue(true);
datalabels.setText(cells1.get(0,i).getStringValue());
}

But the label is never changed.

Am i doing anything wrong ?
Is this possible to do so with the version of aspose_cells and excel ?

Thanks for your help.
Benoit

Hi,


Well, I think you should loop through the series data points and then access data label for particular point to set your desired custom text changed, see the sample lines of code for your reference:
e.g
Sample code:

//Get the data labels in the data series of the first data point.
DataLabels datalabels = chart.getNSeries().get(0).getPoints().get(0).getDataLabels();

//Change the text of the label.
datalabels.setText(cells1.get(0,0).getStringValue());


If you still find the issue, kindly paste your complete sample code (runnable) and attach your template Excel file here, we will check it soon.

Thank you.



Hi,


It is working very fine this way !
(i just had to had : datalabels.setShowValue(true);
for futher use my final code is :
//Get the data labels in the data series of the first data point.
DataLabels datalabels = chart.getNSeries().get(0).getPoints().get(0).getDataLabels();

//allow the display of the value
datalabels.setShowValue(true);

//Change the text of the label.
datalabels.setText(cells1.get(0,0).getStringValue());
)

Many thanks for your help and the fast and sharp answer !

Benoit

Hi,


Good to know that it figures out your issue now. Feel free to write back in case you have further comments or questions, we will be happy to assist you soon.

Thank you.