Skip to Content

SAP OLE - Hide Column

I have a program which generates and excel sheet via OLE , since it requires complex formatting. Now based on certain criteria, I want to hide certain columns. I could not find how to do the same. How do i achieve the same?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Dec 12, 2012 at 12:48 PM

    Hi Anish,

    Here's an example:

    METHOD column_B_hidden.

    DATA: l_excel TYPE ole2_object,

    l_wbooklist TYPE ole2_object,

    l_application TYPE ole2_object,

    l_wbook TYPE ole2_object,

    l_activesheet TYPE ole2_object,

    l_column TYPE ole2_object.

    CREATE OBJECT l_excel 'EXCEL.APPLICATION'.

    SET PROPERTY OF l_excel 'Visible' = 1. " Visible

    GET PROPERTY OF l_excel 'Workbooks' = l_wbooklist.

    GET PROPERTY OF l_wbooklist 'Application' = l_application.

    SET PROPERTY OF l_application 'SheetsInNewWorkbook' = 1.

    CALL METHOD OF l_wbooklist 'Add' = l_wbook.

    GET PROPERTY OF l_application 'ActiveSheet' = l_activesheet.

    CALL METHOD OF l_excel 'COLUMNS' = l_column

    EXPORTING

    #1 = 2. " 2 = Column B

    SET PROPERTY OF l_column 'Hidden' = 1.

    ENDMETHOD. "column_B_hidden

    Regards,

    Christian

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 12, 2012 at 12:51 PM

    Hi Anish,

    As a reference of SAP Standard Demo Program ,"RSDEMO01" .

    if Field1 = field2 .

    " Suppose u doesn't want dis field for certern Condition put if condition ,Excel Colomn Name
    PERFORM FILL_CELL USING 1 1 1 'Flg'(001).
    endif.
    PERFORM FILL_CELL USING 1 2 1 'Nr'(002).
    PERFORM FILL_CELL USING 1 3 1 'Von'(003).
    PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
    PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).

    for Column Value .....

    LOOP AT IT_SPFLI.
    * copy flights to active EXCEL sheet
    H = SY-TABIX + 1.
    if Field1 = field2 .
    PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
    endif.
    PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
    PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
    PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
    PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
    ENDLOOP.

    Note : Not match with ur exact requirement , but your reference purpose

    Regard's

    Smruti

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.