Summary: | Unable to get Chart Axis | ||
---|---|---|---|
Product: | POI | Reporter: | srivastavavijay |
Component: | XSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | critical | CC: | srivastavavijay |
Priority: | P2 | Keywords: | PatchAvailable |
Version: | 3.10-FINAL | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | All | ||
Attachments: | SampleExcel |
Description
srivastavavijay
2014-12-17 08:00:43 UTC
Can you produce a small junit unit test showing this problem? And ideally also a patch if you can see the right fix! Created attachment 32306 [details]
SampleExcel
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; } 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. (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. |