Skip to Content
avatar image
Former Member

abap2xlsx - How to edit xlsx template from OAOR?

Hi experts, I would like know if is possible to read a template xlsx from OAOR and edit it with abap2xlsx in background mode.

I have need to change single cells and insert new rows into my template being careful not to damage the images.

Best Regards,

AI

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Nov 08, 2016 at 08:02 AM

    OAOR gives access to the documents in the Business Document Services (BDS). The API to get a document is the class CL_BDS_DOCUMENT_SET (can be called in background).

    abap2xlsx can be called in background too.

    Add comment
    10|10000 characters needed characters exceeded

    • DATA file_table TYPE filetable.
      DATA rc TYPE i.
      DATA user_action TYPE i.
      cl_gui_frontend_services=>file_open_dialog(
      CHANGING
      file_table = file_table
      rc = rc
      user_action = user_action
      EXCEPTIONS
      OTHERS = 1
      ).
      CHECK sy-subrc = 0.
      CHECK user_action = cl_gui_frontend_services=>action_ok.
      DATA data_tab TYPE TABLE OF x255.
      cl_gui_frontend_services=>gui_upload(
      EXPORTING
      filename = CONV #( file_table[ 1 ]-filename )
      filetype = 'BIN'
      IMPORTING
      filelength = DATA(filelength)
      CHANGING
      data_tab = data_tab
      EXCEPTIONS
      OTHERS = 1
      ).
      CHECK sy-subrc = 0.
      DATA(reader) = NEW zcl_excel_reader_2007( ).
      DATA(excel) = reader->zif_excel_reader~load( i_excel2007 = CONV #(
      substring( val = REDUCE string( INIT x TYPE xstring FOR <x> IN data_tab NEXT x = x && <x> )
      len = filelength * 2 ) ) ).