customFormulaEngine print no if formula

I hope to analyze the operation mode of the formula through CustomEngine and print out the execution sequence of the formula, but I find that the IF formula has not been printed out. What is the reason?

public static class CustomEngine extends AbstractCalculationEngine {
        public void calculate(CalculationData data) {
            System.out.println(data.getFunctionName());
        }
        public boolean getProcessBuiltInFunctions() { return true; }
    }

    public static void runSingeFormat() throws Exception {
        Workbook workbook = new Workbook("idNumber.xlsx");
        Worksheet worksheet = workbook.getWorksheets().get(0);
        CalculationOptions opts = new CalculationOptions();
        opts.setCustomEngine(new CustomEngine());
        Object result = worksheet.calculateFormula("=IF(MOD(MID(A1,15,3),2),\"男\",\"女\")", opts);
        System.out.println(result);

    }

@wanghq09,

IF function and CHOOSE function are special in ms excel’s formula structure. For performance consideration, they are redirected to the resultant directly according to the condition without constructing the formula tree completely. So it cannot be processed by AbstractCalculationEngine.calculate(CalculationData data) method in general way.

To make the IF function be constructed completely and processed in the custom engine, currently you may override the AbstractCalculationEngine.isParamArrayModeRequired() method with the returned value as true. This api was provided in our recent versions, 23.9 is recommended.

We will investigate the possibility of making those functions be processed by custom engine too when user requires to process built-in functions.

1 Like

@wanghq09
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-54266

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.