Aspose::Cells::Startup(); //Implement AbstractCalculationEngine interface class CustomFunction1 : public AbstractCalculationEngine { public: void Calculate(CalculationData& data) { Object funcName = data.GetParamValue(0); U16String cellName = data.GetCell().GetName(); Object cellValue = data.GetParamValue(1); if (data.GetFunctionName() == u"MySampleFunc") { std::cout << funcName.ToString().ToUtf8() << " called successfully." << std::endl; data.GetCell().PutValue(cellValue); } if (data.GetFunctionName() == u"YourSampleFunc") { std::cout << funcName.ToString().ToUtf8() << " called successfully." << std::endl; data.GetCell().PutValue(cellValue); } } }; //Create workbook Workbook wb; //Access first worksheet in the workbook Worksheet ws = wb.GetWorksheets().Get(0); //Adding custom formulas to Cell A1 and A2 ws.GetCells().Get(u"A1").SetFormula(u"=MySampleFunc(\"MySampleFunc-Test\",1)"); ws.GetCells().Get(u"A2").SetFormula(u"=YourSampleFunc(\"YourSampleFunc-Test\",2)"); // Calcualting Formulas CustomFunction1 custFunc; CalculationOptions options; options.SetCustomEngine(&custFunc); wb.CalculateFormula(options); //Print the value of cell A1 and A2 after the calculation of custom function implemented by us. U16String valA1 = ws.GetCells().Get(u"A1").GetStringValue(); U16String valA2 = ws.GetCells().Get(u"A2").GetStringValue(); std::cout << "Value of A1 is : " << valA1.ToUtf8() << std::endl; std::cout << "Value of A2 is : " << valA2.ToUtf8() << std::endl; Aspose::Cells::Cleanup();