Example #1
0
        // Creates an TableOverlap instance and adds its children.
        public TableOverlap Create()
        {
            TableOverlap tableOverlap = new TableOverlap()
            {
                Val = TableOverlapValues.Never
            };

            return(tableOverlap);
        }
Example #2
0
        public override void ToWordDocument(WordprocessingDocument wordDocument)
        {
            // Create an empty table.
            Table table = new Table();

            TableProperties tableProperties = new TableProperties();

            // TableOverlap
            TableOverlap tableOverlap = new TableOverlap()
            {
                Val = TableOverlapValues.Never
            };

            tableProperties.Append(tableOverlap);

            // Make the table width 100% of the page width (50 * 100).
            TableWidth tableWidth = new TableWidth()
            {
                Width = _width.ToString(), Type = TableWidthUnitValues.Pct
            };

            tableProperties.Append(tableWidth);

            TableJustification tableJustification = new TableJustification()
            {
                Val = TableRowAlignmentValues.Center
            };

            tableProperties.Append(tableJustification);

            // Create a TableProperties object and specify its border information.
            tableProperties.Append(
                new TableBorders(
                    new TopBorder()
            {
                Val = new EnumValue <BorderValues>(BorderValues.Double), Size = 1
            },
                    new BottomBorder()
            {
                Val = new EnumValue <BorderValues>(BorderValues.Double), Size = 1
            },
                    new LeftBorder()
            {
                Val = new EnumValue <BorderValues>(BorderValues.Double), Size = 1
            },
                    new RightBorder()
            {
                Val = new EnumValue <BorderValues>(BorderValues.Double), Size = 1
            },
                    new InsideHorizontalBorder()
            {
                Val = new EnumValue <BorderValues>(BorderValues.BasicThinLines), Size = 1
            },
                    new InsideVerticalBorder()
            {
                Val = new EnumValue <BorderValues>(BorderValues.BasicThinLines), Size = 1
            }
                    )
                );

            // TableCellMarginDefault
            TableCellMarginDefault tableCellMarginDefault = new TableCellMarginDefault();
            TableCellLeftMargin    tableCellLeftMargin    = new TableCellLeftMargin()
            {
                Width = 10, Type = TableWidthValues.Dxa
            };
            TableCellRightMargin tableCellRightMargin = new TableCellRightMargin()
            {
                Width = 10, Type = TableWidthValues.Dxa
            };

            tableCellMarginDefault.Append(tableCellLeftMargin);
            tableCellMarginDefault.Append(tableCellRightMargin);

            tableProperties.Append(tableCellMarginDefault);

            // TableLook
            TableLook tableLook = new TableLook()
            {
                Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true
            };

            tableProperties.Append(tableLook);

            // Shading
            // TableStyle
            // TablePositionProperties tablePositionProperties1 = new TablePositionProperties()
            // {
            //     LeftFromText = 141,
            //     RightFromText = 141,
            //     VerticalAnchor = VerticalAnchorValues.Text,
            //     TablePositionXAlignment = HorizontalAlignmentValues.Center,
            //     TablePositionY = 1
            // };

            // ***** NÃO ESTÁ FUNCIONANDO COM TableOverlap
            // TablePositionProperties tablePositionProperties = new TablePositionProperties();
            // tablePositionProperties.TablePositionXAlignment = HorizontalAlignmentValues.Center;
            // tablePositionProperties.VerticalAnchor = VerticalAnchorValues.Text;
            // tablePositionProperties.TablePositionY = 1;
            // tableProperties.Append(tablePositionProperties);


            // BiDiVisual

            // TableCellSpacing
            // TableIndentation

            // TableCaption tableCaption = new TableCaption() { Val = "Caption Table" };
            // tableProperties.Append(tableCaption);

            // TableDescription
            // TablePropertiesChange

            // TableGrid tableGrid = new TableGrid();
            //
            // for (int w = 0; w < this[0].Length; w++)
            //     tableGrid.Append(new GridColumn());
            //
            // table.Append(tableGrid);

            // Append the TableProperties object to the empty table.
            table.AppendChild(tableProperties);

            // Create a row and a cell.
            for (int row = 0; row < _linhas.Length; row++)
            {
                table.Append(_linhas[row].ToTableRow());
            }

            string str = table.OuterXml;

            wordDocument.MainDocumentPart.Document.Body.AppendChild(table);
        }