Java读取Excel条件格式,使用APACHE POI在Excel中使用条件格式

在尝试使用Apache POI库在Java中读取Excel并设置条件格式时,遇到公式错误,提示名为'test'的范围不存在。错误源于在创建条件格式规则时,提供的字符串应为单元格坐标而非文本。修正方法是将比较条件改为实际的单元格坐标,如'B1'。
摘要由CSDN通过智能技术生成

I have a problem using the SheetConditionalFormatting, just for testing if the cell contains particular string (in my case just "test") I run the following code:

SheetConditionalFormatting sheetConditionalFormatting = excelSheet.getSheetConditionalFormatting();

ConditionalFormattingRule rule = sheetConditionalFormatting.createConditionalFormattingRule(ComparisonOperator.EQUAL, "test");

PatternFormatting fill1 = rule.createPatternFormatting();

fill1.setFillBackgroundColor(IndexedColors.BLUE.index);

fill1.setFillPattern(PatternFormatting.SOLID_FOREGROUND);

CellRangeAddress[] regions = {

CellRangeAddress.valueOf("A1")

};

sheetConditionalFormatting.addConditionalFormatting(regions, rule);

And I got message that 'test' does not exist in the workspace. This is my error

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值