You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2014/12/17 09:00:43 UTC

[Bug 57362] New: Unable to get Chart Axis

https://issues.apache.org/bugzilla/show_bug.cgi?id=57362

            Bug ID: 57362
           Summary: Unable to get Chart Axis
           Product: POI
           Version: 3.10-FINAL
          Hardware: PC
            Status: NEW
          Severity: critical
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: srivastavavijay@gmail.com

I have excel having chart with primary and secondary axis.  I am to retrieve
the chart Axis details to update the maximum value. 

I am having XSSFSheet instance after loading the given excel on which i am
retrieving drawing and chart as below:

        final XSSFDrawing drawing = xsh.createDrawingPatriarch();
        final XSSFChart chart = drawing.getCharts().get(0);
        final List<XSSFChartAxis> axisList = (List<XSSFChartAxis>)
chart.getAxis();

While debugging, it seems that XSSFChart.getAxis() is not having null check on
axis variable and its not initialized. Its just checking the empty check. Which
is why its failing. axis is initialized in the constructor. However in this
case, its not initialized.

I think in this case it should not come as null or it should be initialized on
getAxis also.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 57362] Unable to get Chart Axis

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57362

--- Comment #5 from srivastavavijay@gmail.com ---
(In reply to Dominik Stadler from comment #4)
> Thanks for the Patch, this is now applied via r1647317, although I reworked
> it slightly to not need to query in getAxis() constantly, we rather now
> create the List of Axises always.

Thanks for applying the patch.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 57362] Unable to get Chart Axis

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57362

Nick Burch <ap...@gagravarr.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #1 from Nick Burch <ap...@gagravarr.org> ---
Can you produce a small junit unit test showing this problem? And ideally also
a patch if you can see the right fix!

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 57362] Unable to get Chart Axis

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57362

srivastavavijay@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

--- Comment #3 from srivastavavijay@gmail.com ---
I just downloaded the src from svn and trying to get used to build process and
creating patch . 
Meanwhile I just provide the test case and possible fix (which, I had tried out
to be working).

Test Examples:
//Load existing excel with some chart on it having primary and secondary axis.
final File res = new File("SampleExcel.xlsx");
final Workbook workbook = new XSSFWorkbook(OPCPackage.open(new
FileInputStream(res)));
        final Sheet sh = workbook.getSheetAt(0);
        final XSSFSheet xsh = (XSSFSheet) sh;
        final XSSFDrawing drawing = xsh.createDrawingPatriarch();
        final XSSFChart chart = drawing.getCharts().get(0);
        final List<XSSFChartAxis> axisList = (List<XSSFChartAxis>)
chart.getAxis();
//Note: getAxis fails as axis variable inside chart is null.
        for(XSSFChartAxis axis: axisList){
           //Do Some operation.
        }


Fix:XSSFChart.java
=====================
public List<? extends XSSFChartAxis> getAxis() 
{
 //ADDED NULL Check and Initialize the axis.
 if(axis == null){
   axis = new ArrayList<XSSFChartAxis>();
 }
 if (axis.isEmpty() && hasAxis()) {
   parseAxis();
 }
return axis;
}

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 57362] Unable to get Chart Axis

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57362

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |PatchAvailable

--- Comment #4 from Dominik Stadler <do...@gmx.at> ---
Thanks for the Patch, this is now applied via r1647317, although I reworked it
slightly to not need to query in getAxis() constantly, we rather now create the
List of Axises always.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 57362] Unable to get Chart Axis

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57362

--- Comment #2 from srivastavavijay@gmail.com ---
Created attachment 32306
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=32306&action=edit
SampleExcel

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 57362] Unable to get Chart Axis

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57362

srivastavavijay@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |srivastavavijay@gmail.com
                 OS|                            |All

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 57362] Unable to get Chart Axis

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57362

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

-- 
You are receiving this mail because:
You are the assignee for the bug.

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