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

查看:115
本文介绍了在 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-only 类

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

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

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