Showing results for 
Search instead for 
Did you mean: 

ABAP2XLSX problem downloading file

Active Participant
0 Kudos

Hi, all.

I'm using ABAP2XLSX, i've created this simple test program.

The file is downloaded but when I open the file MS Excel is showing a message:
"We have encountered a problem with the content of "my_file.xlsx" . Do you want us to try to recover as much content as possible? If you trust the origin of this book, click Yes."

And then a message:
"Removed part: /xl/tables/table1.xml, part with error of XML. Line 1 column 202.

This is my code:


REPORT  ztest_abap2xlsx.

  BEGIN OF tys_table,
     field1 TYPE string,
     field2 TYPE string,
     field3 TYPE string,
     field4 TYPE string,
   END OF tys_table .
  tyt_table TYPE STANDARD TABLE OF tys_table.

 ls_table            TYPE tys_table,
 lt_table            TYPE tyt_table,
 ls_table_settings   TYPE zexcel_s_table_settings,
 lo_worksheet        TYPE REF TO zcl_excel_worksheet,
 lo_excel            TYPE REF TO zcl_excel.

ls_table-field1 'Expedient'.
ls_table-field2 '123123123'.
APPEND ls_table TO lt_tableCLEARls_table.
ls_table-field1 'Description'.
ls_table-field2 'My description'.
APPEND ls_table TO lt_tableCLEARls_table.
APPEND ls_table TO lt_tableCLEARls_table"Empty line
ls_table-field1 'VENDOR'.
APPEND ls_table TO lt_tableCLEARls_table.
ls_table-field1 'ID'.
APPEND ls_table TO lt_tableCLEARls_table.
ls_table-field1 'Type'.
ls_table-field2 'V'.
APPEND ls_table TO lt_tableCLEARls_table.

lo_worksheet lo_excel->get_active_worksheet).
lo_worksheet->set_titleip_title 'Vendor' ).

    ls_table_settings-top_left_column 2.
    ls_table_settings-top_left_row    2.
    CALL METHOD lo_worksheet->bind_table
        ip_table          lt_table
        is_table_settings ls_table_settings.
*          iv_no_header        = abap_true.
  CATCH zcx_excel.

    lv_filename         TYPE string,
    lv_folder           TYPE string,
    lv_xdata     TYPE xstring,
    lv_bytecount TYPE i,
    lt_raw_data  TYPE solix_tab,
    lo_writer    TYPE REF TO zif_excel_writer.

  CALL METHOD cl_gui_frontend_services=>directory_browse
*     window_title         =
*     initial_folder       =
      selected_folder      lv_folder
      cntl_error           1
      error_no_gui         2
      not_supported_by_gui 3
      OTHERS               4.
  IF sy-subrc <> OR lv_folder IS INITIAL.
    RAISE cancelar.

  CONCATENATE lv_folder '\' lv_filename '.xlsx' INTO lv_filename.

  CREATE OBJECT lo_writer TYPE zcl_excel_writer_2007.
  lv_xdata lo_writer->write_filelo_excel ).
  lt_raw_data cl_bcs_convert=>xstring_to_solixiv_xstring  lv_xdata ).
  lv_bytecount xstrlenlv_xdata ).

  cl_gui_frontend_services=>gui_downloadEXPORTING bin_filesize lv_bytecount
                                                    filename     lv_filename
                                                    filetype     'BIN'
                                           CHANGING data_tab     lt_raw_data ).




Any tip?

Active Contributor
0 Kudos
abap2xlsx is a little bit difficult to use. It may also due to bugs fixed if you're using an old version. You have demos provided which show how to use the various methods.
View Entire Topic
Active Contributor

You should file a bugreport on Github:

  • explain that you're manually backporting to an unsupported system (I might remember about this tomorrow but not sure about next week... and other devs might not be aware of this thread)
  • attach the source code
  • attach the generated XLSX

One of the devs might then generate a similar output on a supported system and then compare the results; be aware that the issue might not be solvable at all, if it comes down to the system being too old.

Oh... and please format the code with the "source code" tag 😄


Active Contributor

Bug reproduced in the latest version. BIND_TABLE doesn't handle a numeric column in TOP_LEFT_COLUMN. The right way to call is shown here:

Issue and PR welcome.

Active Contributor
0 Kudos