You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by ranzhang35 <rz...@mkprod.com> on 2018/10/09 00:32:20 UTC

Please Help! Change Axis labels using XSSFValueAxis or ValueAxis class

How do I change the axis labels?  instead of showing 1, 2,3,....  I want to
show 1s, 2s, 3s

Please advise.



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Please Help! Change Axis labels using XSSFValueAxis or ValueAxis class

Posted by Greg Woolsey <gr...@gmail.com>.
You will have to use the underlying CT* classes, there is no good way to do
it with the POI API directly.  This is partly because Excel determines the
axis label from either a formula or static text, each stored as different
properties in the underlying XML, and mutually exclusive.

Your best option is to open a sample file in Excel, edit the title you want
to change, save it as a new file, then unzip both files and compare their
contents.  This will show you where in the XML your new value is stored.
From that, you can deduce the CT object path you will need to use to set
your value.

When I get the axis title, I have to go from the chart axis object lists:

XSSFChart.getCTChart().getPlotArea().getCatAxList()
XSSFChart.getCTChart().getPlotArea().getValAxList()
XSSFChart.getCTChart().getPlotArea().getDateAxList()
XSSFChart.getCTChart().getPlotArea().getSerAxList()

then for each axis element in each list:

CT*Ax.getTitle()

Then, with each axis CTTitle, you can either set a reference formula
expression or RichText static text.

You will need to check for existing objects and update them, remove them,
or add new instances if missing using the standard XMLBeans manipulation
methods.

If you are switching from one type of title to the other, i.e. from a
formula to static text, don't forget to remove the object nodes for the
title property you are replacing.

On Wed, Oct 10, 2018 at 8:26 AM ranzhang35 <rz...@mkprod.com> wrote:

> can someone give some hints?
>
>
>
> --
> Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

Re: Please Help! Change Axis labels using XSSFValueAxis or ValueAxis class

Posted by ranzhang35 <rz...@mkprod.com>.
can someone give some hints?



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org