Application Development 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: 

ALV - Excel in place Issue

Former Member
0 Kudos

Hi all,

Im facing a strange issue in ALV output's excel in place option.

while selecting the default option - Excel in place, in ALV output, ocassionally some fields (Particularly Table headings) are appearing in a different font, say SAPDings.

This font is actually used for displaying check boxes.

Table headings which are supposed to be displayed in Arial font by default are some time displayed in SAPDings.

Have anyone faced such an issue and resolved ? or any solution for this? Please do reply.

1 REPLY 1

Former Member
0 Kudos

See the following good example

REPORT ZOLE_ABAP.

INCLUDE ole2incl.

&----


*& TYPES *

&----


TYPES: BEGIN OF ty_spfli,

kunnr TYPE kna1-kunnr,

land1 TYPE kna1-land1,

NAME1 TYPE KNA1-NAME1,

ORT01 TYPE KNA1-ORT01,

REGIO TYPE KNA1-REGIO,

ADRNR TYPE KNA1-ADRNR,

END OF ty_spfli.

TYPES: BEGIN OF ty_titles,

title(20) TYPE c,

field(20) TYPE c,

END OF ty_titles.

&----


*& INTERNAL TABLES *

&----


DATA: t_spfli TYPE STANDARD TABLE OF ty_spfli,

t_titles TYPE STANDARD TABLE OF ty_titles.

&----


*& FIELD-SYMBOLS *

&----


FIELD-SYMBOLS: <fs_spfli> LIKE LINE OF t_spfli,

<fs_titles> LIKE LINE OF t_titles,

<fs> TYPE ANY.

&----


*& VARIABLES *

&----


DATA: w_tabix TYPE sy-tabix,

w_titles TYPE sy-tabix,

w_line TYPE sy-tabix,

w_field TYPE string,

filename TYPE string,

path TYPE string,

fullpath TYPE string.

DATA: data_titles TYPE REF TO data.

DATA: e_sheet TYPE ole2_object,

e_activesheet TYPE ole2_object,

e_newsheet TYPE ole2_object,

e_appl TYPE ole2_object,

e_work TYPE ole2_object,

e_cell TYPE ole2_object,

e_color TYPE ole2_object,

e_bold TYPE ole2_object.

&----


*& SELECTION-SCREEN *

&----


SELECTION-SCREEN BEGIN OF BLOCK b1.

PARAMETERS: p_file TYPE rlgrap-filename.

SELECTION-SCREEN END OF BLOCK b1.

&----


*& START-OF-SELECTION *

&----


START-OF-SELECTION.

PERFORM get_titles.

PERFORM get_data.

PERFORM create_excel.

&----


*& AT SELECTION-SCREEN *

&----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL METHOD cl_gui_frontend_services=>file_save_dialog

EXPORTING

window_title = 'Select archivo'

default_extension = 'xls'

file_filter = '*.xls'

CHANGING

filename = filename

path = path

fullpath = fullpath.

IF sy-subrc EQ 0.

p_file = fullpath.

ENDIF.

&----


*& Form get_titles *

&----


FORM get_titles.

CREATE DATA data_titles TYPE ty_titles.

ASSIGN data_titles->* TO <fs_titles>.

<fs_titles>-title = 'Customer Number 1'.

<fs_titles>-field = 'KUNNR'.

APPEND <fs_titles> TO t_titles.

<fs_titles>-title = 'Country Key'.

<fs_titles>-field = 'LAND1'.

APPEND <fs_titles> TO t_titles.

<fs_titles>-title = 'Name 1'.

<fs_titles>-field = 'NAME1'.

APPEND <fs_titles> TO t_titles.

<fs_titles>-title = 'City'.

<fs_titles>-field = 'ORT01'.

APPEND <fs_titles> TO t_titles.

<fs_titles>-title = 'Region'.

<fs_titles>-field = 'REGIO'.

APPEND <fs_titles> TO t_titles.

<fs_titles>-title = 'Address'.

<fs_titles>-field = 'ADRNR'.

APPEND <fs_titles> TO t_titles.

ENDFORM. "get_titles

&----


*& Form get_data *

&----


FORM get_data.

SELECT KUNNR LAND1 NAME1 ORT01 REGIO ADRNR

INTO TABLE t_spfli

FROM KNA1

WHERE LAND1 EQ 'IN'

and KUNNR EQ '0000700008'.

ENDFORM. " get_data

&----


*& Form create_excel *

&----


FORM create_excel.

w_line = 1.

CREATE OBJECT e_appl 'EXCEL.APPLICATION'.

SET PROPERTY OF e_appl 'VISIBLE' = 1.

CALL METHOD OF e_appl 'WORKBOOKS' = e_work.

CALL METHOD OF e_work 'Add' = e_work.

GET PROPERTY OF e_appl 'ActiveSheet' = e_activesheet.

SET PROPERTY OF e_activesheet 'Name' = 'Customer Details'.

LOOP AT t_spfli ASSIGNING <fs_spfli>.

w_tabix = sy-tabix.

w_line = w_line + 1.

LOOP AT t_titles ASSIGNING <fs_titles>.

w_titles = sy-tabix.

CALL METHOD OF e_appl 'Cells' = e_cell

EXPORTING

#1 = 1

#2 = w_titles.

SET PROPERTY OF e_cell 'Value' = <fs_titles>-title.

GET PROPERTY OF e_cell 'Interior' = e_color.

SET PROPERTY OF e_color 'ColorIndex' = 35.

GET PROPERTY OF e_cell 'Font' = e_bold.

SET PROPERTY OF e_bold 'Bold' = 1.

CALL METHOD OF e_appl 'Cells' = e_cell

EXPORTING

#1 = w_line

#2 = w_titles.

CONCATENATE '<fs_spfli>-' <fs_titles>-field

INTO w_field.

ASSIGN (w_field) TO <fs>.

SET PROPERTY OF e_cell 'Value' = <fs>.

GET PROPERTY OF e_cell 'Interior' = e_color.

SET PROPERTY OF e_cell 'ColumnWidth' = 20.

SET PROPERTY OF e_color 'ColorIndex' = 0.

GET PROPERTY OF e_cell 'Font' = e_bold.

SET PROPERTY OF e_bold 'Bold' = 0.

ENDLOOP.

ENDLOOP.

CALL METHOD OF e_work 'SAVEAS'

EXPORTING

#1 = p_file.

CALL METHOD OF e_work 'close'.

CALL METHOD OF e_appl 'QUIT'.

FREE OBJECT e_appl.

ENDFORM. " create_excel