public void IsBlank_true() { var ws = new XLWorkbook().AddWorksheet("Sheet"); var actual = ws.Evaluate("=IsBlank(A1)"); Assert.AreEqual(true, actual); }
public void TestOmittedParameters() { using (var wb = new XLWorkbook()) { object value; value = wb.Evaluate("=IF(TRUE,1)"); Assert.AreEqual(1, value); value = wb.Evaluate("=IF(TRUE,1,)"); Assert.AreEqual(1, value); value = wb.Evaluate("=IF(FALSE,1,)"); Assert.AreEqual(false, value); value = wb.Evaluate("=IF(FALSE,,2)"); Assert.AreEqual(2, value); } }
public void IsBlank_false() { var ws = new XLWorkbook().AddWorksheet("Sheet"); ws.Cell("A1").Value = " "; var actual = ws.Evaluate("=IsBlank(A1)"); Assert.AreEqual(false, actual); }
public void InvalidFunction() { Exception ex; ex = Assert.Throws <NameNotRecognizedException>(() => XLWorkbook.EvaluateExpr("XXX(A1:A2)")); Assert.That(ex.Message, Is.EqualTo("The identifier `XXX` was not recognised.")); var ws = new XLWorkbook().AddWorksheet(); ex = Assert.Throws <NameNotRecognizedException>(() => ws.Evaluate("XXX(A1:A2)")); Assert.That(ex.Message, Is.EqualTo("The identifier `XXX` was not recognised.")); }
public void InvalidFunction() { Exception ex; ex = Assert.Throws <ExpressionParseException>(() => XLWorkbook.EvaluateExpr("XXX(A1:A2)")); Assert.That(ex.Message, Is.EqualTo("Unknown function: XXX")); var ws = new XLWorkbook().AddWorksheet(); ex = Assert.Throws <ExpressionParseException>(() => ws.Evaluate("XXX(A1:A2)")); Assert.That(ex.Message, Is.EqualTo("Unknown function: XXX")); }
public void Hlookup() { // Range lookup false var value = workbook.Evaluate(@"=HLOOKUP(""Total"",Data!$B$2:$I$71,4,FALSE)"); Assert.AreEqual(179.64, value); }
public void Average() { double value; value = workbook.Evaluate("AVERAGE(-27.5,93.93,64.51,-70.56)").CastTo <double>(); Assert.AreEqual(15.095, value, tolerance); var ws = workbook.Worksheets.First(); value = ws.Evaluate("AVERAGE(G3:G45)").CastTo <double>(); Assert.AreEqual(49.3255814, value, tolerance); Assert.That(() => ws.Evaluate("AVERAGE(D3:D45)"), Throws.Exception); }