public override object Parse(object obj)
{
Require.That(obj).Named("argument").IsNotNull();
int result;
var objType = obj.GetType();
if (objType == typeof(int))
{
return (int)obj;
}
if (objType == typeof(double) || objType == typeof(decimal))
{
return Convert.ToInt32(obj);
}
if (!int.TryParse(obj.ToString(), out result))
{
throw new ExcelFunctionException("Could not parse " + obj.ToString() + " to int", ExcelErrorCodes.Value);
}
return result;
}