Cells node.js via c++ TEXTAFTER and customEngine not working

It seems TEXTAFTER doesn’t work properly
and the docs for implementing custom functions don’t work:

@curlingpotato,

We will look into your mentioned issues and get back to you with updates soon. Moreover, regarding TEXTAFTER formula calculation issue, could you please share your sample code and template Excel file (if any) to demonstrate the issue, this may help a bit.

P.S. please zip the Excel file prior attaching here.

textafter.xlsx.zip (7.1 KB)

Just run calculateFormula() on this workbook.

A1 = 23432APPLE
B2 =IFERROR(TEXTAFTER(A1, “23432”), “”)

result should be “APPLE” but is “3432APPLE”

@curlingpotato,

We reproduced the issue where TEXTAFTER formula is not evaluated/calculated properly by Aspose.Cells formula calculation engine. Let us evaluate your both issues in details and then appropriate tickets would be logged for the problems.

@curlingpotato
We can reproduce the issue by testing on the latest version v25.2 using sample files and the following code. The TEXTAFTER returns an incorrect value after calling the formula calculation.

const AsposeCells = require("aspose.cells.node");

var workbook = new AsposeCells.Workbook("textafter.xlsx");
var sheet = workbook.getWorksheets().get(0);
var cell = sheet.getCells().get("A1");
console.log("A1: " + cell.getStringValue());
cell = sheet.getCells().get("B1");
console.log("B1: " + cell.getStringValue());
workbook.calculateFormula();
console.log("after calling calculateFormula()");

cell = sheet.getCells().get("A1");
console.log("A1: " + cell.getStringValue());
cell = sheet.getCells().get("B1");
console.log("B1: " + cell.getStringValue());

The output:

A1: 23432APPLE
B1: APPLE
after calling calculateFormula()
A1: 23432APPLE
B1: 3432APPLE

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): CELLSNODEJSCPP-34

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.

@curlingpotato

And if you are solving this issue by using custom engine to calculate TEXTAFTER function by yourself, because it is a builtin function we have supported, please provide True value for the property ProcessBuiltInFunctions for your custom engine implementation.

If your custom engine cannot work with this change, please provide us your sample code and we will investigate it soon.

@curlingpotato
The TEXTAFTER builtin function will be supported in Aspose.Cells for Node.js via C++ v25.3.

In addition, there is an issue in Implement Custom Calculation Engine to extend the Default Calculation Engine of Aspose.Cells with Node.js via C++, we’ll fix the doc soon. Please try the following code, the AbstractCalculationEngine works fine.

const AsposeCells = require("aspose.cells.node");

// Create a new class derived from AbstractCalculationEngine
class CustomEngine extends AsposeCells.AbstractCalculationEngine {
    // Override the Calculate method with custom logic
    calculate(data) {
        // Check the formula name and change the implementation
        if (data.getFunctionName().toUpperCase() === "TODAY") {
            // Assign the CalculationData.CalculatedValue: add one day offset for the date
            data.setCalculatedValue(AsposeCells.CellsHelper.getDoubleFromDateTime(new Date(), false) + 1.0);
        }
    }
    getProcessBuiltInFunctions() {
        return true;
    }
}

class ImplementCustomCalculationEngine {
    static run() {
        // Create an instance of Workbook
        const workbook = new AsposeCells.Workbook();

        // Access first Worksheet from the collection
        const sheet = workbook.getWorksheets().get(0);

        // Access Cell A1 and put a formula to sum values of B1 to B2
        const a1 = sheet.getCells().get("A1");
        const style = a1.getStyle();
        style.setNumber(14);
        a1.setStyle(style);

        a1.setFormula("=TODAY()");

        // Calculate all formulas in the Workbook 
        workbook.calculateFormula();

        // The result of A1 should be 20 as per default calculation engine
        console.log("The value of A1 with default calculation engine: " + a1.getStringValue());

        // Create an instance of CustomEngine
        const engine = new CustomEngine();

        // Create an instance of CalculationOptions
        const opts = new AsposeCells.CalculationOptions();

        // Assign the CalculationOptions.CustomEngine property to the instance of CustomEngine
        opts.setCustomEngine(engine);

        // Recalculate all formulas in Workbook using the custom calculation engine
        workbook.calculateFormula(opts);

        // The result of A1 will be 50 as per custom calculation engine
        console.log("The value of A1 with custom calculation engine: " + a1.getStringValue());

        console.log("Press any key to continue...");
    }
}

// Call the run method to execute the example
ImplementCustomCalculationEngine.run();

@curlingpotato
Aspose.Cells for Node.js via C++ v25.3 has been released. The bug has been fixed in this version.