Application Development 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: 

Import data from ABAP program to Excell template file

Former Member
0 Kudos
114

Hello everyone

I have a such task: In abap program I have fields(screen fields), which I want to import into excell file. I don't want to export into empty file but into ready template .xls. Is there any possibility to match corresponding fields?

I really need to know, I will be gratefully for any suggestions.

Greetings

5 REPLIES 5

Clemenss
Active Contributor
0 Kudos
65

Hi Katarzyna ,

something like


DATA: EXCEL TYPE OLE2_OBJECT.
DATA: BOOKS TYPE OLE2_OBJECT.
DATA: BOOK  TYPE OLE2_OBJECT.
DATA: CELL  TYPE OLE2_OBJECT.
DATA: FONT  TYPE OLE2_OBJECT.
DATA: FILE  TYPE OLE2_OBJECT.

  CREATE OBJECT EXCEL 'EXCEL.APPLICATION'.

  CALL METHOD OF EXCEL 'WORKBOOKS' = FILE.

  CALL METHOD OF  FILE 'OPEN' EXPORTING #1 = P_FILE
                                        #2 = 1.   

  CALL METHOD OF EXCEL 'CELLS' = CELL EXPORTING #1 = P_LINE
                                                #2 = P_COLUMN.
  SET PROPERTY OF CELL 'VALUE' = P_VALUE.


  CALL METHOD OF EXCEL 'QUIT'.
 

This is just a compilation from a complex program. Do some modularization (i.e. create FORM fill_cell using P_line P_column P_value...)

Hope I did not forget anything. Meanwhile we have much more modern and advanced methods and classes - this one is of 2000 (Release 4.5?).

Regards,

Clemens

Former Member
0 Kudos
65

Hello Clemens

Thank you very much, I will try your solution.

Greetings

Former Member
0 Kudos
65

Hello Clemens

I have one more question. In that form fill_cell the arguments p_line and p_column are:

For example:

An excel cell A6 - p_line 6 , p_column A. Which is: the cell' s address where I want export p_value is p_column,p_line?

Could you explain it for me please. I'm totally beginner.

Former Member
0 Kudos
65

And another question: what if I don't have a cell with address, but I have text field which contains 3 cells? Then, how looks the method 'CELLS'? Please, could you show me.

Former Member
0 Kudos
65

OK it's all right. Now I know answers for my all questions and everything works great.

Thank you.

Greetings