Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Upload EXCEL File with headers

0 Likes
1,775

Hi, I have an excel file with headers and an internal table. But order of the headers in the excel file is different from my internal table. What i wanna do is append them into corresponding columns. Any leads?

Hi, I have an excel file with headers and an internal table. But order of the headers in the excel file is different from my internal table. What i wanna do is append them into corresponding columns. Any leads?

5 REPLIES 5
Read only

abo
Active Contributor
1,653

abap2xlsx and then see demo ZDEMO_EXCEL37

Read only

0 Likes
1,653

Hello, what I want is read an excel file from my computer and output it to ALV.

Read only

abo
Active Contributor
0 Likes
1,653

and that is something that you can do with that package!

Read only

Sandra_Rossi
Active Contributor
1,653

c5e08e0478aa4727abc4482f5be390b2 I don't find a demo program just to show how simple it is to read, with minimal output of the result. I mean without using lcl_output=>output because beginners may not understand why it's so complex behind the scene. Maybe it could be a demo program added to abap2xlsx?

Example to read the first worksheet and display its contents (syntax errors, missing code needs to be completed):

PARAMETERS file TYPE string.
START-OF-SELECTION.
  DATA(file_contents) = VALUE solix_tab( ).
  cl_gui_frontend_services=>gui_upload( ... file_size ... file_contents ).
  DATA(xstring) = cl_bcs_convert=>solix_to_xstring( IT_SOLIX = file_contents IV_SIZE = file_size ).
  DATA(lo_reader) = NEW zcl_excel_reader_2007( ).
  DATA(lo_excel) = lo_reader->zif_excel_reader~load( i_excel2007 = xstring ).
  DATA(lo_worksheet) = lo_excel->get_worksheet_by_index( i ).
  LOOP AT lo_worksheet->sheet_content ASSIGNING FIELD-SYMBOL(<cell>).
    WRITE : / <cell>-cell_row, <cell>-cell_column, <cell>-cell_value.
  ENDLOOP.
Read only

abo
Active Contributor
1,653

The one I mentioned does show how to read a file, though it might not be the most concise example possible 🙂

I think we discussed restructuring the examples in a bug report or another but, yeah, this is worth adding perhaps.