Exemplo n.º 1
0
        /**
         * Set the color to use for the bottom border
         *
         * @param color the color to use, null means no color
         */

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

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

            CT_BorderPr pr = ct.IsSetBottom() ? ct.bottom : ct.AddNewBottom();

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

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

            _cellXf.borderId    = (uint)idx;
            _cellXf.applyBorder = (true);
        }
Exemplo 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);
        }
Exemplo n.º 3
0
        public void setBottomBorderColor(CT_Color color)
        {
            CT_BorderPr pr = _border.IsSetBottom() ? _border.bottom : _border.AddNewBottom();

            if (color == null)
            {
                pr.UnsetColor();
            }
            else
            {
                pr.color = (color);
            }
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo n.º 6
0
        public void SetBottomBorderColor(XSSFColor color)
        {
            CT_Border ctBorder = this.GetCTBorder();

            if (color == null && !ctBorder.IsSetBottom())
            {
                return;
            }
            CT_BorderPr ctBorderPr = ctBorder.IsSetBottom() ? ctBorder.bottom : ctBorder.AddNewBottom();

            if (color != null)
            {
                ctBorderPr.SetColor(color.GetCTColor());
            }
            else
            {
                ctBorderPr.UnsetColor();
            }
            this._cellXf.borderId    = (uint)this._stylesSource.PutBorder(new XSSFCellBorder(ctBorder, this._theme));
            this._cellXf.applyBorder = true;
        }
Exemplo 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);
        }
Exemplo 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));
        }