Example #1
0
        /// <summary>
        /// Returns true if this = other
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public bool Equals(ExcelCellStyleInfo other)
        {
            if (other == null && !this.HasCellInfo)
            {
                return(true);
            }
            if (other == null)
            {
                return(false);
            }

            if (!Nullable <Color> .Equals(this.FillColour, other.FillColour))
            {
                return(false);
            }
            if (!string.Equals(this.NumberFormat, other.NumberFormat))
            {
                return(false);
            }
            if (!ExcelCellFontInfo.Equals(this.FontInfo, other.FontInfo))
            {
                return(false);
            }
            if (!ExcelCellBorderInfo.Equals(this.BorderInfo, other.BorderInfo))
            {
                return(false);
            }
            if (!ExcelCellAlignmentInfo.Equals(this.AlignmentInfo, other.AlignmentInfo))
            {
                return(false);
            }

            return(true);
        }
Example #2
0
        /// <summary>
        /// Creates a copy of original.
        /// </summary>
        /// <param name="source"></param>
        private ExcelCellStyleInfo(ExcelCellStyleInfo source)
        {
            this.fillColour   = source.FillColour;
            this.numberFormat = source.NumberFormat;
            this.hasCellInfo  = source.HasCellInfo;

            this.fontInfo      = source.FontInfo == null ? null : (ExcelCellFontInfo)source.FontInfo.Clone();
            this.borderInfo    = source.BorderInfo == null ? null : (ExcelCellBorderInfo)source.BorderInfo.Clone();
            this.alignmentInfo = source.AlignmentInfo == null ? null : (ExcelCellAlignmentInfo)source.AlignmentInfo.Clone();
        }
Example #3
0
        /// <summary>
        /// Compares and updates alignment information for the cell.
        /// </summary>
        /// <param name="font"></param>
        private void UpdateAlignmentInfo(StyleBase mapStyle)
        {
            // Only applies to CellMapStyles
            CellStyle typedMapStyle = mapStyle as CellStyle;

            if (typedMapStyle != null && HasAnyAlignmentInfo(typedMapStyle))
            {
                if (this.alignmentInfo == null)
                {
                    this.alignmentInfo = new ExcelCellAlignmentInfo();
                }

                // Update any allignment-related properties that are non-null/empty
                if (typedMapStyle.TextAlignment.HasValue)
                {
                    this.alignmentInfo.TextAlignment = typedMapStyle.TextAlignment.Value;
                }
                if (typedMapStyle.RotationAngle.HasValue && typedMapStyle.RotationAngle.Value != 0)
                {
                    this.alignmentInfo.TextRotationAngle = typedMapStyle.RotationAngle.Value;
                }
                if (typedMapStyle.TextWrapping.HasValue)
                {
                    this.alignmentInfo.TextWrapping = typedMapStyle.TextWrapping.Value;
                }
                if (typedMapStyle.Indentation.HasValue)
                {
                    this.alignmentInfo.LeftMargin = typedMapStyle.Indentation.Value * 2;                                     // NB! CH-Can we remove this /2... It's there because we / 2 when applying to cell
                }
                if (typedMapStyle.VerticalAlignment.HasValue)
                {
                    this.alignmentInfo.VerticalAlignment = typedMapStyle.VerticalAlignment.Value;
                }
                this.hasCellInfo = true;
            }
        }