Beispiel #1
0
        private void ApplyBorderDiagonalStyle(ICellStyle cellStyle, DocumentModel.BorderStyle borderStyleDiagonalUpLeftToBottomRight, DocumentModel.BorderStyle borderStyleDiagonalUpRightToBottomLeft)
        {
            if (borderStyleDiagonalUpLeftToBottomRight == null && borderStyleDiagonalUpRightToBottomLeft == null)
            {
                return;
            }

            var style = (XSSFCellStyle)cellStyle;

            if (borderStyleDiagonalUpLeftToBottomRight != null && borderStyleDiagonalUpRightToBottomLeft != null && borderStyleDiagonalUpLeftToBottomRight.Type != BorderType.None && borderStyleDiagonalUpRightToBottomLeft.Type != BorderType.None)
            {
                style.BorderDiagonal = BorderDiagonal.Both;
            }
            else if (borderStyleDiagonalUpLeftToBottomRight != null && borderStyleDiagonalUpLeftToBottomRight.Type != BorderType.None)
            {
                style.BorderDiagonal          = BorderDiagonal.Backward;
                style.BorderDiagonalLineStyle = this.GetBorderStyle(borderStyleDiagonalUpLeftToBottomRight.Type);
                if (borderStyleDiagonalUpLeftToBottomRight.Color.HasValue)
                {
                    var color = borderStyleDiagonalUpLeftToBottomRight.Color.Value;
                    style.SetDiagonalBorderColor(new XSSFColor(new[] { color.Red, color.Green, color.Blue }));
                }
            }
            else if (borderStyleDiagonalUpRightToBottomLeft != null && borderStyleDiagonalUpRightToBottomLeft.Type != BorderType.None)
            {
                style.BorderDiagonal          = BorderDiagonal.Forward;
                style.BorderDiagonalLineStyle = this.GetBorderStyle(borderStyleDiagonalUpRightToBottomLeft.Type);

                if (borderStyleDiagonalUpRightToBottomLeft.Color.HasValue)
                {
                    var color = borderStyleDiagonalUpRightToBottomLeft.Color.Value;
                    style.SetDiagonalBorderColor(new XSSFColor(new[] { color.Red, color.Green, color.Blue }));
                }
            }
        }
Beispiel #2
0
        private void ApplyBorderStyleLeft(ICellStyle cellStyle, DocumentModel.BorderStyle borderStyleLeft)
        {
            if (borderStyleLeft == null)
            {
                return;
            }

            cellStyle.BorderLeft = this.GetBorderStyle(borderStyleLeft.Type);

            if (borderStyleLeft.Color.HasValue)
            {
                XSSFCellStyle style = cellStyle as XSSFCellStyle;
                var           color = borderStyleLeft.Color.Value;
                style.SetLeftBorderColor(new XSSFColor(new[] { color.Red, color.Green, color.Blue }));
            }
        }