Fix Anchor Column and Row Positioning by Adjusting Scaling for Excel Defaults #2924
+129
−152
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…faults
Previously colWidth and rowHeight assumed a simplistic scaling factor, causing incorrect image and object positioning when custom widths/heights were set.
This update uses accurate scaling:
This pull request includes several changes aimed at improving code readability and accuracy in calculations, as well as adding a new test for image positioning with custom column widths. The most important changes include refactoring calculation logic in the
Anchor
class, simplifying test assertions, and introducing a new integration test for image positioning.Codebase Improvements
Refactored calculation logic in
Anchor
class: Updated column width and row height calculations to use more precise scaling factors for better accuracy. (lib/doc/anchor.js
: [1] [2] [3]Simplified test assertions: Replaced multiline assertions with single-line equivalents for better readability in the test suite. (
spec/integration/workbook-xlsx-reader.spec.js
: [1] [2] [3]Testing Enhancements
New integration test for image positioning: Added a test to verify that images are positioned correctly when custom column widths are set. (
spec/integration/workbook/images.spec.js
: spec/integration/workbook/images.spec.jsR292-R338)Updated unit tests for
Anchor
class: Adjusted tests to reflect the new scaling factors in column width and row height calculations. (spec/unit/doc/anchor.spec.js
: [1] [2] [3]These changes collectively improve the maintainability and accuracy of the codebase while enhancing test coverage.
Improves placement precision for images and anchored objects.
Summary
Test plan
Related to source code (for typings update)