コード例 #1
0
        public void IsBlank_true()
        {
            var ws     = new XLWorkbook().AddWorksheet("Sheet");
            var actual = ws.Evaluate("=IsBlank(A1)");

            Assert.AreEqual(true, actual);
        }
コード例 #2
0
ファイル: FunctionsTests.cs プロジェクト: wtf3505/ClosedXML
        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);
            }
        }
コード例 #3
0
        public void IsBlank_false()
        {
            var ws = new XLWorkbook().AddWorksheet("Sheet");

            ws.Cell("A1").Value = " ";
            var actual = ws.Evaluate("=IsBlank(A1)");

            Assert.AreEqual(false, actual);
        }
コード例 #4
0
        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."));
        }
コード例 #5
0
        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"));
        }
コード例 #6
0
ファイル: LookupTests.cs プロジェクト: zhoushlu/ClosedXML
        public void Hlookup()
        {
            // Range lookup false
            var value = workbook.Evaluate(@"=HLOOKUP(""Total"",Data!$B$2:$I$71,4,FALSE)");

            Assert.AreEqual(179.64, value);
        }
コード例 #7
0
        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);
        }