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; }
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) }); }
private bool FillsAreEqual(Fill f, IXLFill xlFill) { var nF = new XLFill(); if (f.PatternFill != null) { if (f.PatternFill.PatternType != null) nF.PatternType = f.PatternFill.PatternType.Value.ToClosedXml(); var fColor = GetColor(f.PatternFill.ForegroundColor); if (fColor.HasValue) nF.PatternColor = fColor; var bColor = GetColor(f.PatternFill.BackgroundColor); if (bColor.HasValue) nF.PatternBackgroundColor = bColor; } return nF.Equals(xlFill); }
public void BackgroundPatternNotEqualCheck() { var fill1 = new XLFill {PatternBackgroundColor = XLColor.Blue}; var fill2 = new XLFill {PatternBackgroundColor = XLColor.Red}; Assert.IsFalse(fill1.Equals(fill2)); }
public void BackgroundNoColorSetsPatternNone() { var fill = new XLFill {BackgroundColor = XLColor.NoColor}; Assert.AreEqual(XLFillPatternValues.None, fill.PatternType); }
public void BackgroundColorSetsPattern() { var fill = new XLFill {BackgroundColor = XLColor.Blue}; Assert.AreEqual(XLFillPatternValues.Solid, fill.PatternType); }