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 2009/02/11 10:35:10 UTC

DO NOT REPLY [Bug 46692] New: Boolean formula evaluation inverts result

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

           Summary: Boolean formula evaluation inverts result
           Product: POI
           Version: 3.2-FINAL
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: regression
          Priority: P2
         Component: HSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: nick.giles@ontology.com


It appears that the result of boolean formulae is being inverted when
calculated. The following test case currently fails:

    public void testBooleanFunctions() {
        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet sheet = workbook.createSheet("test");
        HSSFRow row = sheet.createRow(0);

        HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(workbook);

        HSSFCell cell = row.createCell(0);

        cell.setCellFormula("AND(TRUE,TRUE)");
        evaluator.evaluateFormulaCell(cell);
        assertEquals("Should get correct boolean value", true,
cell.getBooleanCellValue());

        cell = row.createCell(1);
        cell.setCellFormula("AND(TRUE,FALSE)");
        evaluator.evaluateFormulaCell(cell);
        assertEquals("Should get correct boolean value", false,
cell.getBooleanCellValue());

    }

It appears there is a mismatch in
org.apache.poi.hssf.record.FormulaRecord.SpecialCachedValue between the logic
of createCachedBoolean and getBooleanValue

public static SpecialCachedValue createCachedBoolean(boolean b) {
  return create(BOOLEAN, b ? 0 : 1);
}

public boolean getBooleanValue() {
 ...
 return getDataValue() != 0;
}


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- 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


DO NOT REPLY [Bug 46692] Boolean formula evaluation inverts result

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


Josh Micich <jo...@gildedtree.com> changed:

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




--- Comment #1 from Josh Micich <jo...@gildedtree.com>  2009-02-11 10:20:12 PST ---
Thanks for the detailed bug report.  This typo was spotted during the work on
bug 46479 , and fixed in svn r731715 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=731715 ).  There were a few extra bugs found and
fixed at the same time.  Junits were added for all fixed bugs but only the
original bug is described in the bugzilla record. The bug you describe here
(inverted conditinal operator) is identified by this junit:
TestFormulaRecord.testCachedValue_bug46479().


This fix made it into the recent release, 3.5-beta5.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- 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