Skip to Content
author's profile photo Former Member
Former Member

Urgent:download data in differnt tabs of excel sheet

Hi,

I want to save data from internal table to different worksheet of an excel sheet file without using ole. I am having thousands of record in my internal table. Currently I am doing this by using OLE but its response time is very high. Plz suggest any other method with which we can do it fast.

rely will be suitably rewarded

Edited by: amit manglik on Jan 28, 2008 10:23 AM

Edited by: amit manglik on Jan 29, 2008 10:18 AM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 09:21 AM

    hi,

    Refer sample code:

    Multiple excel sheets generation in a workbook

    CREATE OBJECT EXCEL 'EXCEL.SHEET'.

    GET PROPERTY OF EXCEL 'Application' = APPLICATION.

    SET PROPERTY OF APPLICATION 'Visible' = 1.

    CALL METHOD OF APPLICATION 'Workbooks' = BOOKS.

    CALL METHOD OF BOOKS 'Add' = BOOK.

    CALL METHOD OF BOOK 'WORKSHEETS' = SHEET.

    CALL METHOD OF SHEET 'ADD'.

    Fill all the sheets with relavant data

    PERFORM SHEET1 TABLES ITAB1.

    PERFORM SHEET2 TABLES ITAB2.

    PERFORM SHEET3 TABLES ITAB3.

    PERFORM SHEET4 TABLES ITAB4.

    Quit the excel after use

    CALL METHOD OF EXCEL 'QUIT'.

    FREE OBJECT: COLUMN,SHEET,BOOK,BOOKS,APPLICATION,EXCEL. "NO FLUSH.

    CLEAR V_SHEET.

    FORM FILL_CELL USING ROW COL VAL.

    CALL METHOD OF SHEET 'cells' = CELL NO FLUSH

    EXPORTING #1 = ROW #2 = COL.

    SET PROPERTY OF CELL 'value' = VAL.

    FREE OBJECT CELL NO FLUSH.

    ENDFORM. " FILL_CELL

    FORM SHEET1 TABLES ITAB1 STRUCTURE ITAB1.

    V_SHEET = Sheet Name.

    V_NO = V_NO + 1.

    CALL METHOD OF BOOK 'worksheets' = SHEET NO FLUSH EXPORTING #1 = V_NO.

    SET PROPERTY OF SHEET 'Name' = V_SHEET NO FLUSH.

    PERFORM FILL_SHEET1 TABLES ITAB1 USING V_NO V_SHEET.

    CALL METHOD OF SHEET 'Columns' = COLUMN.

    FREE OBJECT SHEET.

    CALL METHOD OF COLUMN 'Autofit'.

    FREE OBJECT COLUMN.

    ENDFORM.

    Repeat above procedure for all sheets you want to add

    FORM FILL_SHEET1

    TABLES ITAB1 STRUCTURE ITAB1

    USING V_NO V_SHEET.

    ROW = 1.

    PERFORM FILL_CELL USING ROW 1 'Column1 Name'.

    PERFORM FILL_CELL USING ROW 2 'Column2 Name'.

    PERFORM FILL_CELL USING ROW 3 'Column3 Name'.

    ROW = ROW + 1.

    LOOP AT ITAB1.

    PERFORM FILL_CELL USING ROW 1 ITAB1-Column1.

    PERFORM FILL_CELL USING ROW 2 ITAB1-Column2.

    PERFORM FILL_CELL USING ROW 3 ITAB1-Column3.

    ROW = ROW + 1.

    ENDLOOP.

    ENDFORM.

    Repeat above procedure for all sheets you want to add

    Also follow this link, for a simillar kind of download program.

    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c05db2ca-569e-2910-0784-fc06cc3be31d

    Hope this helps, Do reward.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.