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 8609469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:53:12+00:00 2026-06-12T03:53:12+00:00

I am dynamically creating a msword document in PHP using PHPDocx (free version). I

  • 0

I am dynamically creating a msword document in PHP using PHPDocx (free version).

I am having trouble get a table to centre align in the page. I have tried passing in the style parameters as stated in the documentation, but no joy.

Any ideas on how to fix this?

My current code is;

$docx = new CreateDocx();

$valuesTable = array(
    array(
        11,
        12
    ),
    array(
        21,
        22
    ),
);

$paramsTable = array(
    'jc' => 'center',
    'border' => 'single',
    'border_sz' => 20
);

$docx->addTable($valuesTable, $paramsTable);

$docx->createDocx('example_table');
  • 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-12T03:53:14+00:00Added an answer on June 12, 2026 at 3:53 am

    I had the same problem. If you looking at CreateTable source you can see that method for aligning generateJC() is never called so passing a ‘jc’ parameter has no effect (this is the same with most of the options).

    You can override this creating a new class like:

    class SmCreateTable extends CreateTable{
        public function createTable()
        {
            $this->_xml = '';
            $args = func_get_args();
    
            if (is_array($args[0])) {
                $this->generateTBL();
                $this->generateTBLPR();
    
                if(!empty($args[1]['jc'])){
                    $this->generateJC($args[1]['jc']);
                }
    
                $this->generateTBLW();
                if (!empty($args[1]['border'])) {
                    $this->generateTBLBORDERS();
                    $this->generateTBLBOTTOM();
                    $this->generateTBLLEFT();
                    $this->generateTBLTOP();
                    $this->generateTBLRIGHT();
                    $this->generateTBLINSIDEH();
                    $this->generateTBLINSIDEV();
                }
    
                $this->generateTBLLOOK();
                $this->generateTBLOVERLAP();
                $intLine = 0;
                foreach ($args[0] as $datDepth) {
                    $this->generateTR();
                    $intLine++;
                    foreach ($datDepth as $cont) {
                        $this->generateTC();
                        $this->generateP();
                        $this->generateR();
                        if ($args[1]['font'] != '') {
                            $this->generateRPR();
                            $this->generateRFONTS($args[1]['font']);
                        }
                        $this->generateT($cont);
                    }
                    $this->cleanTemplateR();
                }
            }
        }
    
        private function cleanTemplateR()
        {
            $this->_xml = preg_replace('/__GENERATETR__/', '', $this->_xml);
        }
    }   
    

    and then calling:

    $table = new SmCreateTable();
    $table->createTable($valuesTable, $paramsTable);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a JSP page, where i am dynamically creating a Table data.
I am dynamically creating textboxes using document.createElement('input') and adding a break between them using
I am dynamically creating an HTML table by using a repeater. I have four
I am dynamically creating a table using JSON so i dont know in advance
i am dynamically creating radio using jquery as shown belown. but they value only
I'm dynamically creating option elements for a drop down menu using Javascript and would
I am dynamically creating a table that contains a textbox in each cell. The
I am dynamically creating combo boxes with PHP for a calendar: <?php $i=1; while($i
So I am dynamically creating an image and I wish to get the image
After dynamically creating a client-side table based on SELECT information retrieved from MySql database,

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.