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

Reg. Dowloading to EXCEL FILE..

Former Member
0 Likes
746

Hi.

The Excel file which gets dowloaded should be of the form.

Main Heading 1

SUB HEADING ( in the form of an INTERNAL TABLE )

Contents

Main Heading 2

SUB HEADING ( in the form of an INTERNAL TABLE )

Contents.

Let me know how effectively this can be done.

I have used the FM MS_EXCEL_OLE_STANDARD_DAT . But my exact requirement isn't served.

Thanks in advance.

Maheshwari.V

Hi.

The Excel file which gets dowloaded should be of the form.

Main Heading 1

SUB HEADING ( in the form of an INTERNAL TABLE )

Contents

Main Heading 2

SUB HEADING ( in the form of an INTERNAL TABLE )

Contents.

Let me know how effectively this can be done.

I have used the FM MS_EXCEL_OLE_STANDARD_DAT . But my exact requirement isn't served.

Thanks in advance.

Maheshwari.V

5 REPLIES 5
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
715

Have you tried using OLE yet?

/people/rich.heilman2/blog/2005/09/12/manipulate-excel-with-ole-abap

Regards,

Rich Heilman

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
715

Hi,

Check this link and kindly reward points by clicking the star on the left of reply,if it helps.

http://www.abap4.it/download/ZUSERMAIL.txt

Read only

athavanraja
Active Contributor
0 Likes
715

have six itabs

itab1 for main heading,

itab2 for subheading

itab3 data

itab4 main heading2

itab5 subheading2

itab6 contents 2

download one by one to the same file name.

using GUI_DOWNLOAD

first call with append = ' ' .

and next 5 calls with append = 'X'

this is a crude way, but if you want more fancier handling, you can go for OLE programming.

Regards

Raja

Read only

Former Member
0 Likes
715

Hi,

Hope finally u have entire data in one internal table.

Split the data into n tables according to criteria.

then Use GUI_DOWNLOAD

1) First time append = ' ' . "First heading

2) from the next time append = 'X'. "First internal table

again "Heading "Second ITAB

Thanks

Eswar

Read only

0 Likes
715

Here is an example of how you would create a new excel file and put data into.




report zrich_0002.

include ole2incl.

data: e_sheet type ole2_object.
data: e_appl  type ole2_object.
data: e_work  type ole2_object.
data: e_cell  type ole2_object.
data: e_wbooklist type ole2_object.

data: field_value(30) type c.

parameters: p_file type localfile default 'C:Test.xls'.

start-of-selection.


* Start the application
  create object e_appl 'EXCEL.APPLICATION'.
  set property of e_appl 'VISIBLE' = 0.

* Open the file
  call method of e_appl 'WORKBOOKS' = e_wbooklist.
  get property of e_wbooklist 'Application' = e_appl .
  set property of e_appl 'SheetsInNewWorkbook' = 1 .
  call method of e_wbooklist 'Add' = e_work .
  get property of e_appl 'ActiveSheet' = e_sheet .
  set property of e_sheet 'Name' = 'Test' .



* Write data to the excel file
* Here you are manipulating each cell one at a time.
* You can pretty much put the data anywhere you want.
* No restrictions.

  do 20 times.

* Create the value
    field_value  = sy-index.
    shift field_value left deleting leading space.
    concatenate 'Cell' field_value into field_value separated by space.


* Position to specific cell  in  Column 1
    call method of e_appl 'Cells' = e_cell
           exporting
                #1 = sy-index
                #2 = 1.
* Set the value
    set property of e_cell 'Value' = field_value .


* Position to specific cell  in  Column 2
    call method of e_appl 'Cells' = e_cell
           exporting
                #1 = sy-index
                #2 = 2.
* Set the value
    set property of e_cell 'Value' = field_value .


* Position to specific cell  in  Column 3
    call method of e_appl 'Cells' = e_cell
           exporting
                #1 = sy-index
                #2 = 3.
* Set the value
    set property of e_cell 'Value' = field_value .

  enddo.



** Close the file
  get property of e_appl 'ActiveWorkbook' = e_work.
  call method of e_work 'SAVEAS'
        exporting
            #1 = p_file
            #2 = 1.          " Don't ask me when closing

  call method of e_work 'close'.

* Quit the file
  call method of  e_appl  'QUIT'.

* Free them up
  free object e_cell.
  free object e_sheet.
  free object e_work.
  free object e_wbooklist.
  free object e_appl.

Regards,

Rich Heilman