public class CubeFunctionInfo : GrapeCity.CalcEngine.Functions.CalcFunction
{
public override string Name { get { return "CUBE"; } }
public override int MinArgs { get { return 1; } }
public override int MaxArgs { get { return 1; } }
public override object Evaluate(object[] args, bool arrayformulamode)
{
double num = GrapeCity.CalcEngine.CalcConvert.ToDouble(args[0]);
return num * num * num;
}
public override object Evaluate(object[] args, object context, bool arrayformulamode)
{
return Evaluate(args, arrayformulamode);
}
}
private void button1_Click(object sender, RoutedEventArgs e)
{
gcSpreadSheet1.AddCustomFunction(new CubeFunctionInfo());
// or
//gcSpreadSheet1.Sheets[0].AddCustomFunction(new CubeFunctionInfo());
gcSpreadSheet1.Sheets[0].SetFormula(1, 1, "CUBE(4)");
//gcSpreadSheet1.ClearCustomFunctions();
}