mirror of https://github.com/apache/poi.git
added an example on conditional formatting in the site's quick guide
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1135656 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0f5f4424e5
commit
b09aedd0b2
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue