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 2015/04/08 10:24:21 UTC

[Bug 57798] New: Getting java.lang.IllegalStateException: Only formula cells have cached results for array formulas

https://bz.apache.org/bugzilla/show_bug.cgi?id=57798

            Bug ID: 57798
           Summary: Getting java.lang.IllegalStateException: Only formula
                    cells have cached results for array formulas
           Product: POI
           Version: 3.12-dev
          Hardware: PC
            Status: NEW
          Severity: major
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: ftz@rmb.co.za

Created attachment 32637
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=32637&action=edit
xlsx version

The method cell.getCachedFormulaResultType() returns an exception when the cell
is part of an array formula and is not the first cell of the array formula.

This exception is not occurring with a HSSFWorkbook.

See sample code below and file attached.
You'll need to save the .xlsx version as .xls in Excel to run the working test
case.



import java.io.FileInputStream;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;

public class TestXssf {

    public static void main(String[] args) throws Exception {

        String fileName = "Test.xlsx";
//        String fileName = "Test.xls";

        FileInputStream inputStream = new FileInputStream(fileName);
        Workbook workbook = WorkbookFactory.create(inputStream);

        Sheet sheet = workbook.getSheet("Sheet1");

        // *******************************
        // First cell of array formula, OK
        int rowId = 0;
        int cellId = 1;
        System.out.println("Reading row " + rowId + ", col " + cellId);

        Row row = sheet.getRow(rowId);
        Cell cell = row.getCell(cellId);

        System.out.println("Formula:" + cell.getCellFormula());
        if (Cell.CELL_TYPE_FORMULA == cell.getCellType()) {
            int formulaResultType = cell.getCachedFormulaResultType();
            System.out.println("Formual Result Type:" + formulaResultType);
        }

        // *******************************
        // Second cell of array formula, NOT OK for xlsx files  
        rowId = 1;
        cellId = 1;
        System.out.println("Reading row " + rowId + ", col " + cellId);

        row = sheet.getRow(rowId);
        cell = row.getCell(cellId);
        System.out.println("Formula:" + cell.getCellFormula());

        if (Cell.CELL_TYPE_FORMULA == cell.getCellType()) {
            int formulaResultType = cell.getCachedFormulaResultType();
            System.out.println("Formual Result Type:" + formulaResultType);
        }

        workbook.close();

    }
}

-- 
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 57798] Getting java.lang.IllegalStateException: Only formula cells have cached results for array formulas

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

--- Comment #1 from ftz@rmb.co.za ---
Created attachment 32638
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=32638&action=edit
xls version

-- 
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 57798] Getting java.lang.IllegalStateException: Only formula cells have cached results for array formulas

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

abel.stephan@web.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |abel.stephan@web.de

-- 
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 57798] Getting java.lang.IllegalStateException: Only formula cells have cached results for array formulas

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

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

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

--- Comment #2 from Dominik Stadler <do...@gmx.at> ---
I could not reproduce this with the latest trunk, can you try if it was
actually fixed by some change already now?

-- 
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 57798] Getting java.lang.IllegalStateException: Only formula cells have cached results for array formulas

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 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 57798] Getting java.lang.IllegalStateException: Only formula cells have cached results for array formulas

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |RESOLVED
         Resolution|---                         |WORKSFORME

--- Comment #3 from Dominik Stadler <do...@gmx.at> ---
I have added a uni-test which verifies that this works for us, see r1746624 for
the test. Please reopen this bug if this is still a problem for you with the
latest version of POI.

-- 
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