Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8960663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:42:35+00:00 2026-06-15T15:42:35+00:00

How would I align my table in the middle of the word document in

  • 0

How would I align my table in the middle of the word document in open xml?
Here is my code and I want to align the table in the middle.

Here is my code. I’m trying to use TableJustification, but it seems like its not working

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<BorderValues>(BorderValues.BasicBlackSquares), Size = 16 },
                            new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.BasicBlackSquares), Size = 16 },
                            new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.BasicBlackSquares), Size = 16 },
                            new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.BasicBlackSquares), Size = 16 }
                        )

                    );

                    // Align the table to the center
                    TableJustification justs_center = new TableJustification() { Val = _____  };

                    table.AppendChild(justs_center);
                    table.AppendChild<TableProperties>(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 < 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";
            }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:42:36+00:00Added an answer on June 15, 2026 at 3:42 pm
    Table t = new Table(
        new TableProperties(
            ...
            new TableJustification() { Val =  TableRowAlignmentValues.Center},
            ...),
        new TableRow(...),
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to Vertically Align a Table in CSS I would like to
Here's the .jsp code: <table> <s:iterator value=allAgents> <tr> <td><s:property value=firstName /></td> <td><s:property value=middleName /></td>
I would like to left-align a table with CSS, in a way similar to
I would expect this code to display a border around a table. It does
I'm trying to use a table to display some images, I'm allowed 3 images
I just want to put the table in the middle of the page. Any
I have a table column like this, where I want to align an image
I have this table in some code; <table> <tr><td align=left>One</td><td align=center>Two</td><td align=right>Three</td> <tr><td align=left>One</td><td
Learning Jquery here and I would like to show my SQL table on my
I'm trying to create a table. And I would like to know how to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.