poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Woolsey <greg.wool...@gmail.com>
Subject Re: Evaluating Arbitrary Formula
Date Wed, 19 Apr 2017 22:26:39 GMT
The class is org.apache.poi.ss.formula.ConditionalFormattingEvaluator in
poi-3.16.jar.

Use is something like this:

WorkbookEvaluatorProvider wbEvalProv = (WorkbookEvaluatorProvider)
workbook.getCreationHelper().createFormulaEvaluator();
ConditionalFormattingEvaluator cfEval = new
ConditionalFormattingEvaluator(workbook, wbEvalProv);
// if cell values have changed, clear cached format results
cfEvaluator.clearAllCachedValues();
List<EvaluationConditionalFormatRule> rules =
cfEvaluator.getConditionalFormattingForCell(cell);
// check rules list for null, do what you want with results
// EvaluationConditionalFormatRule provides a more user-friendly API to the
disparate underlying elements for a given match



On Wed, Apr 19, 2017 at 2:28 PM Blake Watson <blake.watson@pnmac.com> wrote:

> Greg,
> ​
> ​I'm having trouble figuring out how to use the conditional stuff. ​I can't
> seem to =find= ConditionalFormattingEvaluator in the POI jar.
>
> If I could find it, I'm not sure how I'd use it:
>
> ec = ConditionalFormattingEvaluator(Workbook wb, WorkbookEvaluatorProvider
> provider);
>
> How do I create "provider"? I don't get the "IStabilityClass" thing.
>
> Once having it, I would guess I call:
>
> list = ec.getConditionalFormattingForCell(someCell);
>
> and for each item in the list:
>
> fmt = item.getFormatting();
>
> But does getConditionalFormattingForCell return all the formats POSSIBLE or
> only the ones that apply based on the spreadsheet's current state? And if
> the former, how do I eliminate the ones that apply?
>
> I feel like I'm looking completely in the wrong direction, but I haven't
> been able to locate any examples of how to use this.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message