Header/footer images and comments together create wrong file destinations in sheet#.xml.rels #1201
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.
Hello,
Try to add any comment in the second sheet of demo program ZTEST_EXCEL_IMAGE_HEADER and run it.
You will not succeed.
For comments the same index is used for the xl/comments.xml file and the xl/drawings/vmlDrawing.vml file.
This works as long as the comments are the only user of vml drawings.
But now there are header/footer images which also uses vml drawings.
In the example above however the first vml index is already used by first sheet's header/footer if the comment is created.
That means that the comment needs comments1.xml and vmlDrawing2.vml. This is not possible with current ABAP2XLSX.
And you cannot use comment2.xml leaving a gap, because comment files in [Content_Types].xml are counted from 1 without gaps.
The relationship between comment index and corresponding vml index must be separated.
We need one comment counter for xl/comments#.xml only and one vml counter
supplying vml index for comments and vml index for header/footer.
The following changes are to make in zcl_excel_writer_2007's methods create and create_xl_sheet_rels:
The new idea of calling method create_xl_sheet_rels is not to pass counters as currently but indices which are filled with
current counter values if needed or with initial value if not. The number of parameters to pass increases to four.
So you can use them in this method as a mark to create the respective relation or not without any need to call the according
get data method for empty check again.
I attach an excel file with the content to achieve:
Image_Header_Footer_with_comment.xlsx
Demo program ZTEST_EXCEL_IMAGE_HEADER with a minimum change for demonstration: