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: 

OLE Automation - Background color of a Column in Excel

suryasarathi_basu
Participant
0 Kudos

Hi Experts,

i am using OLE Automation to download some data into excel using 'EXCEL.APPLICATION' from SAP tables based on the requirement and the given format. I want to color a particular column in generated excel but cant do that. The data is getting downloaded correctly but cant set the color. Please can anyone suggest ?

Regards,

SURYA

1 REPLY 1

Former Member
0 Kudos

Hi,

Can be something like this:


DATA: l_ole_interior TYPE ole2_object,
      l_ole_cell1 TYPE ole2_object,
      l_ole_cell2 TYPE ole2_object,
      l_ole_range TYPE ole2_object.

   CALL METHOD OF p_obj 'Cells' = l_ole_cell1
                EXPORTING #1 = 1
                          #2 = 1.
   IF sy-subrc EQ 0.
     CALL METHOD OF p_obj 'Cells' = l_ole_cell2
                  EXPORTING #1 = 10
                            #2 = 1.
     IF sy-subrc EQ 0.
       CALL METHOD OF p_obj 'Range' = l_ole_range
                    EXPORTING #1 = l_ole_cell1
                              #2 = l_ole_cell2.
       IF sy-subrc EQ 0.
         CALL METHOD OF l_ole_range 'Interior' = l_ole_interior.
       ENDIF.
     ENDIF.
   ENDIF.
   SET PROPERTY OF l_ole_interior 'ColorIndex' = 33. "p_color.
   SET PROPERTY OF l_ole_interior 'Pattern' = 1.
   FREE OBJECT: l_ole_cell1, l_ole_cell2, l_ole_range, l_ole_interior.

Kr,

Manu.