title: Open XML (Microsoft Word): C# Table Justification
body: <p><br>
  How would I align my table in the middle of the word document in open xml?<br>
  Here is my code and I want to align the table in the middle. </p>
  
  <p>Here is my code. I'm trying to use TableJustification, but it seems like its not working</p>
  
  <pre><code>using (WordprocessingDocument wordDoc = WordprocessingDocument.Create(filepath, WordprocessingDocumentType.Document))
              {
                  MainDocumentPart mainPart = wordDoc.AddMainDocumentPart();
                  mainPart.Document = new Document();
                  Body body = mainPart.Document.AppendChild(new Body());
  
                  Run run = new Run();
                  // Goes through all of the forms
                  foreach (var form in forms)
                  {
  
                      Table table = new Table();
                      // Initialize all of the table properties
                      TableProperties tblProp = new TableProperties(
                          new TableBorders(
                              new TopBorder() { Val = new EnumValue&lt;BorderValues&gt;(BorderValues.BasicBlackSquares), Size = 16 },
                              new LeftBorder() { Val = new EnumValue&lt;BorderValues&gt;(BorderValues.BasicBlackSquares), Size = 16 },
                              new RightBorder() { Val = new EnumValue&lt;BorderValues&gt;(BorderValues.BasicBlackSquares), Size = 16 },
                              new BottomBorder() { Val = new EnumValue&lt;BorderValues&gt;(BorderValues.BasicBlackSquares), Size = 16 }
                          )
  
                      );
  
                      // Align the table to the center
                      TableJustification justs_center = new TableJustification() { Val = _____  };
  
                      table.AppendChild(justs_center);
                      table.AppendChild&lt;TableProperties&gt;(tblProp);
  
                      Paragraph para = body.AppendChild(new Paragraph());
                      Run run_header = para.AppendChild(new Run());
                      RunProperties runProps = run_header.AppendChild(new RunProperties(new Bold()));
  
  
                      string username = form.Username;
                      string proces_header = form.HeaderTitle;
  
                      run_header.AppendChild(new Text(proces_header + " | " + username));
  
                      for (int i = 0; i &lt; form.FieldList.Count; i++)
                      {
                          if (!(form.FieldList[i].Token == "USR" || form.FieldList[i].Token == "SNT"))
                          {
                              TableRow tr = new TableRow();
  
                              TableCell header_cell = new TableCell();
  
                              header_cell.Append(new Paragraph(new Run(new Text(form.FieldList[i].Label + ": " + form.FieldList[i].Value))));
  
                              tr.Append(header_cell);
                              table.Append(tr);
                          }
                      }
                      wordDoc.MainDocumentPart.Document.Body.Append(table);
  
                  }
  
                  mainPart.Document.Save();
                  wordDoc.Close();
                  return "Success";
              }
          }
  </code></pre>