/// <summary> /// Form a DocumentFormat.OpenXml.Spreadsheet.Border class from SLBorder. /// </summary> /// <returns>A DocumentFormat.OpenXml.Spreadsheet.Border with the properties of this SLBorder class.</returns> public Border ToBorder() { Sync(); var border = new Border(); // by "default" always have left, right, top, bottom and diagonal borders, even if empty? border.LeftBorder = LeftBorder.ToLeftBorder(); border.RightBorder = RightBorder.ToRightBorder(); border.TopBorder = TopBorder.ToTopBorder(); border.BottomBorder = BottomBorder.ToBottomBorder(); border.DiagonalBorder = DiagonalBorder.ToDiagonalBorder(); if (HasVerticalBorder) { border.VerticalBorder = VerticalBorder.ToVerticalBorder(); } if (HasHorizontalBorder) { border.HorizontalBorder = HorizontalBorder.ToHorizontalBorder(); } if (DiagonalUp != null) { border.DiagonalUp = DiagonalUp.Value; } if (DiagonalDown != null) { border.DiagonalDown = DiagonalDown.Value; } // default is true. So set property only if false // This reduces tag attributes if ((Outline != null) && !Outline.Value) { border.Outline = false; } return(border); }