public XLStyle(IXLStylized container, IXLStyle initialStyle = null, Boolean useDefaultModify = true)
        {
            if (initialStyle != null)
            {
                Font = new XLFont(container, initialStyle.Font, useDefaultModify);
                Alignment = new XLAlignment(container, initialStyle.Alignment);
                Border = new XLBorder(container, initialStyle.Border, useDefaultModify);
                Fill = new XLFill(container, initialStyle.Fill, useDefaultModify);
                NumberFormat = new XLNumberFormat(container, initialStyle.NumberFormat);
                Protection = new XLProtection(container, initialStyle.Protection);
            }
            else
            {
                Font = new XLFont(container, null);
                Alignment = new XLAlignment(container);
                Border = new XLBorder(container, null);
                Fill = new XLFill(container);
                NumberFormat = new XLNumberFormat(container, null);
                Protection = new XLProtection(container);
            }

            DateFormat = NumberFormat;
        }
Beispiel #2
0
        internal static XLStyleKey GenerateKey(IXLStyle initialStyle)
        {
            if (initialStyle == null)
            {
                return(Default.Key);
            }
            if (initialStyle is XLStyle)
            {
                return((initialStyle as XLStyle).Key);
            }

            return(new XLStyleKey
            {
                Font = XLFont.GenerateKey(initialStyle.Font),
                Alignment = XLAlignment.GenerateKey(initialStyle.Alignment),
                Border = XLBorder.GenerateKey(initialStyle.Border),
                Fill = XLFill.GenerateKey(initialStyle.Fill),
                NumberFormat = XLNumberFormat.GenerateKey(initialStyle.NumberFormat),
                Protection = XLProtection.GenerateKey(initialStyle.Protection)
            });
        }
Beispiel #3
0
        public XLStyle(IXLStylized container, IXLStyle initialStyle = null, Boolean useDefaultModify = true)
        {
            if (initialStyle != null)
            {
                Font         = new XLFont(container, initialStyle.Font, useDefaultModify);
                Alignment    = new XLAlignment(container, initialStyle.Alignment);
                Border       = new XLBorder(container, initialStyle.Border, useDefaultModify);
                Fill         = new XLFill(container, initialStyle.Fill, useDefaultModify);
                NumberFormat = new XLNumberFormat(container, initialStyle.NumberFormat);
                Protection   = new XLProtection(container, initialStyle.Protection);
            }
            else
            {
                Font         = new XLFont(container, null);
                Alignment    = new XLAlignment(container);
                Border       = new XLBorder(container, null);
                Fill         = new XLFill(container);
                NumberFormat = new XLNumberFormat(container, null);
                Protection   = new XLProtection(container);
            }

            DateFormat = NumberFormat;
        }
        private static bool AlignmentsAreEqual(Alignment alignment, IXLAlignment xlAlignment)
        {
            var a = new XLAlignment();
            if (alignment != null)
            {
                if (alignment.Indent != null)
                    a.Indent = (Int32)alignment.Indent.Value;

                if (alignment.Horizontal != null)
                    a.Horizontal = alignment.Horizontal.Value.ToClosedXml();
                if (alignment.Vertical != null)
                    a.Vertical = alignment.Vertical.Value.ToClosedXml();

                if (alignment.ReadingOrder != null)
                    a.ReadingOrder = alignment.ReadingOrder.Value.ToClosedXml();
                if (alignment.WrapText != null)
                    a.WrapText = alignment.WrapText.Value;
                if (alignment.TextRotation != null)
                    a.TextRotation = (Int32)alignment.TextRotation.Value;
                if (alignment.ShrinkToFit != null)
                    a.ShrinkToFit = alignment.ShrinkToFit.Value;
                if (alignment.RelativeIndent != null)
                    a.RelativeIndent = alignment.RelativeIndent.Value;
                if (alignment.JustifyLastLine != null)
                    a.JustifyLastLine = alignment.JustifyLastLine.Value;
            }
            return a.Equals(xlAlignment);
        }