We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

ICustomFunction paramsList - Why is range passed in as object[][]?

More out of curiosities sake…why is range passed in as object[][]…in your ‘Using ICustomFunction feature’, you have…

var secondParamC1C5 = (Array)(paramsList[1]);

// get every item value of second parameter
foreach (object[] value in secondParamC1C5)
total += System.Convert.ToDecimal(value[0]);

Obviously I will work within the provided mechanisms, but wondering when this would be handy i.e. when would the ‘simple value’ of the range (object[] value) really be an array?


Well, if your underlying values are not coming from a range of cells and you just need to evaluate individual values of the cells instead same as the first parameter, you may accommodate it in your codes accordingly in the implementation of ICustomFunction interface, see the updated sample program for your reference:
Sample code:

using System;
using System.Collections.Generic;
using System.Text;
using Aspose.Cells;

namespace UsingICustomFunction
public class CustomFunction : ICustomFunction

public object CalculateCustomFunction(string functionName, System.Collections.ArrayList paramsList, System.Collections.ArrayList contextObjects)

//get value of first parameter
decimal firstParamB1 = System.Convert.ToDecimal(paramsList[0]);

//get value of second parameter
decimal secondParamC1 = System.Convert.ToDecimal(paramsList[1]);

//get value of second parameter
decimal thirdParamC5 = System.Convert.ToDecimal(paramsList[2]);

decimal total = 0M;

total = firstParamB1 + secondParamC1 + thirdParamC5;

//return result of the function
return total;


class Program
static void Main(string[] args)

//Open the workbook
Workbook workbook = new Workbook();

//Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.Worksheets[0];

//Adding a sample value to “A1” cell

//Adding a sample value to “A2” cell

//Adding a sample value to “A3” cell

//Adding a sample value to “B1” cell

//Adding a sample value to “B2” cell

//Adding a sample value to “B2” cell

//Adding custom formula to Cell A1
workbook.Worksheets[0].Cells[“A1”].Formula = “=MyFunc(B1,C1,C5)”;

//Calculating Formulas
workbook.CalculateFormula(false, new CustomFunction());

//Assign resultant value to Cell A1
workbook.Worksheets[0].Cells[“A1”].PutValue(workbook.Worksheets[0].Cells[“A1”].Value); //167 - Ok

//Save the file


Hope, it helps a bit for your understanding.

Thank you.