aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/poi/hssf/record/cf/Threshold.java11
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java7
2 files changed, 14 insertions, 4 deletions
diff --git a/src/java/org/apache/poi/hssf/record/cf/Threshold.java b/src/java/org/apache/poi/hssf/record/cf/Threshold.java
index 462027807c..414bf0f4ca 100644
--- a/src/java/org/apache/poi/hssf/record/cf/Threshold.java
+++ b/src/java/org/apache/poi/hssf/record/cf/Threshold.java
@@ -73,6 +73,14 @@ public final class Threshold {
}
public void setType(byte type) {
this.type = type;
+
+ // Ensure the value presense / absense is consistent for the new type
+ if (type == RangeType.MIN.id || type == RangeType.MAX.id ||
+ type == RangeType.FORMULA.id) {
+ this.value = null;
+ } else if (value == null) {
+ this.value = 0d;
+ }
}
public void setType(int type) {
this.type = (byte)type;
@@ -86,6 +94,9 @@ public final class Threshold {
}
public void setParsedExpression(Ptg[] ptgs) {
formula = Formula.create(ptgs);
+ if (ptgs.length > 0) {
+ this.value = null;
+ }
}
public Double getValue() {
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
index 1204355fae..602c334958 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
@@ -555,11 +555,11 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
assertEquals("Values", s.getRow(0).getCell(0).toString());
assertEquals("10.0", s.getRow(2).getCell(0).toString());
- // Check we found all the conditional formattings rules we should have
+ // Check we found all the conditional formatting rules we should have
SheetConditionalFormatting sheetCF = s.getSheetConditionalFormatting();
int numCF = 3;
int numCF12 = 15;
- int numCFEX = 0; // TODO This should be 1, but we don't support CFEX formattings yet
+ int numCFEX = 0; // TODO This should be 2, but we don't support CFEX formattings yet
assertEquals(numCF+numCF12+numCFEX, sheetCF.getNumConditionalFormattings());
int fCF = 0, fCF12 = 0, fCFEX = 0;
@@ -982,8 +982,7 @@ public abstract class BaseTestConditionalFormatting extends TestCase {
assertEquals(BorderFormatting.BORDER_HAIR, r1fp.getBorderRight());
}
- // TODO Fix this test to work for HSSF
- public void DISABLEDtestCreateIconFormatting() {
+ public void testCreateIconFormatting() {
Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet();