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

Email excel attachment using BCS classes

Former Member
0 Likes
469

Hi Folks,

I am using BCS classes to send excel attachment in an mail. Everything is working fine except the Auto fit functionality of the columns. When the user opens the excel attachment he wants to see the columns width to be autofit.

2 REPLIES 2
Read only

_IvanFemia_
Active Contributor
0 Likes
329

Hi,

check this SDN Blog [abap2xlsx - Generate your professional Excel spreadsheet from ABAP|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/20046] [original link is broken] [original link is broken] [original link is broken]; could be useful to you.

Regards,

Ivan

Read only

0 Likes
329

Hi Ivan,

My requirement here is, I have data in internal table and this internal table data has to be sent as an email in excel format. I made use of the standard BCS classes SAP provided and was able to successfully send the excel attachment but the columns here are not auto-fit according to the field width. I used the following classes to send data:

The below class what it does is, it converts the data in string(LV_STRING) into binary_content.

TRY.

cl_bcs_convert=>string_to_solix(

EXPORTING

iv_string = lv_string

iv_codepage = '4103' "suitable for MS Excel, leave empty for other doc types

iv_add_bom = 'X'

IMPORTING

et_solix = binary_content

ev_size = size ).

CATCH cx_bcs.

ENDTRY.

The above binary content is transformed into excel

  • Add the spread sheet as attachment to document object

document->add_attachment(

i_attachment_type = 'xls'

i_attachment_subject = 'Excel_Attachment_Name'

i_attachment_size = size

i_att_content_hex = binary_content).

  • Add document object to send request

send_request->set_document( document ).

The links provided by you are very interesting but does not fulfill my requirement. Thanks and appreciate more responses.