You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of the following would work, the first option being the one that makes the most sense:
Row is discarded when writing
The current Word2007 Table element write discards tables without rows, so it makes sense to also discard rows without cells while also ensuring that at least one row is written
Document is created with an implicit cell added (and required p block element)
This would create content in the document not expected
PHP Warning/Notice is raised for the missing cell.
No history of the library doing such a thing
Current Behavior
Document is created and cannot be opened in Word.
When opening and saving in LibreOffice the table is discarded in the saved file
A tr element has one formatting child element, trPr (§17.4.82), which defines the properties for the row. Each unique property on the table row is specified by a child element of this element. As well, a table row can contain any row-level content, which allows for the use of table cells.
If a table cell does not include at least one child element other than the row properties, then this document shall be considered corrupt.
Context
Please fill in your environment information:
PHP Version: 8.0-8.3
PHPWord Version: 1.1.0
The text was updated successfully, but these errors were encountered:
FixPHPOffice#2505. Word treats file as corrupt if a table row does not contain a cell (documentation for why this is so is included in the issue). Person reporting the issue suggests that dropping such a row from the output file is preferred. However, I think generating an empty cell instead is closer to the user's expectation. For example, as demonstrated in the unit tests added with this PR, if a table has row 1 and 3 which contain cells, but row 2 does not, the table as written to the file will have 3 rows, with the second containing an empty cell.
* Generate Table Cell if Row Doesn't Have Any
Fix#2505. Word treats file as corrupt if a table row does not contain a cell (documentation for why this is so is included in the issue). Person reporting the issue suggests that dropping such a row from the output file is preferred. However, I think generating an empty cell instead is closer to the user's expectation. For example, as demonstrated in the unit tests added with this PR, if a table has row 1 and 3 which contain cells, but row 2 does not, the table as written to the file will have 3 rows, with the second containing an empty cell.
* Remove Commented-Out Code in Tests
Describe the Bug
Creating a document that includes a table with a row without a cell causes Microsoft Word to consider the document corrupt
Steps to Reproduce
Please provide a code sample that reproduces the issue.
Expected Behavior
One of the following would work, the first option being the one that makes the most sense:
Current Behavior
Document is created and cannot be opened in Word.
When opening and saving in LibreOffice the table is discarded in the saved file
Table row XML created with only the trPr child
https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.tablerow?view=openxml-2.8.1 documents this as corrupt
Context
Please fill in your environment information:
The text was updated successfully, but these errors were encountered: