/** * 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); }
private static CT_Border CreateDefaultBorder() { CT_Border ctBorder = new CT_Border(); ctBorder.AddNewLeft(); ctBorder.AddNewRight(); ctBorder.AddNewTop(); ctBorder.AddNewBottom(); ctBorder.AddNewDiagonal(); return(ctBorder); }
public void setBottomBorderColor(CT_Color color) { CT_BorderPr pr = _border.IsSetBottom() ? _border.bottom : _border.AddNewBottom(); if (color == null) { pr.UnsetColor(); } else { pr.color = (color); } }
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); }
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); }
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; }
/** * 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); }
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)); }