Esempio n. 1
0
        void MixedRelativeAndAbsolute()
        {
            CellPosition  pos;
            RangePosition range;

            pos = new CellPosition("$A1");
            AssertEquals(pos.Col, 0);
            AssertEquals(pos.Row, 0);
            AssertEquals("$A1", pos.ToAddress());
            AssertEquals("A1", pos.ToRelativeAddress());
            AssertEquals("$A$1", pos.ToAbsoluteAddress());

            pos = new CellPosition("Z$10");
            AssertEquals(pos.Col, 25);
            AssertEquals(pos.Row, 9);
            AssertEquals("Z$10", pos.ToAddress());
            AssertEquals("Z10", pos.ToRelativeAddress());
            AssertEquals("$Z$10", pos.ToAbsoluteAddress());

            // full cols
            range = new RangePosition("$A1:B2");
            AssertSame(range.Row, 0);
            AssertSame(range.Rows, 2);
            AssertSame(range.Col, 0);
            AssertSame(range.Cols, 2);
            AssertEquals("$A1:B2", range.ToAddress());
            AssertEquals("A1:B2", range.ToRelativeAddress());
            AssertEquals("$A$1:$B$2", range.ToAbsoluteAddress());
        }
Esempio n. 2
0
        public void Generic()
        {
            RangePosition range;

            // 1,1
            range = new RangePosition("A1");
            AssertSame(range.Row, 0);
            AssertSame(range.Col, 0);
            AssertSame(range.Rows, 1);
            AssertSame(range.Cols, 1);
            AssertEquals(range.ToAddress(), "A1:A1");
            AssertEquals(range.ToRelativeAddress(), "A1:A1");
            AssertEquals(range.ToAbsoluteAddress(), "$A$1:$A$1");
            AssertEquals(range.StartPos.ToAddress(), "A1");
            AssertEquals(range.StartPos.ToRelativeAddress(), "A1");
            AssertEquals(range.StartPos.ToAbsoluteAddress(), "$A$1");
            AssertEquals(range.EndPos.ToAddress(), "A1");
            AssertEquals(range.EndPos.ToRelativeAddress(), "A1");
            AssertEquals(range.EndPos.ToAbsoluteAddress(), "$A$1");

            range = new RangePosition("$A$1");
            AssertSame(range.Row, 0);
            AssertSame(range.Col, 0);
            AssertSame(range.Rows, 1);
            AssertSame(range.Cols, 1);
            AssertEquals(range.ToAddress(), "$A$1:$A$1");
            AssertEquals(range.ToRelativeAddress(), "A1:A1");
            AssertEquals(range.ToAbsoluteAddress(), "$A$1:$A$1");
            AssertEquals(range.StartPos.ToAddress(), "$A$1");
            AssertEquals(range.StartPos.ToRelativeAddress(), "A1");
            AssertEquals(range.StartPos.ToAbsoluteAddress(), "$A$1");
            AssertEquals(range.EndPos.ToAddress(), "$A$1");
            AssertEquals(range.EndPos.ToRelativeAddress(), "A1");
            AssertEquals(range.EndPos.ToAbsoluteAddress(), "$A$1");

            range = new RangePosition("C53:C60");
            AssertSame(range.Row, 52);
            AssertSame(range.Col, 2);
            AssertSame(range.Rows, 8);
            AssertSame(range.Cols, 1);
            AssertEquals(range.ToAddress(), "C53:C60");
            AssertEquals(range.ToRelativeAddress(), "C53:C60");
            AssertEquals(range.ToAbsoluteAddress(), "$C$53:$C$60");
            AssertEquals(range.StartPos.ToAddress(), "C53");
            AssertEquals(range.StartPos.ToRelativeAddress(), "C53");
            AssertEquals(range.StartPos.ToAbsoluteAddress(), "$C$53");
            AssertEquals(range.EndPos.ToAddress(), "C60");
            AssertEquals(range.EndPos.ToRelativeAddress(), "C60");
            AssertEquals(range.EndPos.ToAbsoluteAddress(), "$C$60");

            range = new RangePosition("$C$53:$C$60");
            AssertSame(range.Row, 52);
            AssertSame(range.Col, 2);
            AssertSame(range.Rows, 8);
            AssertSame(range.Cols, 1);
            AssertEquals(range.ToAddress(), "$C$53:$C$60");
            AssertEquals(range.ToRelativeAddress(), "C53:C60");
            AssertEquals(range.ToAbsoluteAddress(), "$C$53:$C$60");
            AssertEquals(range.StartPos.ToAddress(), "$C$53");
            AssertEquals(range.StartPos.ToRelativeAddress(), "C53");
            AssertEquals(range.StartPos.ToAbsoluteAddress(), "$C$53");
            AssertEquals(range.EndPos.ToAddress(), "$C$60");
            AssertEquals(range.EndPos.ToRelativeAddress(), "C60");
            AssertEquals(range.EndPos.ToAbsoluteAddress(), "$C$60");

            range = new RangePosition("$C$53:C60");
            AssertSame(range.Row, 52);
            AssertSame(range.Col, 2);
            AssertSame(range.Rows, 8);
            AssertSame(range.Cols, 1);
            AssertEquals(range.ToAddress(), "$C$53:C60");
            AssertEquals(range.ToRelativeAddress(), "C53:C60");
            AssertEquals(range.ToAbsoluteAddress(), "$C$53:$C$60");
            AssertEquals(range.StartPos.ToAddress(), "$C$53");
            AssertEquals(range.StartPos.ToRelativeAddress(), "C53");
            AssertEquals(range.StartPos.ToAbsoluteAddress(), "$C$53");
            AssertEquals(range.EndPos.ToAddress(), "C60");
            AssertEquals(range.EndPos.ToRelativeAddress(), "C60");
            AssertEquals(range.EndPos.ToAbsoluteAddress(), "$C$60");

            range = new RangePosition("C53:$C$60");
            AssertSame(range.Row, 52);
            AssertSame(range.Col, 2);
            AssertSame(range.Rows, 8);
            AssertSame(range.Cols, 1);
            AssertEquals(range.ToAddress(), "C53:$C$60");
            AssertEquals(range.ToRelativeAddress(), "C53:C60");
            AssertEquals(range.ToAbsoluteAddress(), "$C$53:$C$60");
            AssertEquals(range.StartPos.ToAddress(), "C53");
            AssertEquals(range.StartPos.ToRelativeAddress(), "C53");
            AssertEquals(range.StartPos.ToAbsoluteAddress(), "$C$53");
            AssertEquals(range.EndPos.ToAddress(), "$C$60");
            AssertEquals(range.EndPos.ToRelativeAddress(), "C60");
            AssertEquals(range.EndPos.ToAbsoluteAddress(), "$C$60");

            // 32768,1048576
            range = new RangePosition("$XFD$1048576");
            AssertSame(range.Row, 1048575);
            AssertSame(range.Col, 16383);
            AssertSame(range.Rows, 1);
            AssertSame(range.Cols, 1);
            AssertEquals(range.ToAddress(), "$XFD$1048576:$XFD$1048576");
            AssertEquals(range.ToRelativeAddress(), "XFD1048576:XFD1048576");
            AssertEquals(range.ToAbsoluteAddress(), "$XFD$1048576:$XFD$1048576");
            AssertEquals(range.StartPos.ToAddress(), "$XFD$1048576");
            AssertEquals(range.StartPos.ToRelativeAddress(), "XFD1048576");
            AssertEquals(range.StartPos.ToAbsoluteAddress(), "$XFD$1048576");
            AssertEquals(range.EndPos.ToAddress(), "$XFD$1048576");
            AssertEquals(range.EndPos.ToRelativeAddress(), "XFD1048576");
            AssertEquals(range.EndPos.ToAbsoluteAddress(), "$XFD$1048576");

            // full rows
            range = new RangePosition("1:12");
            AssertSame(range.Row, 0);
            AssertSame(range.Rows, 12);
            AssertSame(range.Col, 0);
            AssertSame(range.Cols, -1);
            AssertEquals(range.ToAddress(), "1:12");
            AssertEquals(range.ToRelativeAddress(), "1:12");
            AssertEquals(range.ToAbsoluteAddress(), "$1:$12");
            AssertEquals(range.StartPos.ToAddress(), "A1");
            AssertEquals(range.StartPos.ToRelativeAddress(), "A1");
            AssertEquals(range.StartPos.ToAbsoluteAddress(), "$A$1");
            AssertEquals(range.EndPos.ToAddress(), "AVLI12");
            AssertEquals(range.EndPos.ToRelativeAddress(), "AVLI12");
            AssertEquals(range.EndPos.ToAbsoluteAddress(), "$AVLI$12");

            // full rows
            range = new RangePosition("$1:$12");
            AssertSame(range.Row, 0);
            AssertSame(range.Rows, 12);
            AssertSame(range.Col, 0);
            AssertSame(range.Cols, -1);
            AssertEquals(range.ToAddress(), "$1:$12");
            AssertEquals(range.ToRelativeAddress(), "1:12");
            AssertEquals(range.ToAbsoluteAddress(), "$1:$12");
            AssertEquals(range.StartPos.ToAddress(), "A$1");
            AssertEquals(range.StartPos.ToRelativeAddress(), "A1");
            AssertEquals(range.StartPos.ToAbsoluteAddress(), "$A$1");
            AssertEquals(range.EndPos.ToAddress(), "AVLI$12");
            AssertEquals(range.EndPos.ToRelativeAddress(), "AVLI12");
            AssertEquals(range.EndPos.ToAbsoluteAddress(), "$AVLI$12");

            // full rows
            range = new RangePosition("$1:12");
            AssertSame(range.Row, 0);
            AssertSame(range.Rows, 12);
            AssertSame(range.Col, 0);
            AssertSame(range.Cols, -1);
            AssertEquals(range.ToAddress(), "$1:12");
            AssertEquals(range.ToRelativeAddress(), "1:12");
            AssertEquals(range.ToAbsoluteAddress(), "$1:$12");
            AssertEquals(range.StartPos.ToAddress(), "A$1");
            AssertEquals(range.StartPos.ToRelativeAddress(), "A1");
            AssertEquals(range.StartPos.ToAbsoluteAddress(), "$A$1");
            AssertEquals(range.EndPos.ToAddress(), "AVLI12");
            AssertEquals(range.EndPos.ToRelativeAddress(), "AVLI12");
            AssertEquals(range.EndPos.ToAbsoluteAddress(), "$AVLI$12");

            // full rows
            range = new RangePosition("1:$12");
            AssertSame(range.Row, 0);
            AssertSame(range.Rows, 12);
            AssertSame(range.Col, 0);
            AssertSame(range.Cols, -1);
            AssertEquals(range.ToAddress(), "1:$12");
            AssertEquals(range.ToRelativeAddress(), "1:12");
            AssertEquals(range.ToAbsoluteAddress(), "$1:$12");

            // full cols
            range = new RangePosition("B:C");
            AssertSame(range.Row, 0);
            AssertSame(range.Rows, -1);
            AssertSame(range.Col, 1);
            AssertSame(range.Cols, 2);
            AssertEquals(range.ToAddress(), "B:C");
            AssertEquals(range.ToRelativeAddress(), "B:C");
            AssertEquals(range.ToAbsoluteAddress(), "$B:$C");

            // full cols
            range = new RangePosition("$B:C");
            AssertSame(range.Row, 0);
            AssertSame(range.Rows, -1);
            AssertSame(range.Col, 1);
            AssertSame(range.Cols, 2);
            AssertEquals(range.ToAddress(), "$B:C");
            AssertEquals(range.ToRelativeAddress(), "B:C");
            AssertEquals(range.ToAbsoluteAddress(), "$B:$C");

            // full cols
            range = new RangePosition("B:$C");
            AssertSame(range.Row, 0);
            AssertSame(range.Rows, -1);
            AssertSame(range.Col, 1);
            AssertSame(range.Cols, 2);
            AssertEquals(range.ToAddress(), "B:$C");
            AssertEquals(range.ToRelativeAddress(), "B:C");
            AssertEquals(range.ToAbsoluteAddress(), "$B:$C");

            // full cols
            range = new RangePosition("$A:$G");
            AssertSame(range.Row, 0);
            AssertSame(range.Rows, -1);
            AssertSame(range.Col, 0);
            AssertSame(range.Cols, 7);
            AssertEquals(range.ToAddress(), "$A:$G");
            AssertEquals(range.ToRelativeAddress(), "A:G");
            AssertEquals(range.ToAbsoluteAddress(), "$A:$G");
        }