コード例 #1
0
        public void TestCellsUsedWithoutFormulas()
        {
            var          wb = new XLWorkbook();
            IXLWorksheet ws = wb.AddWorksheet("Test");

            ws.Cell(70, 100).Value      = "Value";
            ws.Cell(10, 15).Value       = "Value2";
            ws.Cell(10, 15).Active      = true;
            ws.Cell(10, 20).FormulaA1   = "=ROW()";
            ws.Cell(10, 30).FormulaR1C1 = "=COLUMN()";
            ws.Cell(20, 30).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
            ws.Cell(25, 30).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
            ws.Cell(25, 30).FormulaA1 = "=A1+B2";

            Assert.AreEqual(5, ws.CellsUsed(XLCellsUsedOptions.Contents).Count());
            Assert.AreEqual(6, ws.CellsUsed(XLCellsUsedOptions.All).Count());
            Assert.AreEqual(2, ws.CellsUsedWithoutFormulas().Count());
            Assert.AreEqual(3, ws.CellsUsedWithoutFormulas(XLCellsUsedOptions.All).Count());
            Assert.AreEqual(2, ws.CellsUsed(c => c.Active || c.Style.Border.TopBorder == XLBorderStyleValues.Thin).Count());
            Assert.AreEqual(1, ws.CellsUsedWithoutFormulas(c => c.Active || c.Style.Border.TopBorder == XLBorderStyleValues.Thin).Count());
            Assert.AreEqual(3, ws.CellsUsed(XLCellsUsedOptions.All, c => c.Active || c.Style.Border.TopBorder == XLBorderStyleValues.Thin).Count());
            Assert.AreEqual(2, ws.CellsUsedWithoutFormulas(XLCellsUsedOptions.All, c => c.Active || c.Style.Border.TopBorder == XLBorderStyleValues.Thin).Count());
        }