CalcQuickBase calc = new CalcQuickBase();
calc["a"] = "5";
calc["b"] = "0";
calc["c"] = "4";
calc["d"] = "2";
var result = calc.ParseAndCompute("if([b] = 0, 0 , [a]/[b])+ if([d] = 0, 0 , [c]/[d])");
|
CalcQuickBase calc = new CalcQuickBase();
calc.Engine.AddFunction("Div", new Syncfusion.Calculate.CalcEngine.LibraryFunction(ComputeDivision));
var result1= calc.ParseAndCompute("Div(5, 0)");
//Implementation of function
public string ComputeDivision(string range)
{
var args = range.Split(new char[]{CalcEngine.ParseArgumentSeparator}, StringSplitOptions.None);
if (args[1] == "0")
return "0";
var parse = Int32.Parse(args[0])/Int32.Parse(args[1]);
return parse.ToString();
} |
CalcQuickBase calc = new CalcQuickBase();
calc.Engine.AddFunction("Div", new Syncfusion.Calculate.CalcEngine.LibraryFunction(ComputeDivision));
var result1= calc.ParseAndCompute("DIV((DIV(5,0)+ DIV(9,5)),(DIV(4,0) + 6))"); // (a/b + c/d)/(k/l + j])
//Implementation of function
public string ComputeDivision(string range)
{
var args = range.Split(new char[]{CalcEngine.ParseArgumentSeparator}, StringSplitOptions.None);
string s1 = calc.Engine.GetValueFromArg(args[0]);
string s2 = calc.Engine.GetValueFromArg(args[1]);
if (s2 == "0")
return "0";
var parse = Int32.Parse(s1)/Int32.Parse(s2);
return parse.ToString();
} |