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

Generate Table Cell if Row Doesn't Have Any #2516

Merged
merged 4 commits into from
Aug 7, 2024

Conversation

oleibman
Copy link
Contributor

Description

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.

Checklist:

  • I have run composer run-script check --timeout=0 and no errors were reported
  • The new code is covered by unit tests (check build/coverage for coverage report)
  • I have updated the documentation to describe the changes

Fix PHPOffice#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.
@coveralls
Copy link

coveralls commented Nov 30, 2023

Coverage Status

coverage: 97.209% (+0.001%) from 97.208%
when pulling 054d0d0 on oleibman:word2505b
into 2daa50c on PHPOffice:master.

@Progi1984 Progi1984 added this to the 2.0.0 milestone Nov 30, 2023
@lucasnetau
Copy link

Hi @oleibman , tested locally and LGTM. Thank you.

Copy link
Member

@Progi1984 Progi1984 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oleibman Great job.

Added some comments.
Could you update the changelog file, too, please ?

@oleibman
Copy link
Contributor Author

oleibman commented Jan 7, 2024

@Progi1984 Change log updated, all your suggestions except one are incorporated; that one needs further discussion,

@Progi1984 Progi1984 merged commit 7084019 into PHPOffice:master Aug 7, 2024
12 of 13 checks passed
@Progi1984 Progi1984 deleted the word2505b branch August 7, 2024 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Adding a row to a table without a cell produces a corrupt docx for Word (works in LibreOffice)
4 participants