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
        private static CT_Border CreateDefaultBorder()
        {
            CT_Border ctBorder = new CT_Border();

            ctBorder.AddNewLeft();
            ctBorder.AddNewRight();
            ctBorder.AddNewTop();
            ctBorder.AddNewBottom();
            ctBorder.AddNewDiagonal();
            return(ctBorder);
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
0
        private CT_BorderPr GetBorder(BorderSide side, bool ensure)
        {
            CT_BorderPr borderPr;

            switch (side)
            {
            case BorderSide.TOP:
                borderPr = border.top;
                if (ensure && borderPr == null)
                {
                    borderPr = border.AddNewTop();
                }
                break;

            case BorderSide.RIGHT:
                borderPr = border.right;
                if (ensure && borderPr == null)
                {
                    borderPr = border.AddNewRight();
                }
                break;

            case BorderSide.BOTTOM:
                borderPr = border.bottom;
                if (ensure && borderPr == null)
                {
                    borderPr = border.AddNewBottom();
                }
                break;

            case BorderSide.LEFT:
                borderPr = border.left;
                if (ensure && borderPr == null)
                {
                    borderPr = border.AddNewLeft();
                }
                break;

            case BorderSide.DIAGONAL:
                borderPr = border.diagonal;
                if (ensure && borderPr == null)
                {
                    borderPr = border.AddNewDiagonal();
                }
                break;

            default:
                throw new ArgumentException("No suitable side specified for the border");
            }
            return(borderPr);
        }
Esempio n. 5
0
        private CT_Border GetCTBorder()
        {
            CT_Border ctBorder;

            if (this._cellXf.applyBorder)
            {
                ctBorder = this._stylesSource.GetBorderAt((int)this._cellXf.borderId).GetCTBorder();
            }
            else
            {
                ctBorder = new CT_Border();
                ctBorder.AddNewLeft();
                ctBorder.AddNewRight();
                ctBorder.AddNewTop();
                ctBorder.AddNewBottom();
                ctBorder.AddNewDiagonal();
            }
            return(ctBorder);
        }
Esempio n. 6
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. 7
0
        /**
         * Get a <b>copy</b> of the currently used CT_Border, if none is used, return a new instance.
         */

        public CT_Border GetCTBorder()
        {
            CT_Border ctBorder;

            if (_cellXf.applyBorder)
            {
                int            idx = (int)_cellXf.borderId;
                XSSFCellBorder cf  = _stylesSource.GetBorderAt(idx);

                ctBorder = (CT_Border)cf.GetCTBorder();
            }
            else
            {
                ctBorder = new CT_Border();
                ctBorder.AddNewLeft();
                ctBorder.AddNewRight();
                ctBorder.AddNewTop();
                ctBorder.AddNewBottom();
                ctBorder.AddNewDiagonal();
            }
            return(ctBorder);
        }
Esempio n. 8
0
        public void TestGetBorderStyle()
        {
            CT_Stylesheet stylesheet = new CT_Stylesheet();
            CT_Border     border     = stylesheet.AddNewBorders().AddNewBorder();
            CT_BorderPr   top        = border.AddNewTop();
            CT_BorderPr   right      = border.AddNewRight();
            CT_BorderPr   bottom     = border.AddNewBottom();

            top.style    = (ST_BorderStyle.dashDot);
            right.style  = (ST_BorderStyle.none);
            bottom.style = (ST_BorderStyle.thin);

            XSSFCellBorder cellBorderStyle = new XSSFCellBorder(border);

            Assert.AreEqual("DashDot", cellBorderStyle.GetBorderStyle(BorderSide.TOP).ToString());

            Assert.AreEqual("None", cellBorderStyle.GetBorderStyle(BorderSide.RIGHT).ToString());
            Assert.AreEqual(BorderStyle.None, cellBorderStyle.GetBorderStyle(BorderSide.RIGHT));

            Assert.AreEqual("Thin", cellBorderStyle.GetBorderStyle(BorderSide.BOTTOM).ToString());

            Assert.AreEqual(BorderStyle.Thin, cellBorderStyle.GetBorderStyle(BorderSide.BOTTOM));
        }