[]
Represents the context of the calculation.
Provides information about the cell currently being calculated, including its containing worksheet, row index, and column index. This interface is typically used in custom function evaluation logic to determine where the calculation is occurring.
public interface ICalcContext
Public Interface ICalcContext
CustomFunction function = new CellPositionFunction();
Workbook.AddCustomFunction(function, true);
worksheet.Range["B2"].Formula = "=CELLPOS()";
object cellPosition = worksheet.Range["B2"].Value;
class CellPositionFunction : CustomFunction
{
public CellPositionFunction()
: base("CELLPOS", FunctionValueType.Text)
{
}
public override object Evaluate(object[] arguments, ICalcContext context)
{
IWorksheet sheet = context.Worksheet;
int row = context.Row;
int column = context.Column;
return sheet.Name + "!" + row + "," + column;
}
}
| Name | Description |
|---|---|
| Column | Gets the column index of the cell which is calculating. Use this property in a custom function to identify the zero-based column position of the cell whose formula is currently being evaluated. |
| Row | Gets the row index of the cell which is calculating. Use this property in a custom function to identify the zero-based row position of the cell whose formula is currently being evaluated. |
| Worksheet | Gets the IWorksheet that contains the cell which is calculating. Use this property in a custom function to access the worksheet that contains the cell whose formula is being evaluated. |