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

Download to excel file with multiple worksheets/tabs

Hello All,

I'm having a difficulting looking for a function module that can download an excel file with multiple worksheets.

For example, I need to retrieve from table TCURR the exchange rate for the day. Moreover, a separate sheet needs to be created or each base currency maintained. So if I have let's say 20 currencies that are being maintained, I need to create 20 worksheets for that and then save it to an excel file to a network folder.

I'd really appreciate your help on this. Thanks a lot in advance.

Regards,

Kristine

Add a comment
10|10000 characters needed characters exceeded

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 04, 2005 at 10:59 AM

    Hi Kristine,

    Take a look at transaction DWDM (Demo programs) under tree-node "Demo's Workbench" --> "Excel".

    You'll see 3 programs that demonstrate on handling data to an Excel sheet (also with multiple worksheets).

    The programs are using dummy data and via SE38 you can view the source code better.

    Programs: XXLFTEST, XXLSTEST and XXLTTEST.

    Regards,

    Rob.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 05, 2005 at 05:17 AM

    Thanks Rob!

    I'll try to work on the sample programs you've given me. Although I haven't done any OLE programs yet, I think the references you gave me will be a good help.

    Regards,

    Kristine

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 05, 2005 at 08:56 AM

    Hello,

    I'm trying to follow the code for creating multiple worksheet in an excel file via OLE. Can anyone here help me? I'm really having a hard time on this one.

    So far I have 1 internal table which contains the data needed for excel download in multiple worksheets, I created an internal table for the 10 worksheet names.

    Can somebody start the code for me? I just need 3 columns. My problem here is how to put the values from my internal table (select from TCURR) to the excel spreadsheet.

    So far here's what I have coded: (referenced from sapfans.com)

    --


    Begin of Code--

    data: w_book type ole2_object,

    w_sheet type ole2_object,

    excel type ole2_object.

    create object excel 'EXCEL.APPLICATION'.

    call method of excel 'WORKBOOKS' = w_book.

    call method of w_book 'OPEN' exporting #1 = p_file.

    if sy-subrc eq 0.

    loop at i_worksheet. "contains the 10 worksheets that

    "needs to be created

    call method of excel 'Worksheets' = w_sheet

    exporting #1 = i_worksheet-sheetname.

    call method of w_sheet 'Activate'.

    if sy-subrc eq 0.

    *****Here's where I'm lost********

    endif.

    endloop.

    endif.

    --


    End of Code--

    Thanks in advance.

    Regards,

    Kristine

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 06, 2005 at 09:49 AM

    *Function Module to downlaod the dat into excel file

    CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'

    EXPORTING

    FILE_NAME = V_FNAME

    TABLES

    DATA_TAB = I_ALV

    FIELDNAMES = I_FIELDNAME

    EXCEPTIONS

    FILE_NOT_EXIST = 1

    FILENAME_EXPECTED = 2

    COMMUNICATION_ERROR = 3

    OLE_OBJECT_METHOD_ERROR = 4

    OLE_OBJECT_PROPERTY_ERROR = 5

    INVALID_FILENAME = 6

    INVALID_PIVOT_FIELDS = 7

    DOWNLOAD_PROBLEM = 8

    OTHERS = 9.

    ENDCASE.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 06, 2005 at 10:26 AM

    Good old SAP Help

    http://help.sap.com/saphelp_47x200/helpdata/en/21/b53138e1ba11d2bdbe080009b4534c/frameset.htm

    Above,there is the link for spreadsheet interface. You can find all the help you need.

    -


    Please, give points if it helps.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 23, 2005 at 07:09 PM

    Try DOI(Desktop Office Integration) EXCEL Inegration & pivot Interface.

    SAP has many DEMO Programs under the Package SOFFICEINTEGRATION, you can have a look to these for better understanding with the SAP Office Integration.

    See DOI(Desktop Office Integration) examples in DWDM & SE83.

    I have done some work

    URL http://www.geocities.com/ojnc/freestuff.html

    Download http://www.geocities.com/ojnc/DOI_Excel_Pivot.zip

    This makes DOI very easy to use.

    The pivot interface object should be created soon after creating the document and spreadsheet interfaces object. Otherwise often it is not successful and returns a null pivot handle.

    The Internal table for Pivot should have a header line otherwise DYN_ANALYSE_SINGLE will fail.

    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.