Ejemplo n.º 1
0
        /*
         * Removed this method in v3 since this is rarely used but just increased internal complexity.
         *
         * /// <summary>
         * /// Specify the built-in format.
         * /// </summary>
         * /// <typeparam name="T">The target object type.</typeparam>
         * /// <param name="builtinFormat">The built-in format, see https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/BuiltinFormats.html for possible values.</param>
         * /// <param name="propertySelector">Property selector.</param>
         * /// <returns>The mapper object.</returns>
         * [Obsolete("Builtin format will not be supported in next major release!")]
         * public Mapper Format<T>(short builtinFormat, Expression<Func<T, object>> propertySelector)
         * {
         *  var pi = MapHelper.GetPropertyInfoByExpression(propertySelector);
         *  if (pi == null) return this;
         *  new ColumnAttribute { Property = pi, BuiltinFormat = builtinFormat }.MergeTo(Attributes);
         *
         *  return this;
         * }
         */

        /// <summary>
        /// Specify the custom format.
        /// </summary>
        /// <typeparam name="T">The target object type.</typeparam>
        /// <param name="customFormat">The custom format, see https://support.office.com/en-nz/article/Create-or-delete-a-custom-number-format-78f2a361-936b-4c03-8772-09fab54be7f4 for the syntax.</param>
        /// <param name="propertySelector">Property selector.</param>
        /// <returns>The mapper object.</returns>
        public Mapper Format <T>(string customFormat, Expression <Func <T, object> > propertySelector)
        {
            var pi = MapHelper.GetPropertyInfoByExpression(propertySelector);

            if (pi == null)
            {
                return(this);
            }
            new ColumnAttribute {
                Property = pi, CustomFormat = customFormat
            }.MergeTo(Attributes);

            return(this);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Specify to ignore a property. Ignored property will not be mapped for import and export.
        /// </summary>
        /// <typeparam name="T">The target object type.</typeparam>
        /// <param name="propertySelector">Property selector.</param>
        /// <returns>The mapper object.</returns>
        public Mapper Ignore <T>(Expression <Func <T, object> > propertySelector)
        {
            var pi = MapHelper.GetPropertyInfoByExpression(propertySelector);

            if (pi == null)
            {
                return(this);
            }
            new ColumnAttribute {
                Property = pi, Ignored = true
            }.MergeTo(Attributes);

            return(this);
        }