コード例 #1
0
        /**
         * Set the color to use for the top border as a {@link XSSFColor} value
         *
         * @param color the color to use
         */

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

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

            CT_BorderPr pr = ct.IsSetTop() ? ct.top : ct.AddNewTop();

            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);
        }
コード例 #2
0
ファイル: StylesTable.cs プロジェクト: zbl960/npoi
        private static CT_Border CreateDefaultBorder()
        {
            CT_Border ctBorder = new CT_Border();

            ctBorder.AddNewLeft();
            ctBorder.AddNewRight();
            ctBorder.AddNewTop();
            ctBorder.AddNewBottom();
            ctBorder.AddNewDiagonal();
            return(ctBorder);
        }
コード例 #3
0
ファイル: XSSFBorderFormatting.cs プロジェクト: founshi/npoi
        public void setTopBorderColor(CT_Color color)
        {
            CT_BorderPr pr = _border.IsSetTop() ? _border.top : _border.AddNewTop();

            if (color == null)
            {
                pr.UnsetColor();
            }
            else
            {
                pr.color = (color);
            }
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #6
0
        public void SetTopBorderColor(XSSFColor color)
        {
            CT_Border ctBorder = this.GetCTBorder();

            if (color == null && !ctBorder.IsSetTop())
            {
                return;
            }
            CT_BorderPr ctBorderPr = ctBorder.IsSetTop() ? ctBorder.top : ctBorder.AddNewTop();

            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;
        }
コード例 #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);
        }
コード例 #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));
        }