diff options
author | Nick Burch <nick@apache.org> | 2015-07-20 04:43:36 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2015-07-20 04:43:36 +0000 |
commit | b068856c510f6299ff19d733b65d4523a4eeb7fd (patch) | |
tree | f1d9f99cee567b94bc3243a55802c04b978ae7c9 /src/testcases | |
parent | 886d73deee98fad27cb9bdfa9992ce7d771e3684 (diff) | |
download | poi-b068856c510f6299ff19d733b65d4523a4eeb7fd.tar.gz poi-b068856c510f6299ff19d733b65d4523a4eeb7fd.zip |
#58130 CF DataBar example and tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1691869 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases')
-rw-r--r-- | src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java index d14b556f44..a12dbc13d9 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java @@ -1138,7 +1138,50 @@ public abstract class BaseTestConditionalFormatting extends TestCase { }
public void testCreateDataBarFormatting() {
- // TODO Implement then test
+ Workbook workbook = _testDataProvider.createWorkbook();
+ Sheet sheet = workbook.createSheet();
+
+ String colorHex = "FFFFEB84";
+ ExtendedColor color = workbook.getCreationHelper().createExtendedColor();
+ color.setARGBHex(colorHex);
+ SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
+ ConditionalFormattingRule rule1 =
+ sheetCF.createConditionalFormattingRule(color);
+ DataBarFormatting dbFmt = rule1.getDataBarFormatting();
+
+ assertEquals(false, dbFmt.isIconOnly());
+ assertEquals(true, dbFmt.isLeftToRight());
+ assertEquals(0, dbFmt.getWidthMin());
+ assertEquals(100, dbFmt.getWidthMax());
+ assertColour(colorHex, dbFmt.getColor());
+
+ dbFmt.getMinThreshold().setRangeType(RangeType.MIN);
+ dbFmt.getMaxThreshold().setRangeType(RangeType.MAX);
+
+ CellRangeAddress [] regions = { CellRangeAddress.valueOf("A1:A5") };
+ sheetCF.addConditionalFormatting(regions, rule1);
+
+ // Save, re-load and re-check
+ workbook = _testDataProvider.writeOutAndReadBack(workbook);
+ sheetCF = sheet.getSheetConditionalFormatting();
+ assertEquals(1, sheetCF.getNumConditionalFormattings());
+
+ ConditionalFormatting cf = sheetCF.getConditionalFormattingAt(0);
+ assertEquals(1, cf.getNumberOfRules());
+ rule1 = cf.getRule(0);
+ dbFmt = rule1.getDataBarFormatting();
+ assertEquals(ConditionType.DATA_BAR, rule1.getConditionTypeType());
+
+ assertEquals(false, dbFmt.isIconOnly());
+ assertEquals(true, dbFmt.isLeftToRight());
+ assertEquals(0, dbFmt.getWidthMin());
+ assertEquals(100, dbFmt.getWidthMax());
+ assertColour(colorHex, dbFmt.getColor());
+
+ assertEquals(RangeType.MIN, dbFmt.getMinThreshold().getRangeType());
+ assertEquals(RangeType.MAX, dbFmt.getMaxThreshold().getRangeType());
+ assertEquals(null, dbFmt.getMinThreshold().getValue());
+ assertEquals(null, dbFmt.getMaxThreshold().getValue());
}
public void testBug55380() {
|