SheetConditionalFormatting sheetCF = s.getSheetConditionalFormatting();\r
int numCF = 3;\r
int numCF12 = 15;\r
- int numCFEX = 0; // TODO This should be 2, but we don't support CFEX formattings yet\r
+ int numCFEX = 0; // TODO This should be 2, but we don't support CFEX formattings yet, see #58149\r
assertEquals(numCF+numCF12+numCFEX, sheetCF.getNumConditionalFormattings());\r
\r
int fCF = 0, fCF12 = 0, fCFEX = 0;\r
// TODO Support Data Bars, then check the rest of this rule\r
\r
\r
- // Colours R->G - Column F\r
+ // Colours Red->Yellow->Green - Column F\r
cf = sheetCF.getConditionalFormattingAt(3);\r
assertEquals(1, cf.getFormattingRanges().length);\r
assertEquals("F2:F17", cf.getFormattingRanges()[0].formatAsString());\r
- \r
- assertEquals(1, cf.getNumberOfRules());\r
- cr = cf.getRule(0);\r
- assertEquals(ConditionType.COLOR_SCALE, cr.getConditionTypeType());\r
- // TODO Support Color Scales, then check the rest of this rule\r
+ assertColorScale(cf, "F8696B", "FFEB84", "63BE7B");\r
\r
\r
- // Colours BWR - Column G\r
+ // Colours Blue->White->Red - Column G\r
cf = sheetCF.getConditionalFormattingAt(4);\r
assertEquals(1, cf.getFormattingRanges().length);\r
assertEquals("G2:G17", cf.getFormattingRanges()[0].formatAsString());\r
- \r
- assertEquals(1, cf.getNumberOfRules());\r
- cr = cf.getRule(0);\r
- assertEquals(ConditionType.COLOR_SCALE, cr.getConditionTypeType());\r
- // TODO Support Color Scales, then check the rest of this rule\r
+ assertColorScale(cf, "5A8AC6", "FCFCFF", "F8696B");\r
\r
\r
// Icons : Default - Column H, percentage thresholds\r
assertEquals(null, th.getFormula());\r
}\r
}\r
+ \r
+ private void assertColorScale(ConditionalFormatting cf, String... colors) {\r
+ assertEquals(1, cf.getNumberOfRules());\r
+ ConditionalFormattingRule cr = cf.getRule(0);\r
+ assertColorScale(cr, colors);\r
+ } \r
+ private void assertColorScale(ConditionalFormattingRule cr, String... colors) {\r
+ assertEquals(ConditionType.COLOR_SCALE, cr.getConditionTypeType());\r
+ assertEquals(ComparisonOperator.NO_COMPARISON, cr.getComparisonOperation());\r
+ assertEquals(null, cr.getFormula1());\r
+ assertEquals(null, cr.getFormula2());\r
+ \r
+ // TODO Implement\r
+/*\r
+ ColorScaleFormatting color = cr.getColorScaleFormatting();\r
+ assertNotNull(color);\r
+ assertNotNull(color.getColors());\r
+ assertNotNull(color.getThresholds());\r
+ assertEquals(colors.length, color.getNumControlPoints());\r
+ assertEquals(colors.length, color.getColors().length);\r
+ assertEquals(colors.length, color.getThresholds().length);\r
+ \r
+ // Thresholds should be Min / (evenly spaced) / Max\r
+ int steps = 100 / (colors.length-1);\r
+ for (int i=0; i<colors.length; i++) {\r
+ ConditionalFormattingThreshold th = color.getThresholds()[i];\r
+ if (i == 0) {\r
+ assertEquals(RangeType.MIN, th.getRangeType());\r
+ } else if (i == colors.length-1) {\r
+ assertEquals(RangeType.MAX, th.getRangeType());\r
+ } else {\r
+ assertEquals(RangeType.PERCENT, th.getRangeType());\r
+ assertEquals(steps*i, th.getValue());\r
+ }\r
+ assertEquals(null, th.getFormula());\r
+ }\r
+ \r
+ // Colors should match\r
+ for (int i=0; i<colors.length; i++) {\r
+ Color c = color.getColors()[i];\r
+ assertEquals(colors[i], c.toString());\r
+ }\r
+*/\r
+ }\r
\r
public void testCreateFontFormatting() {\r
Workbook workbook = _testDataProvider.createWorkbook();\r