]> source.dussan.org Git - poi.git/commitdiff
added an example on conditional formatting in the site's quick guide
authorYegor Kozlov <yegor@apache.org>
Tue, 14 Jun 2011 15:49:17 +0000 (15:49 +0000)
committerYegor Kozlov <yegor@apache.org>
Tue, 14 Jun 2011 15:49:17 +0000 (15:49 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1135656 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/spreadsheet/quick-guide.xml

index ca90390b45731ed3afa4ea3efdf204de0b247eac..390d2033149397f81b704b0c943b32e94ea011eb 100644 (file)
@@ -71,6 +71,7 @@
                     <li><link href="#Validation">Data Validation</link></li>
                     <li><link href="#Embedded">Embedded Objects</link></li>
                     <li><link href="#Autofilter">Autofilters</link></li>
+                    <li><link href="#ConditionalFormatting">Conditional Formatting</link></li>
                 </ul>
             </section>
             <section><title>Features</title>
@@ -1662,5 +1663,41 @@ Examples:
     sheet.setAutoFilter(CellRangeAddress.valueOf("C5:F200"));
        </source>
      </section>  
+     <anchor id="ConditionalFormatting"/>
+     <section><title>Conditional Formatting (HSSF Only)</title>
+       <source>
+    HSSFWorkbook workbook = new HSSFWorkbook();
+    HSSFSheet sheet = workbook.createSheet();
+    String formula = "7";
+
+    HSSFSheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
+
+    HSSFConditionalFormattingRule rule1 = sheetCF.createConditionalFormattingRule(formula);
+    HSSFFontFormatting fontFmt = rule1.createFontFormatting();
+    fontFmt.setFontStyle(true, false);
+
+    HSSFBorderFormatting bordFmt = rule1.createBorderFormatting();
+    bordFmt.setBorderBottom(HSSFBorderFormatting.BORDER_THIN);
+    bordFmt.setBorderTop(HSSFBorderFormatting.BORDER_THICK);
+    bordFmt.setBorderLeft(HSSFBorderFormatting.BORDER_DASHED);
+    bordFmt.setBorderRight(HSSFBorderFormatting.BORDER_DOTTED);
+
+    HSSFPatternFormatting patternFmt = rule1.createPatternFormatting();
+    patternFmt.setFillBackgroundColor(HSSFColor.YELLOW.index);
+
+    HSSFConditionalFormattingRule rule2 = sheetCF.createConditionalFormattingRule(ComparisonOperator.BETWEEN, "1", "2");
+    HSSFConditionalFormattingRule [] cfRules =
+    {
+        rule1, rule2
+    };
+
+    CellRangeAddress [] regions = {
+        new CellRangeAddress(2, 4, 0, 0), // A3:A5
+    };
+
+    sheetCF.addConditionalFormatting(regions, cfRules);
+    sheetCF.addConditionalFormatting(regions, cfRules);
+       </source>
+     </section>  
     </body>
 </document>