/** * 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); }
public void TestGetSetBorderBottom() { //default values Assert.AreEqual(BorderStyle.None, cellStyle.BorderBottom); int num = stylesTable.GetBorders().Count; cellStyle.BorderBottom = (BorderStyle.Medium); Assert.AreEqual(BorderStyle.Medium, cellStyle.BorderBottom); //a new border has been Added Assert.AreEqual(num + 1, stylesTable.GetBorders().Count); //id of the Created border int borderId = (int)cellStyle.GetCoreXf().borderId; Assert.IsTrue(borderId > 0); //check Changes in the underlying xml bean CT_Border ctBorder = stylesTable.GetBorderAt(borderId).GetCTBorder(); Assert.AreEqual(ST_BorderStyle.medium, ctBorder.bottom.style); num = stylesTable.GetBorders().Count; //setting the same border multiple times should not change borderId for (int i = 0; i < 3; i++) { cellStyle.BorderBottom = (BorderStyle.Medium); Assert.AreEqual(BorderStyle.Medium, cellStyle.BorderBottom); } Assert.AreEqual((uint)borderId, cellStyle.GetCoreXf().borderId); Assert.AreEqual(num, stylesTable.GetBorders().Count); Assert.AreSame(ctBorder, stylesTable.GetBorderAt(borderId).GetCTBorder()); //setting border to none Removes the <bottom> element cellStyle.BorderBottom = (BorderStyle.None); Assert.AreEqual(num, stylesTable.GetBorders().Count); borderId = (int)cellStyle.GetCoreXf().borderId; ctBorder = stylesTable.GetBorderAt(borderId).GetCTBorder(); Assert.IsFalse(ctBorder.IsSetBottom()); }
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; }
public void setBottomBorderColor(CT_Color color) { CT_BorderPr pr = _border.IsSetBottom() ? _border.bottom : _border.AddNewBottom(); if (color == null) { pr.UnsetColor(); } else { pr.color = (color); } }