Please Help! Change Axis labels using XSSFValueAxis or ValueAxis class

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Please Help! Change Axis labels using XSSFValueAxis or ValueAxis class

ranzhang35
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

ranzhang35
can someone give some hints?



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Greg Woolsey
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 <[hidden email]> wrote:

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