You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by pa...@post.ch on 2011/02/08 09:28:11 UTC

ConditionalFormatting with relative cells doesn't work as expected

Hi .

I'd like to build an excel which contains 2 identical columns. The second one is hidden.
I wanted to add conditional formatting in order to change the format for every cell of the first column where the user changed the value.

Building the excel sheet is ok, but at the end, the format will change for the whole cells of the column only if we change the value of the first cell of the column.
It doesn't seems that the relative reference works well.

If I open the rule in Excel and just press save without changing anything in the rule, then it will start to work as expected.

My code is following :

        HSSFSheetConditionalFormatting scf = sheet.getSheetConditionalFormatting();
        HSSFConditionalFormattingRule rule= scf.createConditionalFormattingRule("B2<>C2");
        HSSFPatternFormatting patternFmt = rule.createPatternFormatting();
        patternFmt.setFillBackgroundColor(HSSFColor.BLUE_GREY.index);
        scf.addConditionalFormatting(new CellRangeAddress[] {new CellRangeAddress(1, 10, 1, 1)}, rule);

Any hints will be appreciated.

Cheers,
Patrick Brühlmann


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org