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

Header/footer images and comments together make corrupted Excel file #1214

Closed
sandraros opened this issue Apr 20, 2024 · 1 comment
Closed

Comments

@sandraros
Copy link
Collaborator

(created after PR #1201)

Minimal reproducible example:

REPORT.

DATA: lo_excel     TYPE REF TO zcl_excel,
      lo_worksheet TYPE REF TO zcl_excel_worksheet,
      lo_drawing   TYPE REF TO zcl_excel_drawing,
      ls_key       TYPE wwwdatatab,
      ls_header    TYPE zexcel_s_worksheet_head_foot.
  DATA lo_comment TYPE REF TO zcl_excel_comment.

CONSTANTS: gc_save_file_name TYPE string VALUE 'abap2xlsx_issue_PR_1201.xlsx'.
INCLUDE zdemo_excel_outputopt_incl.

START-OF-SELECTION.

  CREATE OBJECT lo_excel.
  lo_worksheet = lo_excel->get_active_worksheet( ).

* Comment
  lo_comment = lo_excel->add_new_comment( ).
  lo_comment->set_text( ip_ref = 'B3' ip_text = 'Just a comment' ).
  lo_worksheet->add_comment( lo_comment ).

* Header
  lo_drawing = lo_excel->add_new_drawing( ip_type = zcl_excel_drawing=>type_image_header_footer ).
  ls_key-relid = 'MI'.
  ls_key-objid = 'SAPLOGO.GIF'.
  lo_drawing->set_media_www( ip_key = ls_key
                             ip_width = 166
                             ip_height = 75 ).
  ls_header-left_image = lo_drawing.
  lo_worksheet->sheet_setup->set_header_footer( ip_odd_header = ls_header ).

  lcl_output=>output( lo_excel ).

image

The corrupted part comes from the file xl\worksheets\_rels\sheet1.xml.rels inside the zipped XLSX file:

<?xml version="1.0"  standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing"
    Target="../drawings/vmlDrawing2.vml"/>
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments" 
    Target="../comments2.xml"/>
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing" 
    Target="../drawings/vmlDrawing3.vml"/>
</Relationships>

whose Target file names (vmlDrawing2/3 and comments2) don't match the actual ones inside the zipped XLSX file (vmlDrawing1/2 and comments1):

▮ _rels
▮ docProps
▮ xl
  ▮ _rels
  ▮ drawings
    ▮→ _rels
    vmlDrawing1.vml
    vmlDrawing2.vml
  ▮ media
  ▮ theme
  ▮ worksheets
  comments1.xml
  sharedStrings.xml
  styles.xml
  workbook.xml
@sandraros
Copy link
Collaborator Author

NB: after the fix, we can see how the fix has changed the file xl\worksheets\_rels\sheet1.xml.rels:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant