Repository navigation
fix: read self-closing a:prstGeom in drawing shape properties - #428
Open
jayhemnani9910 wants to merge 2 commits into
Open
jayhemnani9910 wants to merge 2 commits into
jayhemnani9910 wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
openpyxl writes a picture's geometry as a self-closing element,
<a:prstGeom prst="rect" />(ws.add_image).ShapeProperties::set_attributeshandlesa:prstGeomonly in theEvent::Startarm. The self-closing form arrives asEvent::Empty, soprststays empty and is written back as<a:prstGeom prst=""><a:avLst/></a:prstGeom>. openpyxl then refuses to open the saved file:So reading and saving an openpyxl or pandas report that has a logo or other picture produces a file Python can no longer read. Excel writes the element with an explicit end tag and isn't affected.
The
Event::Emptyarm now also readsprstfrom a self-closinga:prstGeom, next to the existinga:noFillcase.Testing: added
tests/self_closing_preset_geometry.rswith a small openpyxl-made workbook (tests/test_files/openpyxl_image.xlsx). It reads and writes the file and checks that the drawing keepsprst="rect". It fails on master and passes with the change.cargo testpasses (413). Read and wrote the openpyxl file with the change, and openpyxl 3.1.5 loads the result.