Label above Histogram Columns

I try to implements in java with Aspose.Cell this:

ActiveSheet.ChartObjects("Grafico 2").Activate

axisTop = ActiveChart.Axes(2).Top
axisH = ActiveChart.Axes(2).Height
maxY = ActiveChart.Axes(2).MaximumScale

For j = 1 To ActiveChart.SeriesCollection.Count

For i = 1 To ActiveChart.SeriesCollection(j).Points.Count
labelTop = ActiveChart.SeriesCollection(j).Points(i).DataLabel.Top + 10
value = ActiveChart.SeriesCollection(j).Points(i).DataLabel.Caption
fatt = axisH * value / maxY
Selection.Top = fatt / 2 + labelTop
Next i
Next j

In excel vba macro this code does what I need.

I have to move the value-label of histogram column from top to center of histogram,

It is possible in Aspose.Cell with java? Thanks and excuse me for my english.


I think you may use Chart APIs, see the Aspose.Cells.Charts namepsace. For example, you may use Chart.ChartObjects.Top/Height APIs to set/get the chart’s height and top position accordingly. Also there are DataLables.Width/X/Y etc. attributes that you may find.

Thank you.


thanks for answer, but I have try to use what you suggest me but I retrieve always 0 values, ex:

int left = chart.getNSeries().get(0).getDataLabels().getX();

int top = chart.getNSeries().get(0).getDataLabels().getY();

int width = chart.getNSeries().get(0).getDataLabels().getWidth();

int height = chart.getNSeries().get(0).getDataLabels().getHeight();

the result is:

left = top = width =height = 0.

Instead if I use my macro in excel it work fine.

Then I need also to acces graphic-axis object to obtain height property to calculate the factor to use for this formula (axisH):

axisTop = ActiveChart.Axes(2).Top (not have)
axisH = ActiveChart.Axes(2).Height (not have)
MaxY = ActiveChart.Axes(2).MaximumScale (this I have)
For j = 1 To ActiveChart.SeriesCollection.Count
For i = 1 To ActiveChart.SeriesCollection(j).Points.Count
tmpTop = ActiveChart.SeriesCollection(j).Points(i).DataLabel.Top + 10 (not have)
value = ActiveChart.SeriesCollection(j).Points(i).DataLabel.Caption (I have)
fatt = axisH * value / MaxY
Selection.Top = fatt / 2 + tmpTop
Next i
Next j

Please help me, I Have a finicky customer that wants a histogram with value column labels in the middle of 3d bar chart. Sigh! I can project my chart in excel and then set data from java-aspose code, but this is ok for graph with fixed x-axis value, I have some other with dynamic x-axis value. For now I can try to use vba-macro in excel but I must resolve problem to excute macro when user open the excel document, however I will prefer to do all in java-aspose code.



Please provide us your sample output xls/xlsx file which you can create manually and attach here. We will look into it and provide you a sample code. Please also help us with screenshots.

Also, some chart series do not let you position the labels so you have to use different type of chart in your series.

For help, please see this post: 335816 and see the red highlighted code. The code is in .NET but it will give you an idea how to place your labels at the desired position.

Report.xlsx is start file, I 'll wish to obtain ReportOut.xlsx through java-aspose.cell code.

I tried to use :










but I alway get zero as result

It seem that these methods are to be implemented, it is true?

I got my goal with an excel-vba-macro, but I seemed to understand that you can not execute a macro from java-aspose.cell code. However I would not use macros.



I am afraid, Aspose.Cells does not support getting the position of the datalabels or axis at the moment. We will look into and try to provide you the supported version in 2 weeks time.

We have logged a ticket for your feature request with an id: CELLSJAVA-40019. Once we have any update, we will let you know.

Keep in touch.

Thanks for your quick reply.

I look forward to news...


To update you further, I’m afraid the feature cannot be supported in the near future. The reason is to support setting customized position, we need to do a lot of adjustments accordingly and it might take some time to do it.

Thank you.

Sigh! :-(

Thanks anyway.


Please try our latest version v7.1.2.5. We have supported to set
customized position for data labels. Please refer to the attached code segments.

Thank you.


We have now released our next official version Aspose.Cells for Java v7.2.0, so you should try it:

Thank you.