public void TwoAndThreeColorConditionalFormattingFromFileDoesNotGetOverwrittenWithDefaultValues() { var file = new FileInfo(@"MultiColorConditionalFormatting.xlsx"); Assert.IsTrue(file.Exists); using (var package = new ExcelPackage(file)) { var sheet = package.Workbook.Worksheets.First(); Assert.AreEqual(2, sheet.ConditionalFormatting.Count); var twoColor = (ExcelConditionalFormattingTwoColorScale)sheet.ConditionalFormatting.First(cf => cf is ExcelConditionalFormattingTwoColorScale); var threeColor = (ExcelConditionalFormattingThreeColorScale)sheet.ConditionalFormatting.First(cf => cf is ExcelConditionalFormattingThreeColorScale); var defaultTwoColorScale = new ExcelConditionalFormattingTwoColorScale(new ExcelAddress("A1"), 2, sheet); var defaultThreeColorScale = new ExcelConditionalFormattingThreeColorScale(new ExcelAddress("A1"), 2, sheet); Assert.IsNull(twoColor.HighValue); Assert.IsNull(twoColor.LowValue); Assert.IsNotNull(defaultTwoColorScale.HighValue); Assert.IsNotNull(defaultTwoColorScale.LowValue); Assert.IsNull(threeColor.HighValue); Assert.IsNull(threeColor.LowValue); Assert.IsNotNull(defaultThreeColorScale.HighValue); Assert.IsNotNull(defaultThreeColorScale.LowValue); } }
public void TwoAndThreeColorConditionalFormattingFromFileDoesNotGetOverwrittenWithDefaultValues() { var file = new FileInfo(Path.Combine( #if Core AppContext.BaseDirectory #else AppDomain.CurrentDomain.BaseDirectory #endif , @"..\..\Workbooks\MultiColorConditionalFormatting.xlsx")); Assert.IsTrue(file.Exists); using (var package = new ExcelPackage(file)) { var sheet = package.Workbook.Worksheets.First(); Assert.AreEqual(2, sheet.ConditionalFormatting.Count); var twoColor = (ExcelConditionalFormattingTwoColorScale)sheet.ConditionalFormatting.First(cf => cf is ExcelConditionalFormattingTwoColorScale); var threeColor = (ExcelConditionalFormattingThreeColorScale)sheet.ConditionalFormatting.First(cf => cf is ExcelConditionalFormattingThreeColorScale); var defaultTwoColorScale = new ExcelConditionalFormattingTwoColorScale(new ExcelAddress("A1"), 2, sheet); var defaultThreeColorScale = new ExcelConditionalFormattingThreeColorScale(new ExcelAddress("A1"), 2, sheet); Assert.IsNull(twoColor.HighValue); Assert.IsNull(twoColor.LowValue); Assert.IsNotNull(defaultTwoColorScale.HighValue); Assert.IsNotNull(defaultTwoColorScale.LowValue); Assert.IsNull(threeColor.HighValue); Assert.IsNull(threeColor.LowValue); Assert.IsNotNull(defaultThreeColorScale.HighValue); Assert.IsNotNull(defaultThreeColorScale.LowValue); } }