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: [email protected]
ReportedBy: [email protected]
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: [email protected]
For additional commands, e-mail: [email protected]