[]
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.
IWorksheet Worksheet { get; }
ReadOnly Property Worksheet As IWorksheet
CustomFunction function = new CaptureSheetFunction();
Workbook.AddCustomFunction(function, true);
worksheet.Range["B2"].Formula = "=CAPTURESHEET()";
object sheetName = worksheet.Range["B2"].Value;
class CaptureSheetFunction : CustomFunction
{
public CaptureSheetFunction()
: base("CAPTURESHEET", FunctionValueType.Text)
{
}
public override object Evaluate(object[] arguments, ICalcContext context)
{
IWorksheet sheet = context.Worksheet;
return sheet.Name;
}
}