public void SetDiagonalBorderColor(XSSFColor color) { CT_Border ct = GetCTBorder(); if (color == null && !ct.IsSetDiagonal()) { return; } CT_BorderPr pr = ct.IsSetDiagonal() ? ct.diagonal : ct.AddNewDiagonal(); 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); }
public void SetDiagonalBorderColor(XSSFColor color) { CT_Border ctBorder = this.GetCTBorder(); if (color == null && !ctBorder.IsSetDiagonal()) { return; } CT_BorderPr ctBorderPr = ctBorder.IsSetDiagonal() ? ctBorder.diagonal : ctBorder.AddNewDiagonal(); 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; }
public void setDiagonalBorderColor(CT_Color color) { CT_BorderPr pr = _border.IsSetDiagonal() ? _border.diagonal : _border.AddNewDiagonal(); if (color == null) { pr.UnsetColor(); } else { pr.color = (color); } }
public void TestGetSetBorderDiagonal() { Assert.AreEqual(BorderDiagonal.None, cellStyle.BorderDiagonal); int num = stylesTable.GetBorders().Count; cellStyle.BorderDiagonalLineStyle = BorderStyle.Medium; cellStyle.BorderDiagonalColor = HSSFColor.Red.Index; cellStyle.BorderDiagonal = BorderDiagonal.Backward; Assert.AreEqual(BorderStyle.Medium, cellStyle.BorderDiagonalLineStyle); //a new border has been added Assert.AreEqual(num + 1, stylesTable.GetBorders().Count); //id of the created border uint borderId = cellStyle.GetCoreXf().borderId; Assert.IsTrue(borderId > 0); CT_Border ctBorder = stylesTable.GetBorderAt((int)borderId).GetCTBorder(); Assert.AreEqual(ST_BorderStyle.medium, ctBorder.diagonal.style); num = stylesTable.GetBorders().Count; //setting the same border multiple times should not change borderId for (int i = 0; i < 3; i++) { cellStyle.BorderDiagonal = BorderDiagonal.Backward; Assert.AreEqual(BorderDiagonal.Backward, cellStyle.BorderDiagonal); } Assert.AreEqual(borderId, cellStyle.GetCoreXf().borderId); Assert.AreEqual(num, stylesTable.GetBorders().Count); Assert.AreSame(ctBorder, stylesTable.GetBorderAt((int)borderId).GetCTBorder()); cellStyle.BorderDiagonal = (BorderDiagonal.None); Assert.AreEqual(num, stylesTable.GetBorders().Count); borderId = cellStyle.GetCoreXf().borderId; ctBorder = stylesTable.GetBorderAt((int)borderId).GetCTBorder(); Assert.IsFalse(ctBorder.IsSetDiagonal()); }