Skip to content

Exported Word Document Content Issue with List (numbering) #2557

Open
@marievyyy

Description

@marievyyy

Describe the Bug

When exporting HTML content to a Word document using the PHPWord library, there is an issue with the formatting of lists. The numbering of lists is not displaying correctly, and it appears to be continuous instead of restarting the numbering lists or follow the correct list hierarchy.

Steps to Reproduce

What i have:

My code goes:
$template = new HTMLTemplateProcessor($documentdir.'mytemplate.docx');
// Read content HTML into placeholders
// sample $content value..
<p>&nbsp;Bug Report:</p>
<p><span style="background-color: #ff0000;">BugTracker X</span> is facing an issue when converting HTML content to a Word document. The problem lies in the formatting of lists. The numbering of lists appears to be continuous instead of restarting for nested lists.</p>
<ol>
<li>Items in the first level of the list
<ol>
<li>Sub-item 1</li>
</ol>
</li>
<li>&nbsp;Another item at the first level</li>
<li>Yet another item at the first level
<ol>
<li>Sub-item 1</li>
<li>Sub-item 2</li>
</ol>
<p><span style="background-color: #ff0000;">BugTracker X</span> is facing an issue when converting HTML content to a Word document. The problem lies in the formatting of lists. The numbering of lists appears to be continuous instead of restarting for nested lists.</p>

$template->setHtmlBlockValue('content', "<br/>".$content."<br/>");

Expected Behavior

I expect the HTML to Word document conversion to produce a properly formatted list with correct numbering, especially for nested lists. Each level of the list should have its own numbering, and the numbering should restart appropriately for sub-lists.
Screen Shot 2024-01-25 at 2 41 21 PM

Current Behavior

Screen Shot 2024-01-25 at 2 42 05 PM

Context

  • PHP Version: 8
  • PHPWord Version: 1.2.0 (latest)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions