public static string ConvertToString(object value)
{
object result;
var retVal = XlCall.TryExcel(XlCall.xlCoerce, out result, value, (int)XlType.XlTypeString);
if (retVal == XlCall.XlReturn.XlReturnSuccess)
{
return (string)result;
}
// Not sure how this can happen...
throw new InvalidCastException("Value " + value.ToString() + " could not be converted to String.");
}