View | Details | Raw Unified | Return to bug 51498
Collapse All | Expand All

(-)src/java/org/apache/poi/ss/formula/functions/Countif.java (+8 lines)
Lines 217-222 Link Here
217
			} else if((x instanceof NumberEval)) {
217
			} else if((x instanceof NumberEval)) {
218
				NumberEval ne = (NumberEval) x;
218
				NumberEval ne = (NumberEval) x;
219
				testValue = ne.getNumberValue();
219
				testValue = ne.getNumberValue();
220
            } else if((x instanceof BlankEval)) {
221
                switch (getCode()) {
222
                    case CmpOp.NE:
223
                        // Excel counts blank values in range as not equal to any value. See Bugzilla 51498
224
                        return true;
225
                    default:
226
                        return false;
227
                }
220
			} else {
228
			} else {
221
				return false;
229
				return false;
222
			}
230
			}
(-)src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java (-10 / +1 lines)
Lines 369-387 Link Here
369
		final int REF_COL = 4;
369
		final int REF_COL = 4;
370
		final int EVAL_COL = 3;
370
		final int EVAL_COL = 3;
371
		
371
		
372
		// Note - POI currently agrees with OpenOffice on certain blank cell cases,
372
        HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("51498.xls");
373
		//  while Excel can differ. This is the list of checks to skip
374
		List<Integer> skipRowsPendingExcelVsOpenOffice = Arrays.asList(
375
		      new Integer[] {3});
376
377
      HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("51498.xls");
378
		FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
373
		FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
379
		HSSFSheet sheet = workbook.getSheetAt(0);
374
		HSSFSheet sheet = workbook.getSheetAt(0);
380
		for (int i = 0; i < 8; i++) {
375
		for (int i = 0; i < 8; i++) {
381
		   if (skipRowsPendingExcelVsOpenOffice.contains(i)) {
382
		      // Skip the check for now
383
		      continue;
384
		   }
385
			CellValue expected = evaluator.evaluate(sheet.getRow(i).getCell(REF_COL));
376
			CellValue expected = evaluator.evaluate(sheet.getRow(i).getCell(REF_COL));
386
			CellValue actual = evaluator.evaluate(sheet.getRow(i).getCell(EVAL_COL));
377
			CellValue actual = evaluator.evaluate(sheet.getRow(i).getCell(EVAL_COL));
387
			assertEquals(expected.formatAsString(), actual.formatAsString());
378
			assertEquals(expected.formatAsString(), actual.formatAsString());

Return to bug 51498