Missed the 2nd half of the question. This class only returns rules that match the current state of the workbook for a given cell - rules that would be applied were it open in Excel. Note that this logic is limited to evaluating functions actually implemented in POI, which is most of them, but there are some exceptions and a few open bugs.
The unit test has one example of usage: http://svn.apache.org/repos/asf/poi/trunk/src/ooxml/testcases/org/apache/poi/ss/usermodel/ConditionalFormattingEvalTest.java as does my submission to Vaadin-Spreadsheet: https://github.com/vaadin/spreadsheet/issues/461#issuecomment-279091036 On Wed, Apr 19, 2017 at 3:26 PM Greg Woolsey <greg.wool...@gmail.com> wrote: > 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.wat...@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. >> >