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: 

Create advance Excel with ABAP code

oleg_sukharenko
Explorer
0 Kudos
420

Hello gurus,

I have a requirement to create excel spreadsheet with accents, colors and icons from ABAP program.

Does anyone know how to do it? Maybe, there is a way to export ALV with at least colors to be carried over?

<removed by moderator>

Thanks.

Edited by: Thomas Zloch on Feb 10, 2012

1 ACCEPTED SOLUTION

oleg_sukharenko
Explorer
0 Kudos
320

Hi Thomas.

For some reason in my system "inplace" functionality is only displaying blank "excel" without data when invoked, but that is not my concern at this point.

I need to send e-mail in background processing with excel attachment and i need to accent some lines with color. I can do simple excel creation in the background processing as an attachment, but do you know a way to create excel or to convert ALV( i can first create ALV with proper formatting) where I can create/keep colors?

Does SAP have a sample program for it?

Thank you very much for your time.

5 REPLIES 5

ThomasZloch
Active Contributor
0 Kudos
320

Did you try the ALV Excel Inplace functionality with colored ALV cells already?

Thomas

oleg_sukharenko
Explorer
0 Kudos
321

Hi Thomas.

For some reason in my system "inplace" functionality is only displaying blank "excel" without data when invoked, but that is not my concern at this point.

I need to send e-mail in background processing with excel attachment and i need to accent some lines with color. I can do simple excel creation in the background processing as an attachment, but do you know a way to create excel or to convert ALV( i can first create ALV with proper formatting) where I can create/keep colors?

Does SAP have a sample program for it?

Thank you very much for your time.

0 Kudos
320

the excel inplace is blank because of excel macro settings:

http://howtosap.blogspot.com/2011/05/how-to-sap-excel-inplace-show-empty.html

this link shows step step by setting that you need to make to get over this.

if you want to do this through code you need to use OLE.

check this wiki:

http://wiki.sdn.sap.com/wiki/display/Snippets/CellColoringwhileExcelDownload

you can search the forum for more.

Regards,

oleg_sukharenko
Explorer
0 Kudos
320

Thomas,

The most complete and satisfying answer.

I really appreciate your input.

Best Regards.

oleg_sukharenko
Explorer
0 Kudos
320

Hi Thomas again,

if you don't mind, I have follow up question to the sample program you provided. It is shown how to launch the formated excel on-line. I need to send email with excel as an attachment. Here is as I convert bulided string into excel now:

-


DATA: lv_string TYPE string.

DATA binary_content TYPE solix_tab.

DATA size TYPE so_obj_len.

*Header

  • header line

CONCATENATE lv_string

'SYSTEM'(m01) gc_tab

'INTERFACE'(m02) gc_tab

'RUN NUMBER'(m03) gc_tab

'DATE'(m04) gc_tab

'TIME'(m05) gc_tab

'MESS. TYPE'(m06) gc_tab

'MESS. CLASS'(m07) gc_tab

'MESS. NO'(m08) gc_tab

'FULL MESSAGE'(m09) gc_tab

'MESS. VAR1'(m10) gc_tab

'MESS. VAR2'(m11) gc_tab

'MESS VAR3'(m12) gc_tab

'MESS. VAR4'(m13) gc_tab INTO lv_string.

*

  • convert the text string into UTF-16LE binary data including

  • byte-order-mark. Mircosoft Excel prefers these settings

  • all this is done by new class cl_bcs_convert (see note 1151257)

TRY.

CLEAR:binary_content.

cl_bcs_convert=>string_to_solix(

EXPORTING

iv_string = lv_string

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

iv_add_bom = 'X' "for other doc types

IMPORTING

et_solix = binary_content

ev_size = size ).

CATCH cx_bcs.

MESSAGE e445(so).

ENDTRY.

-


Do you have any suggestion how to format it with colors?

Thank you vey much for your time