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: 

how to dowload data in particular cell of designed excel sheet

Former Member
0 Kudos

hi everyone

i want to dowload the data in a excel sheet, but this excel sheet is designed in such a format that i have download each field of internal table in a specified cell only , <b>gui_download</b> function module simply download the data in excel sheet by taking the first cell for first field but i dont want that

3 REPLIES 3

former_member181962
Active Contributor
0 Kudos

HI Neetu,

In that case,

you can change the internal table structure itself in such a way that the fields go into corresponding columns.

Regards,

Ravi

Former Member
0 Kudos

Hi,

Take a look at this weblog

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

/people/sap.user72/blog/2006/02/07/downloading-data-into-excel-with-format-options

Regards,

Ravi

former_member188685
Active Contributor
0 Kudos

Hi Neetu,

you can use OLE in that case.

REPORT  ZTEST_EXCEL             .

INCLUDE ole2incl.

DATA: application TYPE ole2_object,
       workbook TYPE ole2_object,
       sheet TYPE ole2_object,
       cells TYPE ole2_object.

CONSTANTS: row_max TYPE i VALUE 256.
DATA index TYPE i.


DATA: BEGIN OF itab1 OCCURS 0,
 first_name(10),
 last_name(10),
 END OF itab1.

START-OF-SELECTION.
 itab1-first_name = '123445'.
 itab1-last_name = 'tesst'.
 append itab1.
 clear itab1.

 

 itab1-first_name = '123446'.
 itab1-last_name = 'tesst'.
 append itab1.
 clear itab1.

 

  CREATE OBJECT application 'excel.application'.
  SET PROPERTY OF application 'visible' = 1.
  CALL METHOD OF application 'Workbooks' = workbook.
  CALL METHOD OF workbook 'Add'.

 

* Create first Excel Sheet

  CALL METHOD OF application 'Worksheets' = sheet
                               EXPORTING #1 = 1.

  CALL METHOD OF sheet 'Activate'.
  SET PROPERTY OF sheet 'Name' = 'Sheet1'.

  LOOP AT itab1.
    index = row_max * ( sy-tabix - 1 ) + 1. " 1 - column name
    CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.
    SET PROPERTY OF cells 'Value' = itab1-first_name.
        index = index + 1. " 1 - column name
    CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.
    SET PROPERTY OF cells 'Value' = itab1-last_name.
  ENDLOOP.
* Save excel speadsheet to particular filename
  CALL METHOD OF sheet 'SaveAs'
                 EXPORTING #1 = 'c:tempexceldoc1.xls'     "filename
                            #2 = 1.                          "fileFormat

Regards

vijay