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

Corrupted XLSX with BIND_TABLE and numeric column in TOP_LEFT_COLUMN #1215

Open
sandraros opened this issue Apr 27, 2024 · 0 comments
Open

Comments

@sandraros
Copy link
Collaborator

sandraros commented Apr 27, 2024

Source: https://community.sap.com/t5/technology-q-a/abap2xlsx-problem-downloading-file/qaq-p/13681256

Program to reproduce the bug:

REPORT.
DATA gc_save_file_name TYPE string VALUE 'abap_issue_1215.xlsx'.
INCLUDE zdemo_excel_outputopt_incl.
START-OF-SELECTION.
  DATA(lo_excel) = NEW zcl_excel( ).
  DATA(lo_worksheet) = lo_excel->get_active_worksheet( ).
  SELECT msehi, msehl
      FROM t006a
      WHERE spras = 'E'
        AND msehi LIKE 'T%'
      INTO TABLE @DATA(t006_lines).
  lo_worksheet->bind_table(
      ip_table            = t006_lines
      is_table_settings   = VALUE #( top_left_column = 1 
                                     top_left_row    = 1 ) ).
  lcl_output=>output( lo_excel ).

image

Solution:

  • Workaround: the right way to call bind_table is to use the alphabetical column name instead of the number:
    lo_worksheet->bind_table(
        ip_table            = t006_lines
        is_table_settings   = VALUE #( top_left_column = 'A'
                                       top_left_row    = 1 ) ).
    
  • Do a fix: I would recommend to accept a number in the parameter TOP_LEFT_COLUMN and write its equivalent alphabetical name to the XLSX file instead of a number.
    Note that the parameter BOTTOM_RIGHT_COLUMN is not concerned because it's always ignored, as the bottom right position is calculated by the method calculate_table_bottom_right.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant