/// <summary>
        /// Format a value before serialisation based on its attributes.
        /// </summary>
        /// <param name="cellValue">The value about to be serialised.</param>
        /// <param name="info">Formatting information for this cell based on attributes.</param>
        protected virtual object FormatCellValue(object cellValue, ExcelColumnInfo info)
        {
            // Boolean transformations.
            if (info.ExcelAttribute != null && info.ExcelAttribute.TrueValue != null && cellValue.Equals("True"))
                return info.ExcelAttribute.TrueValue;

            else if (info.ExcelAttribute != null && info.ExcelAttribute.FalseValue != null && cellValue.Equals("False"))
                return info.ExcelAttribute.FalseValue;

            else if (!string.IsNullOrWhiteSpace(info.FormatString) & string.IsNullOrEmpty(info.ExcelNumberFormat))
                return string.Format(info.FormatString, cellValue);

            else
                return cellValue;
        }
Exemple #2
0
        /// <summary>
        /// Format a value before serialisation based on its attributes.
        /// </summary>
        /// <param name="cellValue">The value about to be serialised.</param>
        /// <param name="info">Formatting information for this cell based on attributes.</param>
        protected virtual object FormatCellValue(object cellValue, ExcelColumnInfo info)
        {
            // Boolean transformations.
            if (info.ExcelAttribute != null && info.ExcelAttribute.TrueValue != null && cellValue.Equals("True"))
            {
                return(info.ExcelAttribute.TrueValue);
            }

            else if (info.ExcelAttribute != null && info.ExcelAttribute.FalseValue != null && cellValue.Equals("False"))
            {
                return(info.ExcelAttribute.FalseValue);
            }

            else if (!string.IsNullOrWhiteSpace(info.FormatString) & string.IsNullOrEmpty(info.ExcelNumberFormat))
            {
                return(string.Format(info.FormatString, cellValue));
            }

            else
            {
                return(cellValue);
            }
        }