poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 60848] SUMPRODUCT fails when first arg is of form --(...)
Date Tue, 21 Mar 2017 15:29:30 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=60848

--- Comment #2 from mewalig@gmail.com ---
It's as simple as evaluating a sumproduct whose first arg starts with --.

--- Sample files ---
 bad.xlsx: in A3, set formula to
     =SUMPRODUCT(--(B5:B20))

--- Test results ---
Running the sample code below, you will get:
  java sampleApp good.xlsx
    <prints "No error">
  java sampleApp bad.xlsx
    <prints "Invalid arg type for
SUMPRODUCT:(org.apache.poi.ss.formula.eval.ErrorEval)">

--- Sample code ---

    private static final String FILE_NAME = "test.xlsx";

    public static void main(String[] args) {
        try {
            FileInputStream excelFile = new FileInputStream(new
File(FILE_NAME));
            Workbook workbook = new XSSFWorkbook(excelFile);

            // get the cell with the offending formula (cell A3 in sheet 0)
            Cell c = workbook.getSheetAt(0).getRow(2).getCell(0);

            FormulaEvaluator evaluator =
workbook.getCreationHelper().createFormulaEvaluator();

            evaluator.evaluateFormulaCell(c);

            System.out.println("No error");
        } catch(Exception e) {
            System.out.println("There was an error");
            System.out.println(e.getMessage());
        }
    }

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


Mime
View raw message