Esempio n. 1
0
        /**
         * Set the color to use for the right border as a {@link XSSFColor} value
         *
         * @param color the color to use
         */

        public void SetRightBorderColor(XSSFColor color)
        {
            CT_Border ct = GetCTBorder();

            if (color == null && !ct.IsSetRight())
            {
                return;
            }

            CT_BorderPr pr = ct.IsSetRight() ? ct.right : ct.AddNewRight();

            if (color != null)
            {
                pr.color = (color.GetCTColor());
            }
            else
            {
                pr.UnsetColor();
            }

            int idx = _stylesSource.PutBorder(new XSSFCellBorder(ct, _theme));

            _cellXf.borderId    = (uint)(idx);
            _cellXf.applyBorder = (true);
        }
Esempio n. 2
0
        public void TestGetSetBorderRight()
        {
            //default values
            Assert.AreEqual(BorderStyle.None, cellStyle.BorderRight);

            int num = stylesTable.GetBorders().Count;
            cellStyle.BorderRight = (BorderStyle.Medium);
            Assert.AreEqual(BorderStyle.Medium, cellStyle.BorderRight);
            //a new border has been Added
            Assert.AreEqual(num + 1, stylesTable.GetBorders().Count);
            //id of the Created border
            uint borderId = cellStyle.GetCoreXf().borderId;
            Assert.IsTrue(borderId > 0);
            //check Changes in the underlying xml bean
            CT_Border ctBorder = stylesTable.GetBorderAt((int)borderId).GetCTBorder();
            Assert.AreEqual(ST_BorderStyle.medium, ctBorder.right.style);

            num = stylesTable.GetBorders().Count;
            //setting the same border multiple times should not change borderId
            for (int i = 0; i < 3; i++)
            {
                cellStyle.BorderRight = (BorderStyle.Medium);
                Assert.AreEqual(BorderStyle.Medium, cellStyle.BorderRight);
            }
            Assert.AreEqual(borderId, cellStyle.GetCoreXf().borderId);
            Assert.AreEqual(num, stylesTable.GetBorders().Count);
            Assert.AreSame(ctBorder, stylesTable.GetBorderAt((int)borderId).GetCTBorder());

            //setting border to none Removes the <right> element
            cellStyle.BorderRight = (BorderStyle.None);
            Assert.AreEqual(num, stylesTable.GetBorders().Count);
            borderId = cellStyle.GetCoreXf().borderId;
            ctBorder = stylesTable.GetBorderAt((int)borderId).GetCTBorder();
            Assert.IsFalse(ctBorder.IsSetRight());
        }
Esempio n. 3
0
        public void SetRightBorderColor(XSSFColor color)
        {
            CT_Border ctBorder = this.GetCTBorder();

            if (color == null && !ctBorder.IsSetRight())
            {
                return;
            }
            CT_BorderPr ctBorderPr = ctBorder.IsSetRight() ? ctBorder.right : ctBorder.AddNewRight();

            if (color != null)
            {
                ctBorderPr.color = color.GetCTColor();
            }
            else
            {
                ctBorderPr.UnsetColor();
            }
            this._cellXf.borderId    = (uint)this._stylesSource.PutBorder(new XSSFCellBorder(ctBorder, this._theme));
            this._cellXf.applyBorder = true;
        }
Esempio n. 4
0
        public void setRightBorderColor(CT_Color color)
        {
            CT_BorderPr pr = _border.IsSetRight() ? _border.right : _border.AddNewRight();

            if (color == null)
            {
                pr.UnsetColor();
            }
            else
            {
                pr.color = (color);
            }
        }