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

Fix for #2149 / Read data validations for drop down list in another sheet. #2150

Merged
merged 9 commits into from
Jun 15, 2021

Conversation

otargetj2s
Copy link
Contributor

@otargetj2s otargetj2s commented Jun 9, 2021

This is:

- [x] a bugfix
- [ ] a new feature

Checklist:

Why this change is needed?

This modification makes it possible to read the drop-down lists linked to other sheets.
See issue #2149

@otargetj2s otargetj2s changed the title Read data validations for drop down list in another sheet. Fix #2149 / Read data validations for drop down list in another sheet. Jun 9, 2021
@otargetj2s otargetj2s changed the title Fix #2149 / Read data validations for drop down list in another sheet. Fix for #2149 / Read data validations for drop down list in another sheet. Jun 9, 2021
@oleibman
Copy link
Collaborator

oleibman commented Jun 9, 2021

Without actually commenting on the substance of your change, it appears that your commit merely adds a block of commented out code. Did you mean to remove the comment marks?
Also, is it possible to write a unit test which will show that your change operates as desired?

@otargetj2s otargetj2s force-pushed the fix/externalDataValidations branch from 498495a to bcb0ffa Compare June 9, 2021 15:17
@otargetj2s
Copy link
Contributor Author

Without actually commenting on the substance of your change, it appears that your commit merely adds a block of commented out code. Did you mean to remove the comment marks?
Also, is it possible to write a unit test which will show that your change operates as desired?

Sorry, i uncommented the code block. It was for test purpose.
I never wrote any unit tests for PHP but i would be thankful to anyone to do it.

@otargetj2s
Copy link
Contributor Author

Without actually commenting on the substance of your change, it appears that your commit merely adds a block of commented out code. Did you mean to remove the comment marks?
Also, is it possible to write a unit test which will show that your change operates as desired?

Sorry, i uncommented the code block. It was for test purpose.
I never wrote any unit tests for PHP but i would be thankful to anyone to do it.

Finally, i have created the unit test and validated it successfully.

@otargetj2s
Copy link
Contributor Author

I finished. I don't make any more changes.

@MarkBaker
Copy link
Member

I've added some more assertions to verify that the list address is correctly loaded with the worksheet name, and resolved the phpstan issue

@MarkBaker MarkBaker merged commit 803737a into PHPOffice:master Jun 15, 2021
@MarkBaker
Copy link
Member

Thank you for this contribution: it may be reworked a bit as we work with the handling of namespaces in Xlsx files

@otargetj2s
Copy link
Contributor Author

Thank you for this contribution: it may be reworked a bit as we work with the handling of namespaces in Xlsx files

I'm happy to have been able to contribute to this project.
Thank you also to you.

oleibman added a commit to oleibman/PhpSpreadsheet that referenced this pull request Aug 10, 2021
See issues PHPOffice#1432 and PHPOffice#2149. Data validations on an Xlsx worksheet can be specified in two manners - one (henceforth "internal") if a list is specified from the same sheet, and a different one (henceforth "external") if a list is specified from a different sheet. Xlsx worksheet reader formerly processed only the internal format; PR PHPOffice#2150 fixed this so that both would be processed correctly on read. However, Xlsx worksheet writer outputs data validators only in the internal format, and that does not work for external data validations; it appears, however, that internal data validations can be specified in external format.

This PR changes Xlsx worksheet writer to use only the external format. Somewhat surprisingly, this must come after most of the other XML tags that constitute a worksheet. It shares this characteristic (and XML tag) with conditional formatting. The new test case DataValidator2Test includes a worksheet which has both internal and external data validation, as well as conditional formatting.

There is some additional namespacing work supporting Data Validations that needs to happen on Xlsx reader. Since that is substantially unchanged with this PR, that work will happen in a future namespacing phase, probably phase 2. However, there are some non-namespace-related changes to Xlsx reader in this PR:
- Cell DataValidation adds support for a new property sqref, which is initialized through Xlsx reader using a setSqref method. If not initialized at write time, the code will work as it did before the introduction of this property. In particular, before this change, data validation applied to an entire column (as in the sample spreadsheet) would be applied only through the last populated row. In addition, this also allows a user to extend a Data Validation over a range of cells rather than just a single cell; the new method is added to the documentation.
- The topLeft property had formerly been used only for worksheets which use "freeze panes". However, as luck would have it, the sample dataset provided to demonstrate the Data Validations problem uses topLeft without freeze panes, slightly affecting the view when the spreadsheet is initially opened; PhpSpreadsheet will now do so as well.

It is worth noting issue PHPOffice#2262, which documents a problem with the hasValidValue method involving the calculation engine. That problem existed before this PR, and I do not yet have a handle on how it might be fixed.
oleibman added a commit that referenced this pull request Aug 24, 2021
See issues #1432 and #2149. Data validations on an Xlsx worksheet can be specified in two manners - one (henceforth "internal") if a list is specified from the same sheet, and a different one (henceforth "external") if a list is specified from a different sheet. Xlsx worksheet reader formerly processed only the internal format; PR #2150 fixed this so that both would be processed correctly on read. However, Xlsx worksheet writer outputs data validators only in the internal format, and that does not work for external data validations; it appears, however, that internal data validations can be specified in external format.

This PR changes Xlsx worksheet writer to use only the external format. Somewhat surprisingly, this must come after most of the other XML tags that constitute a worksheet. It shares this characteristic (and XML tag) with conditional formatting. The new test case DataValidator2Test includes a worksheet which has both internal and external data validation, as well as conditional formatting.

There is some additional namespacing work supporting Data Validations that needs to happen on Xlsx reader. Since that is substantially unchanged with this PR, that work will happen in a future namespacing phase, probably phase 2. However, there are some non-namespace-related changes to Xlsx reader in this PR:
- Cell DataValidation adds support for a new property sqref, which is initialized through Xlsx reader using a setSqref method. If not initialized at write time, the code will work as it did before the introduction of this property. In particular, before this change, data validation applied to an entire column (as in the sample spreadsheet) would be applied only through the last populated row. In addition, this also allows a user to extend a Data Validation over a range of cells rather than just a single cell; the new method is added to the documentation.
- The topLeft property had formerly been used only for worksheets which use "freeze panes". However, as luck would have it, the sample dataset provided to demonstrate the Data Validations problem uses topLeft without freeze panes, slightly affecting the view when the spreadsheet is initially opened; PhpSpreadsheet will now do so as well.

It is worth noting issue #2262, which documents a problem with the hasValidValue method involving the calculation engine. That problem existed before this PR, and I do not yet have a handle on how it might be fixed.
@poojithamiryala
Copy link

When can we expect this fix to be released?

@otargetj2s
Copy link
Contributor Author

otargetj2s commented Sep 7, 2021 via email

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.

4 participants