Java – used in Apache POI instead of the deprecated cellrangeaddress valueOf

I wanted to add conditional formatting in this region, but one of the methods I saw in the tutorial has been deprecated Use what instead of it

ConditionalFormattingRule rule2 = sheetCF.createConditionalFormattingRule(ComparisonOperator.LT,"50");
    PatternFormatting fill2 = rule2.createPatternFormatting();
    fill2.setFillBackgroundColor(IndexedColors.GREEN.index);
    fill2.setFillPattern(PatternFormatting.soLID_FOREGROUND);

    CellRangeAddress[] regions = {
            CellRangeAddress.valueOf("A1:A6") //DEPRECATED
    };
    sheetCF.addConditionalFormatting(regions,rule);

Solution

You are using the wrong version of cellrangeaddress org. apache. poi. hssf. util. Cellrangeaddress is deprecated. You should use org apache. poi. ss. util. CellRangeAddress.

You need to use the SS common spreadsheet model class instead of the old version of HSSF

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>