Skip to content

Using Table in string not showing properly and break file content #2354

@ahmedtoolapp

Description

@ahmedtoolapp

Describe the Bug

I can't create the table manually to PHPWord because users should be able to modify the content to export from the app, that's why I get the content and try to genrate a word file, when the string content contain table an cells , tables are not showing properly and even the file content is incomplet

A clear and concise description of what the bug is.
When content not containing table, my file is generated like a charm, but when table are there, my file is broken.
Also, when there is no tbody/thead tags : my table is here.
I found this :
Using table tag in HTML Reader produces no output
It is too old and I can't modify core code, but it seems that tbody/thead are not DOMElements.

Steps to Reproduce

Please provide a code sample that reproduces the issue.

<?php
require __DIR__ . '/vendor/autoload.php';

$html = """<html lang="fr"><body>....<table><thead><tr><th>....</th></tr></thead><tbody><tr><td>....</td></td></tbody></table>....</body></html>""" // dont work
$html = """<html lang="fr"><body>....<table><tr><td>....</td></tr><tr><td>....</td></tr></table>.....</body></html>""" // work
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$section = $phpWord->addSection();
Html::addHtml($section, $html, true);
$objWriter = IOFactoryWord::createWriter($word);
$path = my/path;
$objWriter->save($path)

Expected Behavior

A clear and concise description of what you expected to happen.
Word file with complete content and inline designed tables.

Current Behavio

What is the current behavior?
Breaked file and tables

Context

Please fill in your environment information:

  • PHP Version: 7.4
  • PHPWord Version: 0.18.3 upgrated to 1.0.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions