Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with table width & table border is not showing in microsoft office word #2687

Open
anandmainali5 opened this issue Sep 25, 2024 · 1 comment

Comments

@anandmainali5
Copy link

Describe the bug and add attachments

I have this code and it generates the below docx. but when opening in microsoft office table width is not 100% & table border is not showing at all.

Example.docx

When opening with office word:
Screenshot 2024-09-25 at 2 02 11 PM

Expected behavior

The table should render in full width and with proper table border.

Steps to reproduce

$section = $phpWord->addSection();
$header  = ['size' => 16, 'bold' => true];

$section->addText('addHtml with theader AND tbody', $header);

//HTML content generated from editor
$table = '
        <table>
          <thead>
            <tr>
              <th>First name</th>
              <th>Last name</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>John</td>
              <td>Doe</td>
            </tr>
            <tr>
              <td>Jane</td>
              <td>Doe</td>
            </tr>
          </tbody>
        </table>';

\PhpOffice\PhpWord\Shared\Html::addHtml($section, $table, true);

$path = 'table.docx';
$phpWord->save($path);

### PHPWord version(s) where the bug happened

1.3

### PHP version(s) where the bug happened

8.1

### Priority

- [ ] I want to crowdfund the bug fix (with [@algora-io](https://docs.algora.io/bounties/overview)) and fund a community developer.
- [ ] I want to pay the bug fix and fund a maintainer for that. (Contact @Progi1984)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants
@anandmainali5 and others