package org.apache.poi.ss.formula.functions;
+import org.apache.poi.ss.formula.eval.BlankEval;
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.EvaluationException;
import org.apache.poi.ss.formula.eval.NumberEval;
return e.getErrorEval();
}
String strText = OperandResolver.coerceValueToString(veText);
+ if (veText == BlankEval.instance) {
+ return new NumberEval(0.0);
+ }
if (StringUtil.isBlank(strText)) {
return ErrorEval.VALUE_INVALID;
}
import static org.junit.jupiter.api.Assertions.assertEquals;
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.StringEval;
import org.apache.poi.ss.formula.eval.ValueEval;
+import org.apache.poi.ss.util.Utils;
import org.junit.jupiter.api.Test;
+import java.io.IOException;
+
/**
* Tests for {@link Value}
*/
confirmValueError("1e2.5");
confirmValueError("");
}
+
+ @Test
+ void testBlank() throws IOException {
+ try (HSSFWorkbook wb = new HSSFWorkbook()) {
+ HSSFSheet sheet = wb.createSheet();
+ HSSFRow row = sheet.createRow(0);
+ HSSFCell b1 = row.createCell(1);
+ HSSFCell c1 = row.createCell(2);
+ HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
+ Utils.assertDouble(fe, b1, "VALUE(A1)", 0.0);
+ Utils.assertDouble(fe, c1, "VALUE(B1)", 0.0);
+ }
+ }
}