在ApachePOI中使用什么代替不推荐使用的CellRangeAddress.valueOf [英] What to use instead of deprecated CellRangeAddress.valueOf in ApachePOI

查看:205
本文介绍了在ApachePOI中使用什么代替不推荐使用的CellRangeAddress.valueOf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在该区域中添加条件格式,但是不建议使用在教程中看到的一种方法.用什么代替它.样本:

I wanted to add conditional formatting in the region but One method which I saw in tutorial is deprecated. What to use instead of it. Sample:

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);

推荐答案

您使用的CellRangeAddress版本错误. org.apache.poi.hssf.util.CellRangeAddress 已弃用,您应该使用的是 org.apache.poi.ss.util.CellRangeAddress.

You're using the wrong version of CellRangeAddress. org.apache.poi.hssf.util.CellRangeAddress is deprecated, the one you should be using is org.apache.poi.ss.util.CellRangeAddress.

您需要使用 SS Common Spreadsheet Model 类,而不是仅使用HSSF的旧版

You need to use the SS Common Spreadsheet Model class, not the older HSSF-only one

这篇关于在ApachePOI中使用什么代替不推荐使用的CellRangeAddress.valueOf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆