public void ThenICanGetAllExcelRangeProperties() { //ExcelInteropHelper.GetCellProperties(5, 1); ExcelInteropHelper.ActivateSheet("RiskRegisterWithScope"); var bgColorProperty = ExcelInteropHelper.ReadExcelRangeProperty("H5:S5", ExcelCellProperties.CellBackGroundColor); var fontColorProperty = ExcelInteropHelper.ReadExcelRangeProperty("H5:S5", ExcelCellProperties.CellFontColor); var fontSizeProperty = ExcelInteropHelper.ReadExcelRangeProperty("H5:S5", ExcelCellProperties.CellFontSize); var formulaProperty = ExcelInteropHelper.ReadExcelRangeProperty("H5:S5", ExcelCellProperties.CellFormula); var textProperty = ExcelInteropHelper.ReadExcelRangeProperty("H5:S5", ExcelCellProperties.CellText); int index = 0; foreach (var text in textProperty) { if (Convert.ToInt32(text) < 2) { Assert.AreEqual("ffffff", bgColorProperty[index]); } else if (Convert.ToInt32(text) >= 2 && Convert.ToInt32(text) < 5) { Assert.AreEqual("ffffff", bgColorProperty[index]); } else if (Convert.ToInt32(text) >= 5) { Assert.AreEqual("a31e22", bgColorProperty[index]); } index++; } }
public void ThenICanGetExcelCellBackgroundColor() { var actualValues = ExcelInteropHelper.ReadExcelRangeProperty("A3", ExcelCellProperties.CellBackGroundColor); var expectedValues = new List <string>(); expectedValues.AddRange(new[] { "ffffff" }); CollectionAssert.AreEquivalent(expectedValues, actualValues); }
public void ThenICanGetExcelRangeAsList() { var actualValues = ExcelInteropHelper.ReadExcelRangeProperty("A1:A11"); var expectedValues = new List <string>(); expectedValues.AddRange(new[] { "A", "2.001", "5", "ABC", "XYZ", "2.498750625", "₹ 23.75", "12/15/2019", "December 15, 2019", "8:52:48 AM", "76.90%" }); CollectionAssert.AreEquivalent(expectedValues, actualValues); }