示例#1
0
        /// <summary>Gets the Excel cell representation of a specific <see cref="System.Object"/>.
        /// </summary>
        /// <param name="value">The value to convert.</param>
        /// <returns><paramref name="value"/> if <paramref name="value"/> is a standard type (i.e. boolean, integer, DateTime, double etc.); otherwise the <see cref="System.String"/> representation
        /// of <paramref name="value"/> using the <c>ToString()</c> method.</returns>
        public static object GetExcelCellRepresentation(object value)
        {
            if (IsEmptyCell(value) == true)
            {
                return("<empty>");
            }
            Type valueType = value.GetType();

            if ((valueType.IsPrimitive == true) || (value is DateTime) || (value is string))
            {
                return(value);
            }
            else if (valueType.IsEnum == true)
            {
                return(EnumString.Create((Enum)value, EnumStringRepresentationUsage.StringAttribute));
            }
            return(value.ToString());
        }