-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Added extractVariables method to IOFactory #2515
Added extractVariables method to IOFactory #2515
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sibalonat Great improvement which improve the Developer Experience.
Could you fix my comments and update the changelog 2.0.0.md file, please ?
I would gladly do so @Progi1984. Thanks for the comments and ill let you know as soon as it's done. |
Fix PHPOffice#2526. Most of that issue has already been fixed. The one remaining problem was a deprecation message handling font size. The code used `dechex($operand / 2)`, and issued the deprecation message whenever `$operand` was odd because `dechex` is designed only for integer conversion. `$operand` is actually 2 times the point size, so it will be odd only when the point size is some integer plus half a point (no other fractions are allowed). At any rate, it seems that `dechex` should not be used here in the first place; font size is a numeric value, not a hex string. There are many problems with MsDoc Reader at the moment. This PR is narrowly focused on the problem at hand. Its test is, at least, more detailed than the existing MsDoc Reader test, which does nothing more than confirm that read successfully creates a PhpWord object. The new test verifies that the font size is as expected, but does not validate any other aspect of the read.
Bumps [dompdf/dompdf](https://github.com/dompdf/dompdf) from 2.0.3 to 2.0.4. - [Release notes](https://github.com/dompdf/dompdf/releases) - [Commits](dompdf/dompdf@v2.0.3...v2.0.4) --- updated-dependencies: - dependency-name: dompdf/dompdf dependency-type: direct:development ... Signed-off-by: dependabot[bot] <[email protected]>
Bumps [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) from 9.6.13 to 9.6.14. - [Changelog](https://github.com/sebastianbergmann/phpunit/blob/9.6.14/ChangeLog-9.6.md) - [Commits](sebastianbergmann/phpunit@9.6.13...9.6.14) --- updated-dependencies: - dependency-name: phpunit/phpunit dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]>
Bumps [mpdf/mpdf](https://github.com/mpdf/mpdf) from 8.2.0 to 8.2.2. - [Release notes](https://github.com/mpdf/mpdf/releases) - [Changelog](https://github.com/mpdf/mpdf/blob/development/CHANGELOG.md) - [Commits](mpdf/mpdf@v8.2.0...v8.2.2) --- updated-dependencies: - dependency-name: mpdf/mpdf dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some last feedbacks
Ill add them now, thanks again, much appreciated :) @Progi1984 |
Thanks @sibalonat for your contribution. |
Thank you very much to you sir :D |
Description
Overview
This pull request introduces a new method
extractVariables
to theIOFactory
class in PHPWord. The primary goal of this enhancement is to enable the extraction of variables from a Word document, particularly those that are linked to spreadsheet cell coordinates. This functionality lays the groundwork for more advanced integrations between Word documents and spreadsheets, allowing for dynamic data retrieval and manipulation.Technical Details
The
extractVariables
method scans a Word document and extracts all instances of variables following a specific pattern (e.g.,${variable}
). This is particularly useful in scenarios where these variables correspond to cell coordinates in a spreadsheet. By extracting these variables, we can programmatically search for corresponding values in linked spreadsheets, thereby automating the process of updating Word documents with dynamic data from spreadsheets.Use Cases
Implementation
The implementation involved modifying the
IOFactory
class to include theextractVariables
method. This method leverages existing structures within PHPWord to navigate through a document's sections and elements, identifying and aggregating variables.Tests
Appropriate unit tests have been added to ensure the functionality works as expected and to prevent future regressions. These tests cover a range of scenarios, including documents with a variety of variable patterns and formats.
Conclusion
This enhancement is a step towards deeper integration between Word documents and spreadsheets, unlocking new potentials in document automation and data-driven report generation. It aligns with PHPWord's goal of providing robust and flexible tools for word processing and document manipulation.
Fixes #2514
Checklist:
composer run-script check --timeout=0
and no errors were reported