Skip to Content
avatar image
Former Member

how to send .XLSX File with multiple worksheets as an attachment

Dear All,

I am facing the issue while sending the mail with attachment type .XLSX. for the multiple Worksheets.

we have Tried with below possibilities :

1. Customized SO_DOCUMENT_SEND_API1 and Changed the Document type Size as from ( 3 to 4 ).

2. Tried with CL_BCS Functionality based on the reference Standard program BCS_EXAMPLE_7

3. Tried with ABAP2XLSX Functionality.

Finally we have achieved to send single worksheet with .XLSX Extension , But its not happening for Multiple worksheets.

Waiting for Solutions.


Regards ,

Nagaraju Adhikari

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Mar 31, 2016 at 05:44 AM

    Hi Naga Raju,

    Try using the OLE For attaching Multiple Work sheets in Excel..All the Changes regarding the Excel you can go through the OLE( For Downloading , Uploading , Creating the Sheets Dynamically ).

    Find the below link...

    Sending email with multiple tabs of excel as a single attachment in ABAP

    Hope these is useful

    Thanks & Regards

    @SURENDRA@

    Add comment
    10|10000 characters needed characters exceeded

    • You have to create a new worksheet (or any number you need)

      If I remember well (in this system I have not yet installed it) there are 2 methods in LO_EXCEL to add_worksheet and SET_ACTIVE_WORKSHEET.

      With them you can add and activate the correct worksheet with a flow like the one below

      LO_EXCEL->ADD_WORKSHEET( )

      LO_EXCEL->SET_ACTIVE_WORKSHEET( n ) <-n is the worksheet number

      LO_WORKSHEET = LO_EXCEL->GET_ACTIVE_WORKSHEET( ).

      <---your code--->

      If you check ZCL_EXCEL class you can find pretty easily the methods you need.
      Sorry for the raw answer, but, as I stated, I do not have the code on this system for a more accurate one

  • Mar 31, 2016 at 12:46 PM

    With little bit of XML knowledge and a know how of how Open XML Spreadsheet works, you can merge different XLSX files into 1 file. I have done this in the past.

    Considering the XLSX files contains only text data - not graphs, pictures etc - You just need to merge, Shared strings, Styles and Relationships for this to happen.

    Don't ask me for source code - I don't have access to it currently - but it is definitely doable without the help of external tools and by just using ABAP.

    Thanks, Juwin

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 01, 2016 at 04:07 AM

    Dear All,

    I got the solution for multiple worksheets with .XLSX Extension.

    Thanks for your suggestions.


    Regards ,

    Nagaraju Adhikari

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi NagaRaju,

      You can explain how you have done..So it is useful for some one who may face the same issue..

      Appreciate if you share your knowledge regarding these.

      Thanks & Regards

      @Surendra@

  • avatar image
    Former Member
    Apr 01, 2016 at 06:58 AM

    Dear Surendra,

    I Have Used ABAP2XLSX Concept and Written the Below Code:

    data:lo_excel type ref to zcl_excel ,

    lo_worksheet type ref to zcl_excel_worksheet ,

    * For first Sheet in the excel workbook

    " Get active sheet

    lo_worksheet = lo_excel->get_active_worksheet( ).

    lo_worksheet->title = 'First Sheet'.

    lo_worksheet->set_table( ip_table = ip_table

    ip_table_title = 'ITAB'"'LT_TEST'

    ip_hdr_style = lv_style_header_guid

    ip_body_style = lv_style_body_guid

    zlt_components = zlt_components ).

    * For second Sheet in the excel workbook

    Add a new work sheet and set the second table as above. ).

    and use below logic

    lv_file = lo_excel->save_as( zcl_excel=>c_xlsx ).

    " Convert to binary

    call function 'SCMS_XSTRING_TO_BINARY'

    exporting

    buffer = lv_file

    importing

    output_length = lv_bytecount

    tables

    binary_tab = lt_file_tab.

    and then write send_request method.

    we need to write code for SET_TABLE and SET_TABLE2 to pass the Internal table data by using all the importing parameters.

    Thanks & Regards ,

    Nagaraju Adhikari

    Add comment
    10|10000 characters needed characters exceeded