OLE Excel NumberFormat

Hi All,
In OLE for example consider the follwing statement,
SET PROPERTY OF wf_cell1 'NumberFormat' = '@'.
How can I get to know the list of possible values for 'NumberFormat' with their meaning?
(Actually I want to use Currency format in my EXCEL application)
Regards,
Manoj Kumar P

Dear Manoj,
HOpe this will help you https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/exporting%252bdata%252bto%252bexcel%252b-%252bxml%252bto%252bthe%252brescue
Regards,
Pravin s

Similar Messages

  • Failed to Run OLE Excel program in background JOB (SM36)

    Please help.
    I have write a program to use OLE to create a Excel file.
    The program can run successful in front end workstation. However, when I run the program in background job by SM36.
    The statement "CREATE OBJECT EXCEL 'EXCEL.APPLICATION'" return with error "SY-SUBRC = 2".
    How can I solve it ?
    Can OLE Excel be run on background job ?
    Thanks so much,
    Mark

    Hi Mark:
    Your need is a very common one. I also was asked to generate an Excel in Background.
    It is not possible to work with OLE in background mode.
    The reason is: In background mode there is no presentation server. OLE is executed in presentation server.
    Below I paste the code I wrote to solve my problem.
    This class sends a mail with an excel attached. The Excel content will be the internal table you pass to the class. But the Excel is not binary, it is a plain text file, separated by tabulators. Anyway, when you open it with Excel, the columns are properly shown.
    Sorry. Comments are in spanish, I don't have time to translate it.
    I kindly ask to everybody which want to use it to keep my name in the code.
    * Autor: Jordi Escoda, 30/10/2008.
    * Descripción: Esta clase genera un correo electrónico destinado a
    *  una persona, adjuntando el contenido de una tabla interna como
    *  Excel (campos separados por tabuladores).
    *  La virtud de esta clase es su sencillez de utilización. Para lanzar
    *  el mail con el excel adjunto basta con declarar la tabla interna,
    *  llenarla, colocar el asunto del mensaje, el destinatario, el nombre
    *  del excel adjunto, y pasar la tabla interna.
    * Ejemplo de utilización:
    *  DATA: lc_mail TYPE REF TO cl_mail_builder_xls_attach.
    *  DATA: lt_anla TYPE STANDARD TABLE OF anla.
    *    SELECT * INTO TABLE lt_anla  FROM anla.
    *    CREATE OBJECT lc_mail.
    *    CALL METHOD lc_mail->set_subject( 'Excel adjunto' ).
    *    CALL METHOD lc_mail->set_recipient( 'XXX@XXXDOTCOM' ).
    *    CALL METHOD lc_mail->set_attach_filename( 'ANLA' ).
    *    APPEND 'Cuerpo del mensaje' TO  lt_body.
    *    APPEND 'Saludos cordiales' TO  lt_body.
    *    CALL METHOD lc_mail->set_bodytext( lt_body ).
    *    CALL METHOD lc_mail->set_attach_table( lt_anla ).
    *    CALL METHOD lc_mail->send( ).
    *       CLASS cl_mail_builder_xls_attach DEFINITION
    CLASS cl_mail_builder_xls_attach DEFINITION.
      PUBLIC SECTION.
        METHODS: set_subject
                               IMPORTING im_subject TYPE so_obj_des,
                 set_bodytext
                               IMPORTING im_body TYPE bcsy_text,
                 set_recipient
                               IMPORTING im_recipient TYPE ad_smtpadr,
                 set_attach_table
                               IMPORTING im_table TYPE ANY TABLE,
                 set_attach_filename
                               IMPORTING im_attach_name TYPE sood-objdes,
                 send.
      PRIVATE SECTION.
        CONSTANTS:
          c_tab  TYPE c VALUE cl_bcs_convert=>gc_tab,
          c_crlf TYPE c VALUE cl_bcs_convert=>gc_crlf,
          c_singlequote TYPE c VALUE '.
        DATA: l_recipient_addr TYPE ad_smtpadr.
        DATA: send_request   TYPE REF TO cl_bcs,
              document       TYPE REF TO cl_document_bcs,
              recipient      TYPE REF TO if_recipient_bcs,
              bcs_exception  TYPE REF TO cx_bcs.
        DATA: binary_content TYPE solix_tab,
              size           TYPE so_obj_len.
        DATA: l_string TYPE string,
              l_body_text TYPE bcsy_text,
              l_subject TYPE so_obj_des,
              l_attach_name TYPE sood-objdes.
        METHODS: create_binary_content,
                 get_dataelement_medium_text
                        IMPORTING im_table_name TYPE tabname
                                  im_field_name TYPE fieldname
                        EXPORTING ex_medium_text TYPE scrtext_m.
    ENDCLASS.                    "cl_mail_builder_xls_attach DEFINITION
    *       CLASS cl_mail_builder_xls_attach IMPLEMENTATION
    CLASS cl_mail_builder_xls_attach IMPLEMENTATION.
      METHOD set_bodytext.
        l_body_text[] = im_body[].
      ENDMETHOD.                    "add_bodytext
      METHOD set_subject.
        l_subject = im_subject.
      ENDMETHOD.                    "add_subject
      METHOD set_attach_filename.
        l_attach_name = im_attach_name.
      ENDMETHOD.                    "add_subject
      METHOD set_recipient.
        l_recipient_addr = im_recipient.
      ENDMETHOD.                    "add_subject
      METHOD set_attach_table.
    *   Rellena en un string el contenido de la tabla interna recibida
        DATA: ref_to_struct  TYPE REF TO cl_abap_structdescr.
        DATA: my_like TYPE fieldname,
              nombretabla TYPE tabname,
              nombrecampo TYPE fieldname,
              texto_mediano TYPE scrtext_m.
        DATA: l_idx TYPE i,
              l_valorcampo(16) TYPE c,
              l_long TYPE i.
        FIELD-SYMBOLS: <fs_linea> TYPE ANY,
                       <fs_campo> TYPE ANY.
        FIELD-SYMBOLS: <comp_descr> TYPE abap_compdescr.
        CHECK NOT im_table[] IS INITIAL.
    *   Línea con los nombres de las columnas.
        CLEAR l_string.
        LOOP AT im_table ASSIGNING <fs_linea>.
    *     Toma los atributos del componente
          ref_to_struct  =
                     cl_abap_structdescr=>describe_by_data( <fs_linea> ).
          LOOP AT ref_to_struct->components ASSIGNING <comp_descr>.
            ASSIGN COMPONENT <comp_descr>-name
                                OF STRUCTURE <fs_linea> TO <fs_campo>.
    *       Obtenemos el origen de donde proviene (like). Ej:BKPF-BUDAT
            DESCRIBE FIELD <fs_campo> HELP-ID my_like.
            SPLIT my_like AT '-' INTO nombretabla nombrecampo.
            CALL METHOD get_dataelement_medium_text
              EXPORTING
                im_table_name  = nombretabla
                im_field_name  = nombrecampo
              IMPORTING
                ex_medium_text = texto_mediano.
            IF texto_mediano IS INITIAL.
              CONCATENATE l_string <comp_descr>-name INTO l_string.
            ELSE.
              CONCATENATE l_string texto_mediano INTO l_string.
            ENDIF.
            AT LAST.
              CONCATENATE l_string c_crlf INTO l_string.
              EXIT.
            ENDAT.
            CONCATENATE l_string c_tab INTO l_string.
          ENDLOOP.
          EXIT.
        ENDLOOP.
    *   Contenido de la tabla
        LOOP AT im_table ASSIGNING <fs_linea>.
    *     Toma los atributos del componente
          ref_to_struct  =
                     cl_abap_structdescr=>describe_by_data( <fs_linea> ).
          LOOP AT ref_to_struct->components ASSIGNING <comp_descr>.
    *       Asignamos el componente ue tratamos, para obtener
    *       el valor del mismo
            ASSIGN COMPONENT <comp_descr>-name OF STRUCTURE <fs_linea>
                                            TO <fs_campo>.
            CASE <comp_descr>-type_kind.
              WHEN 'P'. "Packed Number
    *           Convierte a caracter
                WRITE <fs_campo> TO l_valorcampo.
                CONCATENATE l_string l_valorcampo INTO l_string.
              WHEN OTHERS.
                l_long = STRLEN( <fs_campo> ).
                IF l_long > 11 AND <fs_campo> CO ' 0123456789'.
    *             El Excel muestra un número tal como 190000000006
    *             en formato 1,9E+11.
    *             Para eviarlo, los números de más de 11 dígitos los
    *             concatenamos con comillas simples.
                  CONCATENATE l_string c_singlequote
                              <fs_campo> c_singlequote INTO l_string.
                ELSE.
                  CONCATENATE l_string <fs_campo> INTO l_string.
                ENDIF.
            ENDCASE.
            AT LAST.
    *         Añade CRLF
              CONCATENATE l_string c_crlf INTO l_string.
              EXIT.
            ENDAT.
    *       Añade tabulador
            CONCATENATE l_string c_tab INTO l_string.
          ENDLOOP.
        ENDLOOP.
        create_binary_content( ).
      ENDMETHOD.                    "set_attach_table
      METHOD create_binary_content.
        DATA: l_size TYPE so_obj_len.
    *   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.
            cl_bcs_convert=>string_to_solix(
              EXPORTING
                iv_string   = l_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.
      ENDMETHOD.                    "create_binary_content
      METHOD send.
        DATA: l_sent_to_all TYPE os_boolean.
        TRY.
    *       create persistent send request
            send_request = cl_bcs=>create_persistent( ).
    *       create and set document with attachment
    *       create document object
            document = cl_document_bcs=>create_document(
              i_type    = 'RAW'
              i_text    = l_body_text
              i_subject = l_subject ).
    *       add the spread sheet as attachment to document object
            document->add_attachment(
              i_attachment_type    = 'xls'
              i_attachment_subject = l_attach_name
              i_attachment_size    = size
              i_att_content_hex    = binary_content ).
    *       add document object to send request
            send_request->set_document( document ).
    *       add recipient (e-mail address)
            recipient =
               cl_cam_address_bcs=>create_internet_address(
                                          l_recipient_addr ).
    *       add recipient object to send request
            send_request->add_recipient( recipient ).
    *       send document
            l_sent_to_all = send_request->send(
                                 i_with_error_screen = 'X' ).
            COMMIT WORK.
            IF l_sent_to_all IS INITIAL.
              MESSAGE i500(sbcoms) WITH l_recipient_addr.
            ELSE.
              MESSAGE s022(so).
            ENDIF.
          CATCH cx_bcs INTO bcs_exception.
            MESSAGE i865(so) WITH bcs_exception->error_type.
        ENDTRY.
      ENDMETHOD.                    "lcl_mail_xls_attachment
      METHOD get_dataelement_medium_text.
        DATA: lt_fld_info TYPE STANDARD TABLE OF dfies,
          wa_fld_info TYPE dfies.
    *   Busca en el diccionario los datos del campo
        CALL FUNCTION 'DDIF_FIELDINFO_GET'
          EXPORTING
            tabname        = im_table_name
            fieldname      = im_field_name
            langu          = sy-langu
          TABLES
            dfies_tab      = lt_fld_info
          EXCEPTIONS
            not_found      = 1
            internal_error = 2
            OTHERS         = 3.
        CLEAR ex_medium_text.
        IF sy-subrc = 0.
          READ TABLE lt_fld_info INDEX 1 INTO wa_fld_info.
    *     Si lo ha podido tomar del diccionario...
          IF NOT wa_fld_info-scrtext_m IS INITIAL.
    *       Toma el nombre del nombre de campo del diccionario
            ex_medium_text = wa_fld_info-scrtext_m.
          ENDIF.
        ENDIF.
      ENDMETHOD.                    "get_dataelement_medium_text
    ENDCLASS.                    "cl_mail_builder_xls_attach IMPLEMENTATION

  • Problem in running a ABAP OLE Excel program in Web Portal

    Hi,
    Do anyone know how to solve the following problem ?
    I have write a ABAP program in R/3 to use OLE to create a Excel file.
    The program can run successful in front end workstation through SAPGUI.
    However, when I run this ABAP program through the Web Portal by "Workset"
    After I input the selection criteria and execute the program:
    The statement "CREATE OBJECT EXCEL 'EXCEL.APPLICATION'" return with error "SY-SUBRC = 2".
    How can I solve it ?
    Can OLE Excel Abap Program can run on Web Portal through the "Workset" ?
    Thanks so much,
    Mark

    Hi
    check this might help
    Re: Displaying Error while uploading Excel Sheets
    jo

  • Dump while running a program with OLE Excel download facility in ITS

    Hi,
    Because of some complex requirment, I had created a report program which will download the data to an Excel sheet using SAP OLE Automation Controller. For this report i had created a tcode too.
    The report which i developed is perfectly working fine in SAPGUI. But if i access the same report throught SAP ITS serice. I am getting a dump. Please find below the dump details. I am not able to figure it out why the dump is not coming in SAPGUI.
    Runtime Errors         MESSAGE_TYPE_X
    Date and Time          09.03.2010 05:35:41
    Short text
    The current application triggered a termination with a short dump.
    What happened?
    The current application program detected a situation which really
    should not occur. Therefore, a termination with a short dump was
    triggered on purpose by the key word MESSAGE (type X).
    |
    Error analysis
    Short text of error message:
    Control Framework : Error processing control
    Long text of error message:
    Diagnosis
    An error occurred when the system tried to process the commands
    from the Automation Queue on the presentation server.
    There are several possible reasons for this:
    - The installation of the SAP GUI on the presentation server is
    faulty or obsolete.
    - There is an error in the application program
    - There is an error in the SAPGUI or an integrated control
    Procedure
    1. Make sure that you have imported the appropriate Support
    Package, the current kernel, and GUI patch for the release of your
    system
    2. Check whether the error occurs locally on one or a few PCs, or
    generally on all PCs. Note whether the error only occurs for some
    users, for example because of a specific Customizing setting.
    If it only occurs locally, this suggests an installation problem
    with the PC. Check the installation; if necessary, reinstall the
    software. In the dump, search for the SY-MSGLI field, since it may
    point to the cause of the error.
    3. Activate the Automation Trace (in accordance with SAP Note
    158985).
    4.Start the transaction and continue until the screen immediately
    before the dump.
    5. From the System -> Utilities menu, choose Autom. Queue,
    Synchronous Processing.
    The status bar of the GUI displays the text:
    "Automation synchron flush mode on"
    6. If you now proceed with the application, the short dump will
    display the ABAP call that caused the error; the Automation Trace
    will contain the error on the presentation server.
    7. If necessary, load the short dump and trace files on to
    sapservX, so that SAP can analyze them.
    Technical information about the message:
    Message class....... "CNDP"
    Number.............. 006
    Variable 1.......... " "
    Variable 2.......... " "
    Variable 3.......... " "
    Variable 4.......... " "
    How to correct the error
    Probably the only way to eliminate the error is to correct the program.
    If the error occures in a non-modified SAP program, you may be able to
    find an interim solution in an SAP Note.
    If you have access to SAP Notes, carry out a search with the following
    keywords:
    "MESSAGE_TYPE_X" " "
    "SAPLOLEA" or "LOLEAU02"
    "AC_SYSTEM_FLUSH"
    If you cannot solve the problem yourself and want to send an error
    notification to SAP, include the following information:
    1. The description of the current problem (short dump)
    To save the description, choose "System->List->Save->Local File
    (Unconverted)".
    2. Corresponding system log
    Display the system log by calling transaction SM21.
    Restrict the time interval to 10 minutes before and five minutes
    after the short dump. Then choose "System->List->Save->Local File
    (Unconverted)".
    3. If the problem occurs in a problem of your own or a modified SAP
    program: The source code of the program
    In the editor, choose "Utilities->More
    Utilities->Upload/Download->Download".
    4. Details about the conditions under which the error occurred or which
    actions and input led to the error.
    User and Transaction
    Client.............. 120
    User................ "XXXXXX"
    Language Key........ "E"
    Transaction......... "ZGA_BEACON_SOX_RPT "
    Transactions ID..... "4B95E2560EB62F9AE10000000A241C33"
    Program............. "SAPLOLEA"
    Screen.............. "ZGA_REP_BEACON_SOX_REPORT 9000"
    Screen Line......... 0
    Information on Caller ofr "HTTP" Connection:
    Plug-in Type.......... "HTTP"
    Caller IP............. "10.36.28.52"
    Caller Port........... 8000
    Universal Resource Id. "/sap/bc/gui/sap/its/webgui/~flNUQVRFPTIzNzIxLjAxNC4wNC4
    wNA=="

    Hi All,
    FYI.....
    As I said because of my complex requirement, i am using OLE excel download facilities to download the data. ITS wont support this OLE download facility.  This can be done only through local SAP GUI.
    The reason for this is that, when i am using this download facility through SAP GUI, OLE object thats used in my report program will directly talk to the Local OLE excel objects (i.e. the local installed Excell application) and download the data. But if it's through ITS, my program wont be able to communicate with the local excel OLE objects because of this i am getting a DUMP.
    Thank You all for the support. All the best in future. 
    Regards
    Maneesh Chandran

  • Vnd.ms-excel.numberformat:@

    I use a cloud-computing app, Salesforce, to maintain some databases. The report module, which produces nice-looking formatted reports, allows you to export the data as .csv files, which can be opened without trouble by Numbers. It also allows you to export them (formatting intact) as .xls files, which are (according to their first line) in this vnd.ms-excel.numberformat. I recently downloaded a trial of Microsoft Office, and those files were opened without trouble by excel (formatting intact).
    Is there any way to open them in Numbers so that the formatting remains? Here is a sample lines: it's obviously html code but I can't get Numbers to read it as that.
    "<tr><td style=""vnd.ms-excel.numberformat:@"">xx Durst Membership Donation - 03/05/2010</td><td align=right>5.00</td><td align=right>3/5/2010</td><td style=""vnd.ms-excel.numberformat:@"">xx Durst Household</td><td style=""vnd.ms-excel.numberformat:@"">Membership 2010</td></tr>"

    and which I spelt properly in the other thread.
    I have a friend named Ivan, so I slipped.
    My name is CLARE, not ClaIre, or Clara, or any number of other variations. My last name is DURST, not Durt, nor Dust, nor Rust. I get used to misspellings!

  • OLE excel

    Hello all,
    1.
    I shoud output a excel file using ABAP development. And my excel file is very complex, it have some fixed headers. i am new to ole excel, so who  can give me some examples or some useful website. then i can learn how to do it ?
    2.
    anther question: in which situation, i can't output a excel file? pls tell me asap.
    Thanks in advance.

    Hello Ming,
    Try this program... i have used lots of excel formatting in it.. revert back incase you need help
    *& Report  ZKRIS_OLE2
    REPORT  zkris_ole2.
    TYPE-POOLS ole2 .
    DATA:  count TYPE i,
           application TYPE ole2_object,
           workbook TYPE ole2_object,
           excel     TYPE ole2_object,
           sheet TYPE ole2_object,
           cells TYPE ole2_object.
    CONSTANTS: row_max TYPE i VALUE 256.
    DATA index TYPE i.
    DATA:
          h_cell        TYPE ole2_object,        " cell
          h_f           TYPE ole2_object,        " font
          h_range       TYPE ole2_object,
          h_range2      TYPE ole2_object,
          h_merge       TYPE ole2_object,
          h_int         TYPE ole2_object,
          h_int2         TYPE ole2_object,
          h_width       TYPE ole2_object,
          h_columns     TYPE ole2_object,
          h_rows        TYPE ole2_object,
          h_actwindow   TYPE ole2_object,
          h_select      TYPE ole2_object,
          h_select2     TYPE ole2_object,
          h_hyperlink   TYPE ole2_object,
          h_addhyper    TYPE ole2_object,
          h_borderstop  TYPE ole2_object,
          h_entirecol   TYPE ole2_object.
    CREATE OBJECT excel 'EXCEL.APPLICATION'.
    IF sy-subrc NE 0.
      WRITE: / 'No EXCEL creation possible'.
      STOP.
    ENDIF.
    SET PROPERTY OF excel 'DisplayAlerts' = 0.
    CALL METHOD OF excel 'WORKBOOKS' = workbook .
    SET PROPERTY OF excel 'VISIBLE' = 1.
    * creating workbook
    SET PROPERTY OF excel 'SheetsInNewWorkbook' = 1.
    CALL METHOD OF workbook 'ADD'.
    CALL METHOD OF excel 'WORKSHEETS' = sheet.
    CALL METHOD OF sheet 'ADD'.
    FREE OBJECT sheet.
    CALL METHOD OF excel 'WORKSHEETS' = sheet
      EXPORTING
        #1 = 1.
    SET PROPERTY OF sheet 'NAME' = 'Company Codes'.
    CALL METHOD OF sheet 'ACTIVATE'.
    DATA: col TYPE i VALUE 1,
    row TYPE i VALUE 2,
    col1 TYPE i VALUE 2,
    col_real TYPE i VALUE 1.
      index = row_max * ( row - 2 ) + 1.
      CALL METHOD OF sheet 'Cells' = cells
        EXPORTING
          #1 = index.
      SET PROPERTY OF cells 'Value' = 'thsi is some larger amount of data blahhhh'.
    CALL METHOD OF excel 'Rows' = h_rows
      EXPORTING
        #1 = '1:1'.
      SET PROPERTY OF h_rows 'WrapText' = 1.
    DO 5 TIMES.
      index = row_max * ( row - 1 ) + col.
      CALL METHOD OF sheet 'Cells' = cells
        EXPORTING
          #1 = index.
    *  SET PROPERTY OF cells 'Value' = '=TRIM("1234     2")'.
      SET PROPERTY OF cells 'Value' = 'thsi is some large data'.
      CALL METHOD OF excel 'Cells' = h_cell
        EXPORTING
          #1 = row
          #2 = col.
      SET PROPERTY OF h_cell  'Align' = 'Center'.
      GET PROPERTY OF h_cell 'Interior'   = h_int.
    *  SET PROPERTY OF h_int  'ColorIndex' = col_real .
      GET PROPERTY OF h_cell 'Font'    = h_f.
    *  SET PROPERTY OF h_f 'ColorIndex' = 1.
    get property of h_cell 'Borders' = h_borderstop.
    set property of h_borderstop 'LineStyle' = 1.
    set property of h_borderstop 'Weight' = 2.
      SET PROPERTY OF h_f 'Bold' = 1.                    "bold
      SET PROPERTY OF h_cell 'HorizontalAlignment' = 2.  "left align
      SET PROPERTY OF h_cell 'Orientation' = 45.         "angled
      col = col + 1.
      col_real = col_real + 1.
      IF col = 16.
        col = 1.
        row = row + 1.
      ENDIF.
      col1 = col_real + 1.
    ENDDO.
    index = row_max * ( 10 - 1 ) + 1.
    CALL METHOD OF sheet 'Cells' = cells
      EXPORTING
        #1 = index.
    SET PROPERTY OF cells 'Value' = '123'.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = 10
        #2 = 1.
    GET PROPERTY OF h_cell 'Interior'   = h_int.
    SET PROPERTY OF h_int  'ColorIndex' = 4 .
    *range
    CALL METHOD OF excel 'Range' = h_range
      EXPORTING
        #1 = 'A10'
        #2 = 'K10'.
    CALL METHOD OF h_range 'Merge' = h_merge .
    * width or autofit
    CALL METHOD OF excel 'Columns' = h_columns
      EXPORTING
        #1 = 'A:E'.
    *SET PROPERTY OF h_columns 'ColumnWidth' = 17.
    GET PROPERTY OF h_columns 'EntireColumn' = h_entirecol.
    set property of h_entirecol 'Autofit' = 1.
    * hyperlink
    ** simple method
    *get property of sheet 'Hyperlinks' = h_hyperlink.
    *call method of h_hyperlink 'Add' = h_addhyper
    *  exporting
    *  #1 = h_range
    *  #3 = '#Sheet1!A1'.
    index = row_max * ( 12 ) + 1.
    CALL METHOD OF sheet 'Cells' = cells
      EXPORTING
        #1 = index.
    SET PROPERTY OF cells 'Value' = 'test data'.
    GET PROPERTY OF sheet 'Hyperlinks' = h_hyperlink.
    CALL METHOD OF h_hyperlink 'Add' = h_addhyper
      EXPORTING
        #1 = cells
        #3 = '#Sheet1!A1'.
    * borders
    CALL METHOD OF excel 'Range' = h_range2
      EXPORTING
        #1 = 'A5'
        #2 = 'L28'.
    GET PROPERTY OF h_range2 'Select' = h_select2.
    *CALL METHOD OF h_hyperlink 'Add' = h_addhyper
    *  EXPORTING
    *    #1 = h_range2
    *    #3 = '#Sheet1!A1'.
      GET PROPERTY OF h_select2 'Interior'   = h_int2.
      SET PROPERTY OF h_int2  'ColorIndex' = 6 .
    get property of h_range2 'Borders' = h_borderstop.
    set property of h_borderstop 'LineStyle' = 1.
    set property of h_borderstop 'Weight' = 2.
    * freeze panes
    CALL METHOD OF excel 'Rows' = h_rows
      EXPORTING
        #1 = '3:3'.
    GET PROPERTY OF h_rows 'Select' = h_select.
    GET PROPERTY OF excel 'ActiveWindow' = h_actwindow.
    SET PROPERTY OF h_actwindow 'FreezePanes' = 1.

  • OLE Excel Questions

    Guys,
    I am working on OLE excel to download data from SAP.I have few basic questions for OLE excel
    1. I want to merge Cells in EXCEL , how can i do it?
    2. I want to make alignment right in some Cell,how can i do it?
    3. I have been reading post in SDN for OLE ,so in that one i notice different numbers for colors like 
    SET PROPERTY OF O_INTERIOR 'Color' = '10092543'.
    .how can i know the code for color. as well as for alignment of text in cell . 
    SET PROPERTY OF O_CELL 'HorizontalAlignment' = -4108 .
    ..so from where do you know -4180 is for center alignment
    4. How can i know different methods and properties of excel cell as well as workbook.
    I know these are lot of questions,but basic ones i guess.If someone can give me guidance that would be helpful and points will be given.

    Suppose EXCEL is your EXCEL.APPLICATION handler
    All H_ objects are of  TYPE OLE2_OBJECT type
    1. for merging
    data:
          H_RANGE       TYPE OLE2_OBJECT,
          H_MERGE       TYPE OLE2_OBJECT.
    CALL METHOD OF EXCEL 'Range' = H_RANGE
      EXPORTING
        #1 = 'A10'
        #2 = 'K10'.
    CALL METHOD OF H_RANGE 'Merge' = H_MERGE .
    2. for aligning, row and col are of type i.. referring to the cell you wish to change
    1 = default
    2 = left
    3 = center
    4 = right
    5 = justify
      CALL METHOD OF EXCEL 'Cells' = H_CELL
        EXPORTING
          #1 = ROW
          #2 = COL.
      SET PROPERTY OF h_cell 'HorizontalAlignment' = 3.
    3. For color coding see this program
    *& Report  ZKRIS_OLE3_PALETTE
    *& Displays the full OLE color range in excel
    REPORT  ZKRIS_OLE3_PALETTE.
    TYPE-POOLS ole2 .
    DATA:  count TYPE i,
           count_real TYPE i,
           application TYPE ole2_object,
           workbook TYPE ole2_object,
           excel     TYPE ole2_object,
           sheet TYPE ole2_object,
           cells TYPE ole2_object.
    CONSTANTS: row_max TYPE i VALUE 256.
    DATA index TYPE i.
    DATA:
          h_cell        TYPE ole2_object,        " cell
          h_f           TYPE ole2_object,        " font
          h_int         TYPE ole2_object,
          h_width       TYPE ole2_object,
          h_columns     TYPE ole2_object,
          h_rows        TYPE ole2_object,
          h_font        TYPE ole2_object,
          h_entirecol   TYPE ole2_object.
    DATA: h_range       TYPE ole2_object.
    DATA: h_merge       TYPE ole2_object.
    CREATE OBJECT excel 'EXCEL.APPLICATION'.
    IF sy-subrc NE 0.
      WRITE: / 'No EXCEL creation possible'.
      STOP.
    ENDIF.
    SET PROPERTY OF excel 'DisplayAlerts' = 0.
    CALL METHOD OF excel 'WORKBOOKS' = workbook .
    SET PROPERTY OF excel 'VISIBLE' = 1.
    * creating workbook
    SET PROPERTY OF excel 'SheetsInNewWorkbook' = 1.
    CALL METHOD OF workbook 'ADD'.
    CALL METHOD OF excel 'WORKSHEETS' = sheet
      EXPORTING
        #1 = 1.
    SET PROPERTY OF sheet 'NAME' = 'Color Palette'.
    CALL METHOD OF sheet 'ACTIVATE'.
    DATA: col TYPE i VALUE 1,
    row TYPE i VALUE 2,
    col1 TYPE i VALUE 2,
    col_real TYPE i VALUE 1.
    row = 1.
    col = 3.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'No.'.
    col = col + 1.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'Background'.
    col = col + 1.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'Foreground with white background'.
    col = col + 1.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'Foreground with black background'.
    CALL METHOD OF excel 'Rows' = h_rows
      EXPORTING
        #1 = '2:2'.
    SET PROPERTY OF h_rows 'WrapText' = 1.
    col = 9.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'No.'.
    col = col + 1.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'Background'.
    col = col + 1.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'Foreground with white background'.
    SET PROPERTY OF h_cell 'Bold' = 1.
    col = col + 1.
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = row
        #2 = col.
    SET PROPERTY OF h_cell 'Value' = 'Foreground with black background'.
    CALL METHOD OF excel 'Rows' = h_rows
      EXPORTING
        #1 = '1:1'.
    SET PROPERTY OF h_rows 'WrapText' = 1.
    GET PROPERTY OF h_rows 'Font' = h_font.
    SET PROPERTY OF h_font 'Bold' = 1.
    count = 1.
    count_real = count.
    row = 2.
    col = 3.
    DO 56 TIMES.
      PERFORM write_num_and_color.
    ENDDO.
    * autofit
    CALL METHOD OF excel 'Columns' = h_columns
      EXPORTING
        #1 = 'C:L'.
    GET PROPERTY OF h_columns 'EntireColumn' = h_entirecol.
    SET PROPERTY OF h_entirecol 'Autofit' = 1.
    * write palette on lhs
    *range
    CALL METHOD OF excel 'Range' = h_range
      EXPORTING
        #1 = 'A2'
        #2 = 'A20'.
    CALL METHOD OF h_range 'Merge' = h_merge .
    CALL METHOD OF excel 'Cells' = h_cell
      EXPORTING
        #1 = 2
        #2 = 1.
    SET PROPERTY OF h_cell 'Value' = 'Palette'.
    SET PROPERTY OF h_cell 'Orientation' = 90.         "angled.
    SET PROPERTY OF h_cell 'HorizontalAlignment' = 3.  "center align
    GET PROPERTY OF h_cell 'Font'    = h_f.
    SET PROPERTY OF h_f 'Bold' = 1.                    "bold
    SET PROPERTY OF h_f 'Name' = 'Comic Sans MS'.
    SET PROPERTY OF h_f 'Size' = '14'.
    SET PROPERTY OF h_cell 'VerticalAlignment' = 2.  "center align
    * autofit
    CALL METHOD OF excel 'Columns' = h_columns
      EXPORTING
        #1 = 'A:A'.
    GET PROPERTY OF h_columns 'EntireColumn' = h_entirecol.
    SET PROPERTY OF h_columns 'ColumnWidth' = 4.
    *&      Form  write_num_and_color
    *       text
    FORM write_num_and_color.
      index = row_max * ( row - 1 ) + col.
      CALL METHOD OF sheet 'Cells' = cells
        EXPORTING
          #1 = index.
      SET PROPERTY OF cells 'Value' = count_real.
      col = col + 1.
      CALL METHOD OF excel 'Cells' = h_cell
        EXPORTING
          #1 = row
          #2 = col.
      GET PROPERTY OF h_cell 'Interior'   = h_int.
      SET PROPERTY OF h_int  'ColorIndex' = count_real.
      col = col + 1.
      CALL METHOD OF excel 'Cells' = h_cell
        EXPORTING
          #1 = row
          #2 = col.
      SET PROPERTY OF h_cell 'Value' = 'Sample Text'.
      GET PROPERTY OF h_cell 'Font'    = h_f.
      SET PROPERTY OF h_f 'ColorIndex' = count_real.
      col = col + 1.
      CALL METHOD OF excel 'Cells' = h_cell
        EXPORTING
          #1 = row
          #2 = col.
      GET PROPERTY OF h_cell 'Interior'   = h_int.
      SET PROPERTY OF h_int  'ColorIndex' = 1.
      SET PROPERTY OF h_cell 'Value' = 'Sample Text'.
      GET PROPERTY OF h_cell 'Font'    = h_f.
      SET PROPERTY OF h_f 'ColorIndex' = count_real.
      row = row + 1.
      col = col - 3.
      count = count + 1.
      IF count = 29.
        count = 1.
        row = 2.
        col = col + 6.
      ENDIF.
      count_real = count_real + 1.
    ENDFORM.                    "write_num_and_color
    4. To know the different OLE properties, you need to examine the macros in excel and then use a bit of trial and error at first

  • A number in a CHAR in OLE excel

    Hi,
    I've got a problem with and OLE Excel.
    I must pass to the excel file a numeric value written in a char variables (es: '01111') and, in the excel file, it is written like '111111'.
    I try to convert it with this:
       GET PROPERTY OF g_cell1 'SET_FORMAT' = g_text.
       SET PROPERTY OF g_text  'CATEGORY' = 4.
    but it doesn't work.
    Please, help me.
    Thanks

    Hi,
    I think the value is passed correctly but this is excel's output format.
    When you open the file, right click on cell -> Format Cells -> Custom -> enter 5 zeros '00000' (exact number of places which should be displayed). Now the value will come as '01111'.
    Regards
    Marcin

  • Regarding OLE Excel

    Hi gurus,
    I am creating Excel file passing values to different sheets A,B,C from internal table.
    But when my program is under execution, if i try open new excel sheet then datas are getting written into new sheet. so the out put of real excel sheet is different from as expected.
    Do i have to maintain any property in OLE excel to avoid this situation. because i want to open some other excel file, while my program is executing with OLE excel creation.
    Regards
    Ambichan

    INCLUDE ole2incl.
    DATA: application TYPE ole2_object,
           workbook TYPE ole2_object,
           sheet TYPE ole2_object,
           cells TYPE ole2_object,
           gs_chart TYPE ole2_object.
    CONSTANTS: row_max TYPE i VALUE 256.
    DATA index TYPE i.
    CREATE OBJECT application 'excel.application'.
        SET PROPERTY OF application 'visible' = 1.
        CALL METHOD OF application 'Workbooks' = workbook.
    *CALL METHOD OF workbook 'Add'. "if you want to create a file
        CALL METHOD OF workbook 'Open'
          EXPORTING
            #1 = p_file.
             #1 =    'C:\Temp\XXX0099_Support_20XX.xls'.  "your excel file
                                                               name here
    Create second Excel sheet  "Timesheets
        CALL METHOD OF application 'Worksheets' = sheet
          EXPORTING
            #1 = 2.
        SET PROPERTY OF sheet 'Name' = 'Timesheets'.
        CALL METHOD OF sheet 'Activate'.
        CLEAR: w_index.
        SORT itab BY budat hiden.
        LOOP AT itab.
          w_index = sy-tabix + w_lin.
          CALL METHOD OF application 'Cells' = cells
            EXPORTING
              #1 = w_index      " line
              #2 = 1.           " column
          SET PROPERTY OF cells 'Value' = itab-hiden .  "need to be changed
    Save excel spreadsheet to particular filename
        CALL METHOD OF sheet 'Save'   "'Save'
          EXPORTING
       #1 = p_file
            #1 =  p_file
            #2 = 1."filename
        "fileFormat
    Closes excel window, data is lost if not saved
    SET PROPERTY OF application 'visible' = 0.
    reward points if its helpful

  • Using Existing OLE Excel Object

    Hi
    I have created an ole excel object to download my report data.
    My requirement is to use an existing excel object.
    Existing OLE object would act like a template with the Header Information and my company's logo in it.
    Can anyone suggest suitable procedures for the same.
    AK

    I dont know more about it.
    Just have look below function module.
    <b>EXCEL_OLE_STANDARD_DAT</b> Just calls MS_EXCEL_OLE_STANDARD_DAT
    <b>MS_EXCEL_OLE_STANDARD</b>_DATDownloads internal table and opens it in MS Excel
    <b>KCD_EXCEL_OLE_TO_INT_CONVERT</b> Uploads an *.xls file to internal table (max cell length = 32).
    <b>ALSM_EXCEL_TO_INTERNAL_TABLE</b> the same as KCD_EXCEL_OLE_TO_INT_CONVERT but max cell length = 50
    <b>FTBU_START_EXCEL</b> just [download internal table to file and] start Excel (w/o OLE).
    regards
    vinod

  • Dump while executing a OLE Excel download report feature in ITS

    Hi,
    Because of some complex requirment, I had created a report program which will download the data to an Excel sheet using SAP OLE Automation Controller. For this report i had created a tcode too.
    The report which i developed is perfectly working fine in SAPGUI. But if i access the same report throught SAP ITS serice. I am getting a dump. Please find below the dump details. I am not able to figure it out why the dump is not coming in SAPGUI.
    Runtime Errors         MESSAGE_TYPE_X
    Date and Time          09.03.2010 05:35:41
    Short text
    The current application triggered a termination with a short dump.
    What happened?
    The current application program detected a situation which really
    should not occur. Therefore, a termination with a short dump was
    triggered on purpose by the key word MESSAGE (type X).
    |
    Error analysis
    Short text of error message:
    Control Framework : Error processing control
    Long text of error message:
    Diagnosis
    An error occurred when the system tried to process the commands
    from the Automation Queue on the presentation server.
    There are several possible reasons for this:
    - The installation of the SAP GUI on the presentation server is
    faulty or obsolete.
    - There is an error in the application program
    - There is an error in the SAPGUI or an integrated control
    Procedure
    1. Make sure that you have imported the appropriate Support
    Package, the current kernel, and GUI patch for the release of your
    system
    2. Check whether the error occurs locally on one or a few PCs, or
    generally on all PCs. Note whether the error only occurs for some
    users, for example because of a specific Customizing setting.
    If it only occurs locally, this suggests an installation problem
    with the PC. Check the installation; if necessary, reinstall the
    software. In the dump, search for the SY-MSGLI field, since it may
    point to the cause of the error.
    3. Activate the Automation Trace (in accordance with SAP Note
    158985).
    4.Start the transaction and continue until the screen immediately
    before the dump.
    5. From the System -> Utilities menu, choose Autom. Queue,
    Synchronous Processing.
    The status bar of the GUI displays the text:
    "Automation synchron flush mode on"
    6. If you now proceed with the application, the short dump will
    display the ABAP call that caused the error; the Automation Trace
    will contain the error on the presentation server.
    7. If necessary, load the short dump and trace files on to
    sapservX, so that SAP can analyze them.
    Technical information about the message:
    Message class....... "CNDP"
    Number.............. 006
    Variable 1.......... " "
    Variable 2.......... " "
    Variable 3.......... " "
    Variable 4.......... " "
    How to correct the error
    Probably the only way to eliminate the error is to correct the program.
    If the error occures in a non-modified SAP program, you may be able to
    find an interim solution in an SAP Note.
    If you have access to SAP Notes, carry out a search with the following
    keywords:
    "MESSAGE_TYPE_X" " "
    "SAPLOLEA" or "LOLEAU02"
    "AC_SYSTEM_FLUSH"
    If you cannot solve the problem yourself and want to send an error
    notification to SAP, include the following information:
    1. The description of the current problem (short dump)
    To save the description, choose "System->List->Save->Local File
    (Unconverted)".
    2. Corresponding system log
    Display the system log by calling transaction SM21.
    Restrict the time interval to 10 minutes before and five minutes
    after the short dump. Then choose "System->List->Save->Local File
    (Unconverted)".
    3. If the problem occurs in a problem of your own or a modified SAP
    program: The source code of the program
    In the editor, choose "Utilities->More
    Utilities->Upload/Download->Download".
    4. Details about the conditions under which the error occurred or which
    actions and input led to the error.
    User and Transaction
    Client.............. 120
    User................ "XXXXXX"
    Language Key........ "E"
    Transaction......... "ZGA_BEACON_SOX_RPT "
    Transactions ID..... "4B95E2560EB62F9AE10000000A241C33"
    Program............. "SAPLOLEA"
    Screen.............. "ZGA_REP_BEACON_SOX_REPORT 9000"
    Screen Line......... 0
    Information on Caller ofr "HTTP" Connection:
    Plug-in Type.......... "HTTP"
    Caller IP............. "10.36.28.52"
    Caller Port........... 8000
    Universal Resource Id. "/sap/bc/gui/sap/its/webgui/~flNUQVRFPTIzNzIxLjAxNC4wNC4
    wNA=="

    Check the following example to download in excel
    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.

  • OLE excel - subtotals

    hello everybody,
    i am trying to format an already existing excel-file with ole-technique.
    this works fine so far, but (of course) there is one very important step i can't handle.
    i need to make subtotals and after 2 days of trying and searching the net i have no more ideas how it could work.
    to make it easier to understand i have made a simple excerpt which everyone should be able to use as local report by copy/paste or you can download the coding as txt-file from here:
    txt-file
    Report  ZVEXCELOLE_TMP
    Author: Matthias Leitner
    REPORT zvexcelole_tmp NO STANDARD PAGE HEADING LINE-SIZE 132.
    datendeklaration                                                    *
    DATA: it_filetable TYPE filetable.
    DATA: wa_filetable TYPE file_table.
    DATA: wa_filename     TYPE string,
          wa_upload       TYPE string,
          wa_download     TYPE string,
          wa_file(255)    TYPE c,
          wa_rc           TYPE i.
    OLE-Definitionen
    INCLUDE ole2incl.
    DATA: wa_loesch type i,
          o_excel         TYPE ole2_object,
          o_workbook      TYPE ole2_object,
          o_columns       TYPE ole2_object,
          o_autofit       TYPE ole2_object,
          o_blatt         TYPE ole2_object.
    selection-screen                                                    *
    SELECTION-SCREEN BEGIN OF BLOCK z3 WITH FRAME.
    PARAMETERS: pa_dir(255) TYPE c LOWER CASE .
    SELECTION-SCREEN END OF BLOCK z3.
    initialization                                                      *
    INITIALIZATION.
    standardmässiges download-verzeichnis holen
      CALL METHOD cl_gui_frontend_services=>get_upload_download_path
        CHANGING
          upload_path                 = wa_upload
          download_path               = wa_download
        EXCEPTIONS
          cntl_error                  = 1
          error_no_gui                = 2
          not_supported_by_gui        = 3
          gui_upload_download_path    = 4
          upload_download_path_failed = 5
          OTHERS                      = 6.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        MOVE wa_download TO pa_dir.
      ENDIF.
    at selection-screen                                                 *
    AT SELECTION-SCREEN.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_dir.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
       WINDOW_TITLE            =
       DEFAULT_EXTENSION       =
       DEFAULT_FILENAME        =
       FILE_FILTER             =
       INITIAL_DIRECTORY       =
       MULTISELECTION          =
       WITH_ENCODING           =
        CHANGING
          file_table              = it_filetable
          rc                      = wa_rc
       USER_ACTION             =
       FILE_ENCODING           =
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          not_supported_by_gui    = 4
          OTHERS                  = 5
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        READ TABLE it_filetable INTO wa_filetable INDEX 1.
        MOVE wa_filetable-filename TO pa_dir.
      ENDIF.
    start-of-selection                                                  *
    START-OF-SELECTION.
      PERFORM excel_format.
      MOVE pa_dir TO wa_file.
      FORMAT HOTSPOT ON.
      WRITE: wa_file+0(132).
      FORMAT HOTSPOT OFF.
      HIDE wa_file.
      CLEAR wa_file.
    at line-selection                                                   *
    AT LINE-SELECTION.
      CLEAR wa_file.
      READ CURRENT LINE.
      IF NOT wa_file IS INITIAL.
        MOVE wa_file TO wa_filename.
        CALL METHOD cl_gui_frontend_services=>execute
          EXPORTING
            document               = wa_filename
         application            =
         PARAMETER              =
         DEFAULT_DIRECTORY      =
         MAXIMIZED              =
         MINIMIZED              =
         SYNCHRONOUS            =
          EXCEPTIONS
            cntl_error             = 1
            error_no_gui           = 2
            bad_parameter          = 3
            file_not_found         = 4
            path_not_found         = 5
            file_extension_unknown = 6
            error_execute_failed   = 7
            OTHERS                 = 8
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
      ENDIF.
    form excel_format                                                   *
    FORM excel_format.
    start excel
      CREATE OBJECT o_excel 'EXCEL.APPLICATION'.
      IF sy-subrc NE 0.
        WRITE: / 'OLE-Fehler. EXCEL.APPLICATION'.
      ENDIF.
    excel -> not visible
      SET PROPERTY OF o_excel 'Visible' = 0.                   "visible = 1
      IF sy-subrc NE 0.
        WRITE: / 'OLE-Fehler. Visible'.
      ENDIF.
    Arbeitsblatt auswählen
      CALL METHOD OF o_excel 'Workbooks' = o_workbook.
      IF sy-subrc NE 0.
        WRITE: / 'OLE-Fehler. Workbooks'.
      ENDIF.
    open existing file
      CALL METHOD OF o_workbook 'OPEN'
        EXPORTING
        #1 = pa_dir.
      IF sy-subrc NE 0.
        WRITE: / 'OLE-Fehler. OPEN'.
      ENDIF.
    SUBTOTALS!!!
    bei allen spalten auf optimale breite setzen
      CALL METHOD OF o_excel 'Columns' = o_columns.
      IF sy-subrc NE 0.
        WRITE: / 'OLE-Fehler. Columns'.
      ENDIF.
      CALL METHOD OF o_columns 'Autofit' = o_autofit.
      IF sy-subrc NE 0.
        WRITE: / 'OLE-Fehler. Autofit'.
      ENDIF.
    save and close excel
      CALL METHOD OF o_excel 'Worksheets' = o_blatt
        EXPORTING
        #1 = 1.
      IF sy-subrc NE 0.
        WRITE: / 'OLE-Fehler. Worksheets'.
      ENDIF.
      CALL METHOD OF o_blatt 'SaveAs'
        EXPORTING
        #1 = pa_dir
        #2 = 1.                "fileFormat
      IF sy-subrc NE 0.
        WRITE: / 'OLE-Fehler. SaveAs'.
      ELSE.
      ENDIF.
      CALL METHOD OF o_workbook 'CLOSE'.
      IF sy-subrc NE 0.
        WRITE: / 'OLE-Fehler. CLOSE'.
      ENDIF.
      CALL METHOD OF o_excel 'QUIT'.
      IF sy-subrc NE 0.
        WRITE: / 'OLE-Fehler. QUIT'.
      ENDIF.
      FREE o_excel.
    ENDFORM.                                             "FORM excel_format
    the excel-file should be grouped by column 6 and sum column 4.
    you can download an example of the excel-sheet (already including the subtotals as i need them):
    xls-file
    i hope my question is clear. if i have forgotten anything important - please ask.
    our system:
    SAP_BASIS 620
    excel 2002 - service pack 3
    thanks in advance!
    matthias
    Message was edited by: Matthias Leitner

    hi vinod,
    thank you very much for the reply.
    if i get it right the first two function modules don't have any functionallity for making subtotals. the next two just put excel-data into internal format.
    the last may be a possibility to use an external excel makro .
    but i think it must be possible to do this by OLE.
    best regards,
    matthias

  • OLE EXCEL in foreground

    Hi,
    i use in abap EXCEL with OLE and visible mode. Every thing works like i want, but
    when excel starts, it's allways behind the SAP Window.
    Is there any way to start the excel allways in foreground?
    Regards, Dieter
    Moved to GUI - Forum
    Edited by: Dieter Gröhn on Feb 7, 2011 12:58 PM

    Hi,
    this has been discussed 1000 times.
    OLE is not available in background. Full Stop.
    You can create tab-delimited text files that can be opened by excel: No formatting, one unnamed sheet in workbook.
    XLSX formatted excel-compatible files with all excel features can be created in background. Check out the XLSX code project her or in google code. It will perfectly do what you want but you have to do some work.
    I do not give the link here because if you really want to do you can find it.
    Regards,
    Clemens

  • OLE Excel file upload method

    hi
    we have the requirement to download data in excel file in unicode format for which the OLE FM EXCEL_OLE_STANDARD_DAT in used for the download.
    We now want to upload the same file after modification. GUI_DOWNLOAD uplaods the file wsith gibberish characters. We tried using the FM 'ALSM_EXCEL_TO_INTERNAL_TABLE' but it gives the dump UPLOAD_OLE exception.
    What else are the methods to upload the excel file.
    Your ideas appreciated.
    Rgds,
    Stck

    Hi,
    Try this code to upload the data from EXCEL sheet.
    DATA l_count TYPE sy-tabix.
       CONSTANTS: lc_begin_col TYPE i VALUE '1',
                  lc_begin_row TYPE i VALUE '2',
                  lc_end_col   TYPE i VALUE '2',
                  lc_end_row   TYPE i VALUE '3000'.
    * Begin of CALK912848 - Carlos Werberich - 16Sep08
      CLEAR p_i_excel_data. REFRESH p_i_excel_data.
    * End   of CALK912848 - Carlos Werberich - 16Sep08
    * Function module to read excel file and convert it into internal table
       CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
         EXPORTING
           filename                = p_p_file
           i_begin_col             = lc_begin_col
           i_begin_row             = lc_begin_row
           i_end_col               = lc_end_col
           i_end_row               = lc_end_row
         TABLES
           intern                  = i_data
         EXCEPTIONS
           inconsistent_parameters = 1
           upload_ole              = 2
           OTHERS                  = 3.
    * Error in file upload
       IF sy-subrc NE 0 .
         MESSAGE text-006 TYPE 'E'.
         EXIT.
       ENDIF.
       IF i_data[] IS INITIAL .
         MESSAGE text-007 TYPE 'E'.
         EXIT.
       ELSE.
         SORT i_data BY row col .
    * Loop to fill data in Internal Table
         LOOP AT i_data .
           MOVE i_data-col TO l_count .
           ASSIGN COMPONENT l_count OF STRUCTURE p_i_excel_data TO  .
           AT END OF row .
    * Append data into internal table
             APPEND p_i_excel_data.
             CLEAR p_i_excel_data.
           ENDAT .
         ENDLOOP .
       ENDIF 

  • Declare Array in OLE Excel

    Dear all,
    How can I declare a variable type Array in Excel Ole ABAP ??
    Dim a As Variant
    a = Array(11, 12)
    How can I declare in ABAP ??
    Thank you

    Note 633105 - OLE automation: ABAP type for OLE array parameters
    Symptom
    If the method of an OLE object contains an array parameter, there is no suitable ABAP data type for the parameter.
    Reason and Prerequisites
    Array is not supported as a data type for OLE parameters in ABAP.
    Solution
    None

Maybe you are looking for

  • To CHARGE or NOT to CHARGE, that is the 3G question!

    Man I am so confused. I read CHARGE it like a laptop thus if near a plug, plug it in as its like a laptop and goes on cycles not turning 20% and then charge into your 20% becoming the 100% then having 1 hour on your battery. So, which is it? I have r

  • How to Display the content of Excel file into Webdynpro Table

    Hi Experts I am following the Blog to upload a file in to the webdynpro context,but my problem is after uploading a excel file i need to extract the content from that Excel file and that content should be displayed in the webdynpro table.Can any body

  • Can't Read Web Gallery Announcements

    Is it at all possible to change the preferences for the announcements ("Tell a Friend" button) on the web gallery? When I use it to send out an announcement, you can hardly read it! The writing is so light that people cannot read their log in and pas

  • Itunes music jumping

    I have used itunes for years and never had issues with playing the music through my laptop, but recently any music that i have downloaded or videos they jump constantly and videos freeze and have no sound on them ? Is this an itunes error ? They have

  • Airport Express can only extend network, not create new one. Why?

    I am sharing a flat with some friends. The shared broadband router is placed in the living room. To strengthen the signal and make it easier for me to manage, I bought an Airport Express, connected it to the shared router with an ethernet cable and s