Esempio n. 1
0
        private static TableCellProperties WordCellProperties(TableStyle style)
        {
            var leftBorder             = new DocumentFormat.OpenXml.Wordprocessing.LeftBorder();
            var rightBorder            = new DocumentFormat.OpenXml.Wordprocessing.RightBorder();
            var topBorder              = new DocumentFormat.OpenXml.Wordprocessing.TopBorder();
            var bottomBorder           = new DocumentFormat.OpenXml.Wordprocessing.BottomBorder();
            var insideHorizontalBorder = new DocumentFormat.OpenXml.Wordprocessing.InsideHorizontalBorder();
            var insideVerticalBorder   = new DocumentFormat.OpenXml.Wordprocessing.InsideVerticalBorder();

            leftBorder.Val             = WordLineType(style.BorderLine);
            rightBorder.Val            = WordLineType(style.BorderLine);
            topBorder.Val              = WordLineType(style.BorderLine);
            bottomBorder.Val           = WordLineType(style.BorderLine);
            insideHorizontalBorder.Val = WordLineType(style.BorderLine);
            insideVerticalBorder.Val   = WordLineType(style.BorderLine);

            leftBorder.Color             = ColorToRgb(style.BorderColor);
            rightBorder.Color            = ColorToRgb(style.BorderColor);
            topBorder.Color              = ColorToRgb(style.BorderColor);
            bottomBorder.Color           = ColorToRgb(style.BorderColor);
            insideHorizontalBorder.Color = ColorToRgb(style.BorderColor);
            insideVerticalBorder.Color   = ColorToRgb(style.BorderColor);

            leftBorder.Size             = WordBorderWaight(style.BorderLine);
            rightBorder.Size            = WordBorderWaight(style.BorderLine);
            topBorder.Size              = WordBorderWaight(style.BorderLine);
            bottomBorder.Size           = WordBorderWaight(style.BorderLine);
            insideHorizontalBorder.Size = WordBorderWaight(style.BorderLine);
            insideVerticalBorder.Size   = WordBorderWaight(style.BorderLine);


            DocumentFormat.OpenXml.Wordprocessing.TableCellProperties cellprop = new DocumentFormat.OpenXml.Wordprocessing.TableCellProperties();
            DocumentFormat.OpenXml.Wordprocessing.Shading             shading  = new DocumentFormat.OpenXml.Wordprocessing.Shading();
            shading.Val  = DocumentFormat.OpenXml.Wordprocessing.ShadingPatternValues.Clear;
            shading.Fill = ColorToRgb(style.Foreground);

            DocumentFormat.OpenXml.Wordprocessing.TableCellBorders tableCellBorders = new DocumentFormat.OpenXml.Wordprocessing.TableCellBorders();
            tableCellBorders.LeftBorder             = leftBorder;
            tableCellBorders.RightBorder            = rightBorder;
            tableCellBorders.TopBorder              = topBorder;
            tableCellBorders.BottomBorder           = bottomBorder;
            tableCellBorders.InsideHorizontalBorder = insideHorizontalBorder;
            tableCellBorders.InsideVerticalBorder   = insideVerticalBorder;

            cellprop.Shading          = shading;
            cellprop.TableCellBorders = tableCellBorders;

            return(cellprop);
        }