Esempio n. 1
0
        private void SetCellText(TableCell cell, string text, bool bold)
        {
            ParagraphProperties parProperties = new ParagraphProperties();

            parProperties.Justification     = new Justification();
            parProperties.Justification.Val = JustificationValues.Center;
            Paragraph paragraph = new Paragraph();

            paragraph.AppendChild(parProperties);
            var run = new Run(new Text(text));

            run.RunProperties              = new RunProperties();
            run.RunProperties.FontSize     = new FontSize();
            run.RunProperties.FontSize.Val = new StringValue("28");
            if (bold)
            {
                run.RunProperties.Bold = new Bold();
            }
            paragraph.AppendChild(run);
            cell.AppendChild(paragraph);
        }
        /// <summary>
        /// The write table.
        /// </summary>
        /// <param name="t">The t.</param>
        public void WriteTable(Table t)
        {
            this.body.AppendChild(CreateParagraph(t.GetFullCaption(this.style), TableCaptionId));

            var table = new DocumentFormat.OpenXml.Wordprocessing.Table();

            var tableProperties1 = new TableProperties();
            var tableStyle1      = new TableStyle {
                Val = "TableGrid"
            };
            var tableWidth1 = new TableWidth {
                Width = "0", Type = TableWidthUnitValues.Auto
            };
            var tableLook1 = new TableLook
            {
                Val              = "04A0",
                FirstRow         = true,
                LastRow          = false,
                FirstColumn      = true,
                LastColumn       = false,
                NoHorizontalBand = false,
                NoVerticalBand   = true
            };

            tableProperties1.AppendChild(tableStyle1);
            tableProperties1.AppendChild(tableWidth1);
            tableProperties1.AppendChild(tableLook1);

            var tableGrid1 = new TableGrid();

            // ReSharper disable once UnusedVariable
            foreach (var tc in t.Columns)
            {
                // TODO: use tc.Width to set the width of the column
                var gridColumn1 = new GridColumn {
                    Width = "3070"
                };
                tableGrid1.AppendChild(gridColumn1);
            }

            foreach (var row in t.Rows)
            {
                var tr = new TableRow();

                if (row.IsHeader)
                {
                    var trp          = new TableRowProperties();
                    var tableHeader1 = new TableHeader();
                    trp.AppendChild(tableHeader1);
                    tr.AppendChild(trp);
                }

                int j = 0;
                foreach (var c in row.Cells)
                {
                    bool isHeader = row.IsHeader || t.Columns[j++].IsHeader;
                    var  cell     = new TableCell();
                    var  tcp      = new TableCellProperties();
                    var  borders  = new TableCellBorders();
                    borders.AppendChild(
                        new BottomBorder
                    {
                        Val   = BorderValues.Single,
                        Size  = 4U,
                        Space = 0U,
                        Color = "auto"
                    });
                    borders.AppendChild(
                        new TopBorder
                    {
                        Val   = BorderValues.Single,
                        Size  = 4U,
                        Space = 0U,
                        Color = "auto"
                    });
                    borders.AppendChild(
                        new LeftBorder
                    {
                        Val   = BorderValues.Single,
                        Size  = 4U,
                        Space = 0U,
                        Color = "auto"
                    });
                    borders.AppendChild(
                        new RightBorder
                    {
                        Val   = BorderValues.Single,
                        Size  = 4U,
                        Space = 0U,
                        Color = "auto"
                    });
                    tcp.AppendChild(borders);

                    cell.AppendChild(tcp);
                    string styleId = isHeader ? "TableHeader" : "TableText";
                    cell.AppendChild(CreateParagraph(c.Content, styleId));
                    tr.AppendChild(cell);
                }

                table.AppendChild(tr);
            }

            this.body.AppendChild(table);
        }
 Word.TableRow CreateRow(ArrayList cellText)
 {
     Word.TableRow tr = new Word.TableRow();
     // Create cells with simple text.
     foreach (string s in cellText)
     {
         Word.TableCell tc = new Word.TableCell();
         Word.Paragraph p = new Word.Paragraph();
         Word.Run r = new Word.Run();
         Word.Text t = new Word.Text(s);
         r.AppendChild(t);
         p.AppendChild(r);
         tc.AppendChild(p);
         tr.AppendChild(tc);
     }
     return tr;
 }
        public void InsertForcesTable(IForcesModel forces)
        {
            Paragraph     para          = _body.AppendChild(new Paragraph());
            Run           run           = para.AppendChild(new Run());
            RunProperties runProperties = getHeading2(run);

            run.AppendChild(new Text(++_diagmarCounter + ". Decision Forces Viewpoint: " + forces.Name));
            //_body.AppendChild(new Paragraph(new Run(new Text(++_diagmarCounter + ". Decision Forces Viewpoint"))));
            _body.AppendChild(new Paragraph(new Run(new Text())));

            var table = new Table();

            var props = new TableProperties(
                new TableBorders(
                    new TopBorder
            {
                Val  = new EnumValue <BorderValues>(BorderValues.Single),
                Size = 11
            },
                    new BottomBorder
            {
                Val  = new EnumValue <BorderValues>(BorderValues.Single),
                Size = 11
            },
                    new LeftBorder
            {
                Val  = new EnumValue <BorderValues>(BorderValues.Single),
                Size = 11
            },
                    new RightBorder
            {
                Val  = new EnumValue <BorderValues>(BorderValues.Single),
                Size = 11
            },
                    new InsideHorizontalBorder
            {
                Val  = new EnumValue <BorderValues>(BorderValues.Single),
                Size = 11
            },
                    new InsideVerticalBorder
            {
                Val  = new EnumValue <BorderValues>(BorderValues.Single),
                Size = 11
            }));

            table.AppendChild(props);

            var emptyCell = new TableCell();

            // insert an empty cell in tol left of forces table
            var decRow = new TableRow();

            decRow.AppendChild(emptyCell);
            emptyCell.AppendChild(new Paragraph(new Run(new Text(""))));

            // insert the concern header and the decisions names
            var concCellHeader = new TableCell(new Paragraph(new Run(new Text("Concerns"))));

            decRow.AppendChild(concCellHeader);
            foreach (
                TableCell decCell in
                forces.GetDecisions()
                .Select(decision => new TableCell(new Paragraph(new Run(new Text(decision.Name))))))
            {
                decRow.AppendChild(decCell);
            }
            table.AppendChild(decRow);


            foreach (var concernsPerForces in forces.GetConcernsPerForce())
            {
                IEAElement        force    = concernsPerForces.Key;
                List <IEAElement> concerns = concernsPerForces.Value;

                foreach (IEAElement concern in concerns)
                {
                    var forceRow  = new TableRow();
                    var forceCell = new TableCell(new Paragraph(new Run(new Text(force.Name))));
                    forceRow.AppendChild(forceCell);
                    var concCell = new TableCell();
                    concCell.AppendChild(new Paragraph(new Run(new Text(concern.Name))));
                    forceRow.AppendChild(concCell);

                    // insert ratings
                    foreach (Rating rating in forces.GetRatings())
                    {
                        if (rating.ForceGUID != force.GUID || rating.ConcernGUID != concern.GUID)
                        {
                            continue;
                        }
                        if (forces.GetDecisions().Any(decision => rating.DecisionGUID == decision.GUID))
                        {
                            var ratCell = new TableCell();
                            ratCell.AppendChild(new Paragraph(new Run(new Text(rating.Value))));
                            forceRow.AppendChild(ratCell);
                        }
                    }
                    table.AppendChild(forceRow);
                }
            }


            _body.AppendChild(table);
            _body.AppendChild(new Paragraph());
        }
Esempio n. 5
0
        private void AddSecondPageTable(Body body)
        {
            Table           personalInfoTable = new Table();
            TableProperties tableProps        = new TableProperties();

            AddTableBorders(tableProps);
            TableStyle tableStyle = new TableStyle()
            {
                Val = "TableGrid"
            };
            TableWidth tableWidth = new TableWidth()
            {
                Width = "5000", Type = TableWidthUnitValues.Pct
            };

            tableProps.Append(tableStyle, tableWidth);
            TableGrid tableGrid = new TableGrid();

            personalInfoTable.AppendChild(tableProps);
            for (int x = 0; x < 6; x++)
            {
                tableGrid.AppendChild(new GridColumn());
            }
            personalInfoTable.AppendChild(tableGrid);
            for (int x = 0; x < 7; x++)
            {
                TableRow         pesonalTableRow = new TableRow();
                List <TableCell> cells           = new List <TableCell>();
                for (int i = 0; i < 6; i++)
                {
                    TableCell           cell = new TableCell();
                    TableCellProperties tableCellProperties = new TableCellProperties();
                    tableCellProperties.TableCellVerticalAlignment     = new TableCellVerticalAlignment();
                    tableCellProperties.TableCellVerticalAlignment.Val = TableVerticalAlignmentValues.Center;
                    VerticalMerge   verticalMerge   = new VerticalMerge();
                    HorizontalMerge horizontalMerge = new HorizontalMerge();
                    if (x == 0)
                    {
                        horizontalMerge.Val = i == 0 ? MergedCellValues.Restart : MergedCellValues.Continue;
                        tableCellProperties.AppendChild(horizontalMerge);
                        if (i == 0)
                        {
                            SetCellText(cell, "Time Table", true);
                        }
                        else
                        {
                            SetCellText(cell, "", false);
                        }
                    }
                    else if (i == 0)
                    {
                        verticalMerge.Val = x == 1 ? MergedCellValues.Restart : MergedCellValues.Continue;
                        tableCellProperties.AppendChild(verticalMerge);
                        if (x == 1)
                        {
                            SetCellText(cell, "Hours", true);
                        }
                        else
                        {
                            SetCellText(cell, "", false);
                        }
                    }
                    else if (x == 1)
                    {
                        switch (i)
                        {
                        case 1:
                            SetCellText(cell, "Mon", true);
                            break;

                        case 2:
                            SetCellText(cell, "Tue", true);
                            break;

                        case 3:
                            SetCellText(cell, "Wed", true);
                            break;

                        case 4:
                            SetCellText(cell, "Thu", true);
                            break;

                        case 5:
                            SetCellText(cell, "Fri", true);
                            break;
                        }
                    }
                    else if (x == 4)
                    {
                        horizontalMerge.Val = i == 1 ? MergedCellValues.Restart : MergedCellValues.Continue;
                        tableCellProperties.AppendChild(horizontalMerge);
                        if (i == 1)
                        {
                            SetCellText(cell, "Lunch", true);
                        }
                        else
                        {
                            SetCellText(cell, "", false);
                        }
                    }
                    else if (x == 2 || x == 5)
                    {
                        switch (i)
                        {
                        case 1:
                        case 3:
                            SetCellText(cell, "Science", false);
                            break;

                        case 2:
                        case 4:
                            SetCellText(cell, "Maths", false);
                            break;
                        }
                    }
                    else if (x == 3 || x == 6)
                    {
                        switch (i)
                        {
                        case 1:
                        case 4:
                            SetCellText(cell, "Social", false);
                            break;

                        case 2:
                            SetCellText(cell, "History", false);
                            break;

                        case 3:
                            SetCellText(cell, "English", false);
                            break;
                        }
                    }
                    if (x == 2 && i == 5)
                    {
                        SetCellText(cell, "Arts", false);
                    }
                    else if (x == 3 && i == 5)
                    {
                        SetCellText(cell, "Sports", false);
                    }
                    else if (i == 5 && (x == 5 || x == 6))
                    {
                        if (x == 5)
                        {
                            verticalMerge.Val = MergedCellValues.Restart;
                            SetCellText(cell, "Project", false);
                        }
                        else
                        {
                            verticalMerge.Val = MergedCellValues.Continue;
                            SetCellText(cell, "", false);
                        }
                        tableCellProperties.AppendChild(verticalMerge);
                    }
                    cell.AppendChild(tableCellProperties);
                    cells.Add(cell);
                }
                pesonalTableRow.Append(cells);
                personalInfoTable.AppendChild(pesonalTableRow);
            }
            body.AppendChild(personalInfoTable);
        }
        public void InsertDecisionTable(IDecision decision)
        {
            var dataDict = new Dictionary <String, IList <String> >();

            dataDict.Add("Name", new List <string>());
            dataDict.Add("State", new List <string>());
            dataDict.Add("Problem", new List <string>());
            dataDict.Add("Decision", new List <string>());
            dataDict.Add("Argumentation", new List <string>());
            dataDict.Add("Alternatives", new List <string>());
            dataDict.Add("Related Decisions", new List <string>());
            dataDict.Add("Forces", new List <string>());
            dataDict.Add("Traces", new List <string>());
            dataDict.Add("Stakeholder Involvement", new List <string>());
            dataDict.Add("History", new List <string>());


            dataDict["Name"].Add(decision.Name);
            dataDict["State"].Add(decision.State);
            //dataDict["Problem"].Add(decision.Problem);
            //dataDict["Decision"].Add(decision.Solution);
            //dataDict["Argumentation"].Add(decision.Argumentation);

            _decisionCounter++;
            //_body.AppendChild(new Paragraph(new Run(new Text("Decision " +_decisionCounter.ToString() +": " + decision.Name))));

            var table = new Table();

            var props = new TableProperties(
                new TableBorders(
                    new TopBorder
            {
                Val  = new EnumValue <BorderValues>(BorderValues.Single),
                Size = 11
            },
                    new BottomBorder
            {
                Val  = new EnumValue <BorderValues>(BorderValues.Single),
                Size = 11
            },
                    new LeftBorder
            {
                Val  = new EnumValue <BorderValues>(BorderValues.Single),
                Size = 11
            },
                    new RightBorder
            {
                Val  = new EnumValue <BorderValues>(BorderValues.Single),
                Size = 11
            },
                    new InsideHorizontalBorder
            {
                Val  = new EnumValue <BorderValues>(BorderValues.Single),
                Size = 11
            },
                    new InsideVerticalBorder
            {
                Val  = new EnumValue <BorderValues>(BorderValues.Single),
                Size = 11
            },
                    new TableWidth
            {
                Width = "5000",
                Type  = TableWidthUnitValues.Pct
            }
                    ),
                new TableCaption
            {
                Val = new StringValue("My Caption Val")         // Does not work..
            });

            table.AppendChild(props);

            foreach (IDecisionRelation relation in decision.RelatedDecisions)
            {
                dataDict["Related Decisions"].Add(relation.Decision.GUID.Equals(decision.GUID)
                                                      ? "<<this>> " + decision.Name + " - " + relation.Type +
                                                  " - " +
                                                  relation.RelatedDecision.Name
                                                      : relation.Decision.Name + " - " + relation.Type +
                                                  " - <<this>> " + decision.Name + "\r\n");
            }

            foreach (IDecisionRelation alternative in decision.Alternatives)
            {
                dataDict["Alternatives"].Add(alternative.Decision.GUID.Equals(decision.GUID)
                                                 ? "<<this>> " + decision.Name + " - " + alternative.Type +
                                             " - " + alternative.RelatedDecision.Name
                                                 : alternative.Decision.Name + " - " + alternative.Type +
                                             " - <<this>> " + decision.Name + "\r\n");
            }


            foreach (IForceEvaluation rating in decision.Forces)
            {
                IEAElement force = EAMain.Repository.GetElementByGUID(rating.Force.ForceGUID);
                dataDict["Forces"].Add(rating.Force.Name + " - " + force.Notes);
            }


            foreach (ITraceLink trace in decision.Traces)
            {
                dataDict["Traces"].Add(trace.TracedElementName);
            }


            foreach (IHistoryEntry entry in decision.History)
            {
                dataDict["History"].Add(entry.State + " " + entry.Modified.ToShortDateString());
            }

            foreach (IStakeholderAction stakeholderInvolvment in decision.Stakeholders)
            {
                string line = string.Format(Messages.ReportingStakeholderInvolvmentLine,
                                            stakeholderInvolvment.Stakeholder.Role,
                                            stakeholderInvolvment.Stakeholder.Name,
                                            stakeholderInvolvment.Action);
                dataDict["Stakeholder Involvement"].Add(line);
            }


            foreach (var entry in dataDict)
            {
                if (entry.Value.Count == 0)
                {
                    continue;
                }
                if ("".Equals(entry.Value[0]))
                {
                    continue;
                }

                var tableRow = new TableRow();

                var rowHeader = new TableCell();
                rowHeader.Append(new TableCellWidth {
                    Type = TableWidthUnitValues.Dxa, Width = "1821"
                });
                rowHeader.Append(
                    new TableCellProperties(new Shading
                {
                    Val   = ShadingPatternValues.Clear,
                    Color = "auto",
                    Fill  = "##d3d4d6"
                }));
                Paragraph para = rowHeader.AppendChild(new Paragraph());
                Run       run  = para.AppendChild(new Run());
                getBold(run);
                run.AppendChild(new Text(entry.Key));

                var       rowValue     = new TableCell();
                Paragraph rowValuePara = rowValue.AppendChild(new Paragraph());
                Run       rowValueRun  = rowValuePara.AppendChild(new Run());
                int       lineCount    = 0;
                foreach (string line in entry.Value)
                {
                    rowValueRun.AppendChild(new Text(line));
                    if (++lineCount != entry.Value.Count)
                    {
                        rowValueRun.AppendChild(new Break());
                    }
                }

                tableRow.AppendChild(rowHeader);
                tableRow.AppendChild(rowValue);
                table.AppendChild(tableRow);
            }

            /*  for (int i = 0; i <= data.GetUpperBound(0); i++)
             * {
             *  var tr = new TableRow();
             *  for (int j = 0; j <= data.GetUpperBound(1); j++)
             *  {
             *      var tc = new TableCell();
             *      if (j == 0)
             *      {
             *          //Apply the same width at column 1 (0)
             *          tc.Append(new TableCellWidth {Type = TableWidthUnitValues.Dxa, Width = "1821"});
             *          tc.Append(new TableCellProperties(new Shading{Val = ShadingPatternValues.Clear,Color = "auto",Fill = "##d3d4d6"}));
             *          Paragraph para = tc.AppendChild(new Paragraph());
             *          Run run = para.AppendChild(new Run());
             *          RunProperties runProperties = getBold(run);
             *          run.AppendChild(new Text(dataDict.));
             *      }
             *      else
             *      {
             *          tc.AppendChild(new Paragraph(new Run(new Text(data[i, j]))));
             *      }
             *
             *      tr.AppendChild(tc);
             *  }
             *  if (data[i, 1] != "")
             *      table.AppendChild(tr);
             * }*/

            _body.AppendChild(table);
            _body.AppendChild(new Paragraph());
        }
Esempio n. 7
0
 /// <summary>
 /// Adds a paragraph to the table cell
 /// </summary>
 /// <returns></returns>
 protected override DocumentFormat.OpenXml.Wordprocessing.Paragraph NewParagraph()
 {
     return(tableCell.AppendChild(new DocumentFormat.OpenXml.Wordprocessing.Paragraph()));
 }
        private static void FillSecondTableRow(OpenXmlElement table)
        {
            var tableRow = new TableRow
            {
                TextId               = HexBinaryValue.FromString("77777777"),
                ParagraphId          = HexBinaryValue.FromString("3125C09D"),
                RsidTableRowAddition = HexBinaryValue.FromString("009B2C1D")
            };
            var rowProperties = new TableRowProperties();

            rowProperties.AppendChild(new GridAfter
            {
                Val = Int32Value.FromInt32(2)
            });
            rowProperties.AppendChild(new WidthAfterTableRow
            {
                Width = StringValue.FromString("6375"),
                Type  = new EnumValue <TableWidthUnitValues> {
                    Value = TableWidthUnitValues.Dxa
                }
            });
            tableRow.TableRowProperties = rowProperties;

            var tableCell = new TableCell
            {
                TableCellProperties = new TableCellProperties
                {
                    TableCellWidth = new TableCellWidth
                    {
                        Width = StringValue.FromString("800"),
                        Type  = new EnumValue <TableWidthUnitValues> {
                            Value = TableWidthUnitValues.Dxa
                        }
                    },
                    TableCellBorders = new TableCellBorders
                    {
                        TopBorder = new TopBorder
                        {
                            Val = new EnumValue <BorderValues> {
                                Value = BorderValues.Single
                            },
                            Size  = UInt32Value.FromUInt32(0),
                            Space = UInt32Value.FromUInt32(0),
                            Color = StringValue.FromString("FFFFFF")
                        },
                        LeftBorder = new LeftBorder
                        {
                            Val = new EnumValue <BorderValues> {
                                Value = BorderValues.Single
                            },
                            Size  = UInt32Value.FromUInt32(0),
                            Space = UInt32Value.FromUInt32(0),
                            Color = StringValue.FromString("FFFFFF")
                        },
                        BottomBorder = new BottomBorder
                        {
                            Val = new EnumValue <BorderValues> {
                                Value = BorderValues.Single
                            },
                            Size  = UInt32Value.FromUInt32(0),
                            Space = UInt32Value.FromUInt32(0),
                            Color = StringValue.FromString("FFFFFF")
                        },
                        RightBorder = new RightBorder
                        {
                            Val = new EnumValue <BorderValues> {
                                Value = BorderValues.Single
                            },
                            Size  = UInt32Value.FromUInt32(0),
                            Space = UInt32Value.FromUInt32(0),
                            Color = StringValue.FromString("FFFFFF")
                        }
                    }
                }
            };

            tableCell.AppendChild(new Paragraph
            {
                ParagraphId            = HexBinaryValue.FromString("595BC873"),
                TextId                 = HexBinaryValue.FromString("77777777"),
                RsidParagraphAddition  = HexBinaryValue.FromString("009B2C1D"),
                RsidRunAdditionDefault = HexBinaryValue.FromString("009B2C1D")
            });
            tableRow.AppendChild(tableCell);
            table.AppendChild(tableRow);
        }
        private static void FillFourthTableRow(OpenXmlElement table, GenerationData data)
        {
            var tableRow = new TableRow
            {
                TextId               = HexBinaryValue.FromString("77777777"),
                ParagraphId          = HexBinaryValue.FromString("0E828CE9"),
                RsidTableRowAddition = HexBinaryValue.FromString("009B2C1D")
            };

            var tableCell1 = new TableCell
            {
                TableCellProperties = new TableCellProperties
                {
                    TableCellWidth = new TableCellWidth
                    {
                        Width = StringValue.FromString("800"),
                        Type  = new EnumValue <TableWidthUnitValues> {
                            Value = TableWidthUnitValues.Dxa
                        }
                    },
                    TableCellBorders = new TableCellBorders
                    {
                        TopBorder = new TopBorder
                        {
                            Val = new EnumValue <BorderValues> {
                                Value = BorderValues.Single
                            },
                            Size  = UInt32Value.FromUInt32(0),
                            Space = UInt32Value.FromUInt32(0),
                            Color = StringValue.FromString("FFFFFF")
                        },
                        LeftBorder = new LeftBorder
                        {
                            Val = new EnumValue <BorderValues> {
                                Value = BorderValues.Single
                            },
                            Size  = UInt32Value.FromUInt32(0),
                            Space = UInt32Value.FromUInt32(0),
                            Color = StringValue.FromString("FFFFFF")
                        },
                        BottomBorder = new BottomBorder
                        {
                            Val = new EnumValue <BorderValues> {
                                Value = BorderValues.Single
                            },
                            Size  = UInt32Value.FromUInt32(0),
                            Space = UInt32Value.FromUInt32(0),
                            Color = StringValue.FromString("FFFFFF")
                        },
                        RightBorder = new RightBorder
                        {
                            Val = new EnumValue <BorderValues> {
                                Value = BorderValues.Single
                            },
                            Size  = UInt32Value.FromUInt32(0),
                            Space = UInt32Value.FromUInt32(0),
                            Color = StringValue.FromString("FFFFFF")
                        }
                    }
                }
            };

            tableCell1.AppendChild(new Paragraph {
                ParagraphId            = HexBinaryValue.FromString("7D33E7CB"),
                TextId                 = HexBinaryValue.FromString("77777777"),
                RsidParagraphAddition  = HexBinaryValue.FromString("009B2C1D"),
                RsidRunAdditionDefault = HexBinaryValue.FromString("009B2C1D")
            });
            tableRow.AppendChild(tableCell1);

            var tableCell2 = new TableCell
            {
                TableCellProperties = new TableCellProperties
                {
                    TableCellWidth = new TableCellWidth
                    {
                        Width = StringValue.FromString("2550"),
                        Type  = new EnumValue <TableWidthUnitValues> {
                            Value = TableWidthUnitValues.Dxa
                        }
                    },
                    TableCellBorders = new TableCellBorders
                    {
                        TopBorder = new TopBorder
                        {
                            Val = new EnumValue <BorderValues> {
                                Value = BorderValues.Single
                            },
                            Size  = UInt32Value.FromUInt32(0),
                            Space = UInt32Value.FromUInt32(0),
                            Color = StringValue.FromString("FFFFFF")
                        },
                        LeftBorder = new LeftBorder
                        {
                            Val = new EnumValue <BorderValues> {
                                Value = BorderValues.Single
                            },
                            Size  = UInt32Value.FromUInt32(0),
                            Space = UInt32Value.FromUInt32(0),
                            Color = StringValue.FromString("FFFFFF")
                        },
                        BottomBorder = new BottomBorder
                        {
                            Val = new EnumValue <BorderValues> {
                                Value = BorderValues.Single
                            },
                            Size  = UInt32Value.FromUInt32(0),
                            Space = UInt32Value.FromUInt32(0),
                            Color = StringValue.FromString("FFFFFF")
                        },
                        RightBorder = new RightBorder
                        {
                            Val = new EnumValue <BorderValues> {
                                Value = BorderValues.Single
                            },
                            Size  = UInt32Value.FromUInt32(0),
                            Space = UInt32Value.FromUInt32(0),
                            Color = StringValue.FromString("FFFFFF")
                        }
                    }
                }
            };

            tableCell2.AppendChild(new Paragraph
            {
                ParagraphId            = HexBinaryValue.FromString("4B505573"),
                TextId                 = HexBinaryValue.FromString("77777777"),
                RsidParagraphAddition  = HexBinaryValue.FromString("009B2C1D"),
                RsidRunAdditionDefault = HexBinaryValue.FromString("009B2C1D")
            });
            tableRow.AppendChild(tableCell2);

            var tableCell3 = new TableCell
            {
                TableCellProperties = new TableCellProperties
                {
                    TableCellWidth = new TableCellWidth
                    {
                        Width = StringValue.FromString("3825"),
                        Type  = new EnumValue <TableWidthUnitValues> {
                            Value = TableWidthUnitValues.Dxa
                        }
                    },
                    TableCellBorders = new TableCellBorders
                    {
                        TopBorder = new TopBorder
                        {
                            Val = new EnumValue <BorderValues> {
                                Value = BorderValues.Single
                            },
                            Size  = UInt32Value.FromUInt32(0),
                            Space = UInt32Value.FromUInt32(0),
                            Color = StringValue.FromString("FFFFFF")
                        },
                        LeftBorder = new LeftBorder
                        {
                            Val = new EnumValue <BorderValues> {
                                Value = BorderValues.Single
                            },
                            Size  = UInt32Value.FromUInt32(0),
                            Space = UInt32Value.FromUInt32(0),
                            Color = StringValue.FromString("FFFFFF")
                        },
                        BottomBorder = new BottomBorder
                        {
                            Val = new EnumValue <BorderValues> {
                                Value = BorderValues.Single
                            },
                            Size  = UInt32Value.FromUInt32(0),
                            Space = UInt32Value.FromUInt32(0),
                            Color = StringValue.FromString("FFFFFF")
                        },
                        RightBorder = new RightBorder
                        {
                            Val = new EnumValue <BorderValues> {
                                Value = BorderValues.Single
                            },
                            Size  = UInt32Value.FromUInt32(0),
                            Space = UInt32Value.FromUInt32(0),
                            Color = StringValue.FromString("FFFFFF")
                        }
                    },
                    Shading = new Shading
                    {
                        Val = new EnumValue <ShadingPatternValues> {
                            Value = ShadingPatternValues.Clear
                        },
                        Color = StringValue.FromString("auto"),
                        Fill  = StringValue.FromString("0069B4")
                    },
                    TableCellVerticalAlignment = new TableCellVerticalAlignment
                    {
                        Val = new EnumValue <TableVerticalAlignmentValues> {
                            Value = TableVerticalAlignmentValues.Center
                        }
                    }
                }
            };

            tableCell3.AppendChild(new Paragraph(new Run(new DocumentFormat.OpenXml.Wordprocessing.Text(data.TitleArea.Title))
            {
                RunProperties = new DocumentFormat.OpenXml.Wordprocessing.RunProperties
                {
                    Color = new Color {
                        Val = StringValue.FromString("FFFFFF")
                    },
                    FontSize = new FontSize {
                        Val = StringValue.FromString("18")
                    },
                    FontSizeComplexScript = new FontSizeComplexScript {
                        Val = StringValue.FromString("18")
                    }
                }
            })
            {
                ParagraphId            = HexBinaryValue.FromString("63EAFC9C"),
                TextId                 = HexBinaryValue.FromString("77777777"),
                RsidParagraphAddition  = HexBinaryValue.FromString("009B2C1D"),
                RsidRunAdditionDefault = HexBinaryValue.FromString("009E39C2"),
                ParagraphProperties    = new DocumentFormat.OpenXml.Wordprocessing.ParagraphProperties
                {
                    SpacingBetweenLines = new SpacingBetweenLines
                    {
                        Before = StringValue.FromString("550"),
                        After  = StringValue.FromString("800")
                    },
                    Indentation = new Indentation
                    {
                        Left = StringValue.FromString("432")
                    }
                }
            });
            tableCell3.AppendChild(new Paragraph(new Run(new DocumentFormat.OpenXml.Wordprocessing.Text(data.TitleArea.Name))
            {
                RunProperties = new DocumentFormat.OpenXml.Wordprocessing.RunProperties
                {
                    Color = new Color {
                        Val = StringValue.FromString("FFFFFF")
                    },
                    FontSize = new FontSize {
                        Val = StringValue.FromString("33")
                    },
                    FontSizeComplexScript = new FontSizeComplexScript {
                        Val = StringValue.FromString("33")
                    }
                }
            })
            {
                ParagraphId            = HexBinaryValue.FromString("48E9D2B9"),
                TextId                 = HexBinaryValue.FromString("77777777"),
                RsidParagraphAddition  = HexBinaryValue.FromString("009B2C1D"),
                RsidRunAdditionDefault = HexBinaryValue.FromString("0007641E"),
                ParagraphProperties    = new DocumentFormat.OpenXml.Wordprocessing.ParagraphProperties
                {
                    SpacingBetweenLines = new SpacingBetweenLines
                    {
                        After = StringValue.FromString("0")
                    },
                    Indentation = new Indentation
                    {
                        Left = StringValue.FromString("432")
                    }
                }
            });
            tableCell3.AppendChild(new Paragraph(new Run(new DocumentFormat.OpenXml.Wordprocessing.Text(data.TitleArea.Date))
            {
                RunProperties = new DocumentFormat.OpenXml.Wordprocessing.RunProperties
                {
                    Color = new Color {
                        Val = StringValue.FromString("FFFFFF")
                    },
                    FontSize = new FontSize {
                        Val = StringValue.FromString("18")
                    },
                    FontSizeComplexScript = new FontSizeComplexScript {
                        Val = StringValue.FromString("18")
                    }
                }
            })
            {
                ParagraphId            = HexBinaryValue.FromString("4D45EC2E"),
                TextId                 = HexBinaryValue.FromString("77777777"),
                RsidParagraphAddition  = HexBinaryValue.FromString("009B2C1D"),
                RsidRunAdditionDefault = HexBinaryValue.FromString("009E39C2"),
                ParagraphProperties    = new DocumentFormat.OpenXml.Wordprocessing.ParagraphProperties
                {
                    SpacingBetweenLines = new SpacingBetweenLines
                    {
                        Before   = StringValue.FromString("800"),
                        After    = StringValue.FromString("550"),
                        Line     = StringValue.FromString("240"),
                        LineRule = new EnumValue <LineSpacingRuleValues> {
                            Value = LineSpacingRuleValues.Auto
                        }
                    },
                    Indentation = new Indentation
                    {
                        Left = StringValue.FromString("432")
                    }
                }
            });
            tableRow.AppendChild(tableCell3);

            table.AppendChild(tableRow);
        }
        /// <summary>
        /// The write table.
        /// </summary>
        /// <param name="t">The t.</param>
        public void WriteTable(Table t)
        {
            this.body.AppendChild(CreateParagraph(t.GetFullCaption(this.style), TableCaptionId));

            var table = new DocumentFormat.OpenXml.Wordprocessing.Table();

            var tableProperties1 = new TableProperties();
            var tableStyle1 = new TableStyle { Val = "TableGrid" };
            var tableWidth1 = new TableWidth { Width = "0", Type = TableWidthUnitValues.Auto };
            var tableLook1 = new TableLook
                {
                    Val = "04A0",
                    FirstRow = true,
                    LastRow = false,
                    FirstColumn = true,
                    LastColumn = false,
                    NoHorizontalBand = false,
                    NoVerticalBand = true
                };

            tableProperties1.AppendChild(tableStyle1);
            tableProperties1.AppendChild(tableWidth1);
            tableProperties1.AppendChild(tableLook1);

            var tableGrid1 = new TableGrid();
            // ReSharper disable once UnusedVariable
            foreach (var tc in t.Columns)
            {
                // TODO: use tc.Width to set the width of the column
                var gridColumn1 = new GridColumn { Width = "3070" };
                tableGrid1.AppendChild(gridColumn1);
            }

            foreach (var row in t.Rows)
            {
                var tr = new TableRow();

                if (row.IsHeader)
                {
                    var trp = new TableRowProperties();
                    var tableHeader1 = new TableHeader();
                    trp.AppendChild(tableHeader1);
                    tr.AppendChild(trp);
                }

                int j = 0;
                foreach (var c in row.Cells)
                {
                    bool isHeader = row.IsHeader || t.Columns[j++].IsHeader;
                    var cell = new TableCell();
                    var tcp = new TableCellProperties();
                    var borders = new TableCellBorders();
                    borders.AppendChild(
                        new BottomBorder
                            {
                                Val = BorderValues.Single,
                                Size = 4U,
                                Space = 0U,
                                Color = "auto"
                            });
                    borders.AppendChild(
                        new TopBorder
                            {
                                Val = BorderValues.Single,
                                Size = 4U,
                                Space = 0U,
                                Color = "auto"
                            });
                    borders.AppendChild(
                        new LeftBorder
                            {
                                Val = BorderValues.Single,
                                Size = 4U,
                                Space = 0U,
                                Color = "auto"
                            });
                    borders.AppendChild(
                        new RightBorder
                            {
                                Val = BorderValues.Single,
                                Size = 4U,
                                Space = 0U,
                                Color = "auto"
                            });
                    tcp.AppendChild(borders);

                    cell.AppendChild(tcp);
                    string styleId = isHeader ? "TableHeader" : "TableText";
                    cell.AppendChild(CreateParagraph(c.Content, styleId));
                    tr.AppendChild(cell);
                }

                table.AppendChild(tr);
            }

            this.body.AppendChild(table);
        }