Tables inside a bullet list result in a corrupt docx file
This is:
- [x] a bug report
- [ ] a feature request
- [ ] not a usage question (ask them on https://stackoverflow.com/questions/tagged/phpword)
Expected Behavior
Creating a table inside a bullet list is valid HTML and valid docx behaviour. In HTML it results in a bullet next to the table. In Word it results in an empty line with the bullet, then the table indented below.
Current Behavior
The XML created looks like it should work, but instead it creates a docx file that refuses to open as it is considered corrupt.
Failure Information
"Unspecified error. Location: Part: /word/document.xml, Line: 0, Column: 0"
How to Reproduce
Feed the following into PHPOffice:
<ul>
<li>I'm a bullet</li>
<li><table><tr><td>I'm a cell</td></tr></table></li>
<li>I'm a bullet</li>
</ul>
Context
- PHP version:
- PHPWord version: 0.14
I have exactly the same problem.
I am facing same issue only in Microsoft word, otherwise working fine with ubuntu editors like Liber office, WPS office, also document open in a Google doc.
Any solutions?
I also facing same issue when I parsed data from docx file to html then bullets table data does not added in html
Hi, I also encounter similar issue, table under ol li [table] ol li will produce this error :
Fatal error: Uncaught BadMethodCallException: Cannot add Table in ListItemRun. in [project-dir]/vendor/phpoffice/phpword/src/PhpWord/Element/AbstractContainer.php:273 Stack trace: #0 [project-dir]/vendor/phpoffice/phpword/src/PhpWord/Element/AbstractContainer.php(138): PhpOffice\PhpWord\Element\AbstractContainer->checkValidity('Table') #1 [internal function]: PhpOffice\PhpWord\Element\AbstractContainer->addElement('Table', Array) #2 [project-dir]/vendor/phpoffice/phpword/src/PhpWord/Element/AbstractContainer.php(119): call_user_func_array(Array, Array) #3 [project-dir]/vendor/phpoffice/phpword/src/PhpWord/Shared/Html.php(420): PhpOffice\PhpWord\Element\AbstractContainer->__call('addtable', Array) #4 [internal function]: PhpOffice\PhpWord\Shared\Html::parseTable(Object(DOMElement), Object(PhpOffice\PhpWord\Element\ListItemRun), Array) #5 [project-dir]/vendor/phpoffice/phpword/src/PhpWord/Shared/Html.php(258): call_user_func_array(Array, Array) #6 /usr/lo in [project-dir]/vendor/phpoffice/phpword/src/PhpWord/Element/AbstractContainer.php on line 273
@abydarts Hi, have you got a sample docx file with the expected result, please ?
@abydarts Hi, have you got a sample docx file with the expected result, please ?
Hi @Progi1984 , its not even give me any docx exported because php throw mentioned error even before giving the output docx, but if you want to know the sample html code that I want to export, here it is :
<h3 data-excluded-id="7,18">1.1 Heading Title</h3>
<h3>1.1.1 Title</h3>
<ol>
<li>List 1.</li>
<li>List 2:
<ol>
<li><br>
<table style="border-collapse: collapse; width: 100%; height: 67.5556px;" border="1">
<tbody>
<tr style="height: 16.8889px;">
<td style="width: 22.1701%; height: 16.8889px;"><strong>Col 1</strong></td>
<td style="width: 22.1701%; height: 16.8889px;"><strong>Col 2</strong></td>
<td style="width: 22.1701%; height: 16.8889px;"><strong>Col 3</strong></td>
<td style="width: 22.1701%; height: 16.8889px;"> </td>
</tr>
<tr style="height: 16.8889px;">
<td style="width: 22.1701%; height: 16.8889px;"> </td>
<td style="width: 22.1701%; height: 16.8889px;"> </td>
<td style="width: 22.1701%; height: 16.8889px;"> </td>
<td style="width: 22.1701%; height: 16.8889px;"> </td>
</tr>
<tr style="height: 16.8889px;">
<td style="width: 22.1701%; height: 16.8889px;"> </td>
<td style="width: 22.1701%; height: 16.8889px;"> </td>
<td style="width: 22.1701%; height: 16.8889px;"> </td>
<td style="width: 22.1701%; height: 16.8889px;"> </td>
</tr>
</tbody>
</table>
</li>
</ol>
</li>
<li>List 3.</li>
<li>List 4.</li>
<li>List 5 (Rule):
<ul>
<li>Sub List 1.</li>
<li>Sub List 2.</li>
<li>Sub List 3.</li>
<li>Sub List 4.</li>
</ul>
</li>
</ol>