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

Writer ODS : Writer Border Style for cells #3693

Merged
merged 3 commits into from
Sep 14, 2023

Conversation

Progi1984
Copy link
Member

@Progi1984 Progi1984 commented Aug 29, 2023

This is:

  • a bugfix
  • a new feature
  • refactoring
  • additional unit tests

Checklist:

  • Changes are covered by unit tests
    • Changes are covered by existing unit tests
    • New unit tests have been added
  • Code style is respected
  • Commit message explains why the change is made (see https://github.com/erlang/otp/wiki/Writing-good-commit-messages)
  • CHANGELOG.md contains a short summary of the change and a link to the pull request if applicable
  • Documentation is updated as necessary

Why this change is needed?

Fixes #3690

@Progi1984 Progi1984 force-pushed the issue3690 branch 4 times, most recently from 1c1f029 to e517afe Compare August 29, 2023 19:49
@Progi1984 Progi1984 marked this pull request as ready for review August 29, 2023 19:53
@Progi1984 Progi1984 requested a review from a team August 29, 2023 19:56
@oleibman
Copy link
Collaborator

@Progi1984 It's late here. I will try to start reviewing tomorrow. In the meantime, can you add some tests to demonstrate that your change works as expected?

Copy link
Member

@PowerKiKi PowerKiKi left a comment

Choose a reason for hiding this comment

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

See comments, and should add tests as mentioned by @oleibman

src/PhpSpreadsheet/Writer/Ods/Cell/Style.php Outdated Show resolved Hide resolved
src/PhpSpreadsheet/Writer/Ods/Cell/Style.php Outdated Show resolved Hide resolved
@Progi1984
Copy link
Member Author

@Progi1984 It's late here. I will try to start reviewing tomorrow. In the meantime, can you add some tests to demonstrate that your change works as expected?

@oleibman Can i add XML Tester like in PHPWord unit tests : for example, https://github.com/PHPOffice/PHPWord/blob/master/tests/PhpWordTests/Writer/Word2007/ElementTest.php#L109 ?

@oleibman
Copy link
Collaborator

@Progi1984 Take a look at tests/PhpSpreadsheet/Writer/Ods/ContentTest. It puts the generated Xml in a string via:

$content = new Content(new Ods($workbook));

I'm not sure offhand if the results of your change will go into the xml file content.xml (in which case the code above will do) or styles.xml (in which case you'll have to tweak it a bit).

@Progi1984 Progi1984 force-pushed the issue3690 branch 3 times, most recently from e65bdd0 to 16144f8 Compare September 7, 2023 15:31
@oleibman
Copy link
Collaborator

oleibman commented Sep 7, 2023

@Progi1984 I agree that your test confirms that your change is working, but ... it seems unmaintainable (e.g. the unnecessary number-columns-repeated in the xml seem like a bug, and, if we fix that, your test breaks) and opaque. It is just not clear why that xml demonstrates the correctness of the change. I will let @PowerKiKi weigh in on this - if it's okay with him, it's okay with me. But, if not, what I had in mind was for you to load the xml string as a DomDocument, and then query the DomDocument (possibly using normal Dom methods or xpath) to confirm the following:

  • the first row first cell is linked to a style which sets the left and top borders to the expected color and thickness, and does not specify a bottom or right border
  • the first row second cell ... sets right and top, does not set bottom or left
  • second row first cell ... sets left and bottom, does not set top or right
  • second row second cell ... sets right and bottom, does not set left or top

Does that sound like a test you can set up? Some tests in PhpWord Writer/Html (e.g. ElementTest) use this technique.

@Progi1984
Copy link
Member Author

@oleibman No soucis. I work on it.

@oleibman
Copy link
Collaborator

@Progi1984 Your new test looks good (and has definitely expanded my horizons on how to use xpath). I will try to merge this over the next day or two.

@Progi1984
Copy link
Member Author

Progi1984 commented Sep 14, 2023

@oleibman I rebase the PR ;)

@Progi1984 Progi1984 requested a review from oleibman September 14, 2023 08:37
@oleibman oleibman merged commit f085c85 into PHPOffice:master Sep 14, 2023
@oleibman
Copy link
Collaborator

Thank you for your contribution.

@Progi1984 Progi1984 deleted the issue3690 branch September 14, 2023 13:30
@Progi1984
Copy link
Member Author

@oleibman It's not the first contribution. I've been contributing since 2011.

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.

Border doesn't work in ods
3 participants