Populating graph in excel using ole

Hi All,
I am able to populate the graph from abap into excel using OLE.
But I am not able to take x-axis and y-axis according to my requirement, its taking by its own as default. please see the below code:
<b>CALL METHOD OF GS_EXCEL 'Cells' = GS_CELL1
    EXPORTING
    #1 = GV_LINE_CNTR
    #2 = 1.
    CALL METHOD OF GS_EXCEL 'Cells' = GS_CELL2
    EXPORTING
    #1 = GV_LINNO1
    #2 = GV_COLNO.
    CALL METHOD OF GS_EXCEL 'Range' = GS_CELLS
    EXPORTING
    #1 = GS_CELL1
    #2 = GS_CELL2.
    CALL METHOD OF GS_CELLS 'Select' .
    GET PROPERTY OF GS_APPLICATION 'Charts' = GS_CHARTS .
    CALL METHOD OF GS_CHARTS 'Add' = GS_CHART .
    CALL METHOD OF GS_CHART 'Activate' .
    SET PROPERTY OF GS_CHART 'ChartType' = '93' .</b>Now I want to give my own range. But i am not able to.
I am also not able to give labels of x-axis and y-axis.
Please help, its very urgent............

Hello,
try this code. It creates macro as a file, and than uses that macro to show the chart
Regards,
Naimesh
REPORT ZTEST_NP .
INCLUDE OLE2INCL. " OLE objects include
*export data variables
DATA: H_EXCEL TYPE OLE2_OBJECT, " Excel object
WORKBOOKS TYPE OLE2_OBJECT, " list of workbooks
THIS_WORKBOOK TYPE OLE2_OBJECT, " workbook
CELL TYPE OLE2_OBJECT, " cell
BOOK_FONT TYPE OLE2_OBJECT. " font
*chart creation DATA: variables
DATA: MODULE TYPE OLE2_OBJECT, "macro
     NEWMODULE TYPE OLE2_OBJECT. "macrotab with VB source code
INternal tableTABLES: no_table.
DATA H TYPE I.
table that contains Visual Basic source code
DATA: BEGIN OF MACROFILE OCCURS 0,
      LINE(80) ,
     END OF MACROFILE.
*Internal table with Months and related Profits
DATA: BEGIN OF NO_TABLE OCCURS 10,   "Internal table with no's
      MONTH(8) TYPE C,
      PROFIT(8) TYPE C,
     END OF NO_TABLE.
*Months added to table as well as Profits
NO_TABLE-MONTH = 'June'.
NO_TABLE-PROFIT = '1000'. APPEND NO_TABLE. "Update table
NO_TABLE-MONTH = 'July'.
NO_TABLE-PROFIT = '4000'. APPEND NO_TABLE. "Update table
NO_TABLE-MONTH = 'August'.
NO_TABLE-PROFIT = '3000'. APPEND NO_TABLE. "Update table
NO_TABLE-MONTH = 'September'.
NO_TABLE-PROFIT = '7000'. APPEND NO_TABLE. "Update table
NO_TABLE-MONTH = 'October'.
NO_TABLE-PROFIT = '7000'. APPEND NO_TABLE. "Update table
NO_TABLE-MONTH = 'November'.
NO_TABLE-PROFIT = '6000'. APPEND NO_TABLE. "Update table
CALL METHOD OF THIS_WORKBOOK 'InsertFile'
EXPORTING #1 = 'C:\VBsource.tmp'.
*********Fill makro table with VB source code************************
the macro's name is draw_graph
MACROFILE-LINE = 'sub draw_graph()'. APPEND MACROFILE.
MACROFILE-LINE = 'Range("a1:a1").Font.Bold = True'.APPEND macrofile.
MACROFILE-LINE =
'Range("a1:a1").Value = "Net Profits for last few months.
"'. APPEND macrofile. "Bold heading at top of sheet.
MACROFILE-LINE = 'Range("A2:B7").Select'. APPEND macrofile.
MACROFILE-LINE = 'charts.add'. APPEND MACROFILE.
MACROFILE-LINE = 'activechart.charttype = xllinemarkersStacked
'. APPEND macrofile.
MACROFILE-LINE =
'Activechart.setsourcedata source:=sheets("Sheet1").range("A2:B7") ,
PLOTBY:= XLROWS'. APPEND macrofile.
MACROFILE-LINE = 'activechart.location where:=xllocationasobject, name:=
"sheet1"'.  APPEND macrofile.
MACROFILE-LINE = 'With ActiveChart'. APPEND MACROFILE.
MACROFILE-LINE = '.hasLegend = false '. APPEND MACROFILE.
MACROFILE-LINE = ' .Axes(xlValue, xlPrimary).HasTitle = True'.
APPEND MACROFILE.
MACROFILE-LINE = '.axes(xlvalue, xlprimary).axistitle.characters.text =
"Net Profit ($)"'.
APPEND MACROFILE.
MACROFILE-LINE = 'End With'. APPEND MACROFILE.
MACROFILE-LINE = 'msgbox ("Chart completed!")'. APPEND macrofile.
MACROFILE-LINE = 'end sub                         '. APPEND MACROFILE.
*******************vb source code end********************************
***********create file with visual basic source code *******************
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = 'c:\VBsource.tmp'    "directory with temporary file
FILETYPE = 'ASC'
TABLES
DATA_TAB = MACROFILE
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
OTHERS = 8.
**********create file with visual basic source code end**************
**write info to screen (ABAP)
LOOP AT NO_TABLE.
WRITE: / SY-VLINE NO-GAP,
NO_TABLE-MONTH COLOR COL_KEY NO-GAP, SY-VLINE NO-GAP,
NO_TABLE-PROFIT COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP.
ENDLOOP.
ULINE (61).
**********************START THE EXCEL APPLICATION*********************
CREATE OBJECT H_EXCEL 'EXCEL.APPLICATION'. "type of application
PERFORM CHECK_ERRORS.
SET PROPERTY OF H_EXCEL 'Visible' = 1.
PERFORM CHECK_ERRORS.
CALL METHOD OF H_EXCEL 'Workbooks' = WORKBOOKS.
PERFORM CHECK_ERRORS.
create a new workbook
CALL METHOD OF WORKBOOKS 'Add' = THIS_WORKBOOK.
PERFORM CHECK_ERRORS.
***********fill the Excel table with data*****************************
PERFORM FILL_EXC_TAB USING 1 1 1 'Profits:'(001). "initial heading
LOOP AT NO_TABLE.
H = SY-TABIX + 1.
PERFORM FILL_EXC_TAB USING H 1 0 NO_TABLE-MONTH.
ENDLOOP.
LOOP AT NO_TABLE.
H = SY-TABIX + 1.
PERFORM FILL_EXC_TAB USING H 2 0 NO_TABLE-PROFIT.
ENDLOOP.
***********fill the Excel table with data end*************************
************DRAW the CHART using the values exported *******************
  CALL METHOD OF H_EXCEL 'Modules' = MODULE.
  PERFORM CHECK_ERRORS.
   CALL METHOD OF MODULE 'Add' = NEWMODULE. " the macro
   PERFORM CHECK_ERRORS.
    CALL METHOD OF NEWMODULE 'Activate'.
    PERFORM CHECK_ERRORS.
get source code from temporary file
CALL METHOD OF NEWMODULE 'InsertFile' EXPORTING #1 = 'C:\VBsource.tmp'.
PERFORM CHECK_ERRORS.
executing VBA program code -> macro name = "draw_graph"
CALL METHOD OF H_EXCEL 'Run' EXPORTING #1 = 'draw_graph'.
PERFORM CHECK_ERRORS.
FREE OBJECT H_EXCEL. "free up memory
PERFORM CHECK_ERRORS.
FORM FILL_EXC_TAB USING I J BOLD VAL.
CALL METHOD OF H_EXCEL 'Cells' = CELL EXPORTING #1 = I #2 = J.
PERFORM CHECK_ERRORS.
SET PROPERTY OF CELL 'Value' = VAL .
PERFORM CHECK_ERRORS.
GET PROPERTY OF CELL 'Font' = BOOK_FONT.
PERFORM CHECK_ERRORS.
SET PROPERTY OF BOOK_FONT 'Bold' = BOLD .
PERFORM CHECK_ERRORS.
ENDFORM.
error handling subroutine
FORM CHECK_ERRORS.
IF SY-SUBRC NE 0.
WRITE: / 'OLE error:'(010), SY-SUBRC.
STOP.
ENDIF.
ENDFORM.

Similar Messages

  • Xy graph in excel using activeX

    Hi
    I am trying to plot a XY graph in excel using Active X. I have two coloums of data one should be X the other should be Y. I am using XlXYscattersmooth graph type and giving the range as A1 to B5. But when the excel plots it, I am getting two series rather of X data points rather than XY. I know I am doing a simple mistake in choosing some variable but I am not able to figure out where I am going wrong.
    Can anybody please look at my code and correct the code in order to get a XY plot rather than getting two different series.
    Thanking you in advance
    Nitin
    Attachments:
    excel4.vi ‏155 KB

    Hello
    Here is that Set Cell Value with Range.vi
    Regards,
    Nitin
    Attachments:
    Set Cell Value with Range.vi ‏45 KB

  • Creating Excel Using OLE through ABAP

    Hi Experts,
    Can anyone help me in running an abap program to give an Excel file using OLE..
    Regards,
    Seshadri

    Hi Seshadri,
          Here is ur expected coding...
    REPORT ZCREATEEXCEL.
    TYPE-POOLS OLE2.
    DATA: EXCEL     TYPE OLE2_OBJECT,
          WORKBOOKS TYPE OLE2_OBJECT,
          WORKBOOK  TYPE OLE2_OBJECT.
    DATA: FILENAME LIKE RLGRAP-FILENAME.
    START THE EXCEL APPLICATION
      CREATE OBJECT EXCEL 'EXCEL.APPLICATION'.
      PERFORM ERR_HDL.
    PUT EXCEL IN FRONT
      SET PROPERTY OF EXCEL  'VISIBLE' = 1.
      PERFORM ERR_HDL.
    INFORM USER OF THE CURRENT STATUS
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
           EXPORTING
                PERCENTAGE = 0
                TEXT       = TEXT-I08
           EXCEPTIONS
                OTHERS     = 1.
    CREATE AN EXCEL WORKBOOK OBJECT
      CALL METHOD OF EXCEL 'WORKBOOKS' = WORKBOOKS.
      PERFORM ERR_HDL.
      CALL METHOD OF WORKBOOKS 'ADD' = WORKBOOK.
      PERFORM ERR_HDL.
    EXCEL FILENAME
      CONCATENATE SY-REPID '_' SY-DATUM6(2) '_' SY-DATUM4(2) '_'
                  SY-DATUM(4) '_' SY-UZEIT '.XLS' INTO FILENAME.
      CALL METHOD OF WORKBOOK 'SAVEAS' EXPORTING #1 = FILENAME.
      FORM ERR_HDL.
      IF SY-SUBRC <> 0.
        WRITE: / 'OLE ERROR: RETURN CODE ='(I10), SY-SUBRC.
        STOP.
      ENDIF.
    ENDFORM.
    hope it helps..

  • Complicated graph on Excel using Labview

    Hello All
    1. I am trying to plot some complicated graphs from some csv data file. I have been able to do this in excel using chart wizard. However, I want to automate this process using Labview. I am stuck at trying to plot a excel graph with primary and secondary Y-axis.I am attaching the project file and the relevant Vi. I am also attaching a same excel sheet which shows the finished version of the graph. 
    2. I am also having trouble with formating the graph to make it similar to that obtained from excel.Specifically
    (a) How do I place the legends at the bottom of the screen
    (b) Also, how do to turn values on X-axis by 90 degrees and also display all discrete values instead of every 3rd or every 4th data point.
    Vi - MOS_FUT_Display1_Attempt4.vi
    data file in csv format - MOS_Scores_Generic_Overall_27Oct09.csv
    original excel along with reference output formatting - MOS_Scores_Generic_Overall_27Oct09.xls
    It is notnecessary for me to use excel to get my output, if I can use any other functions or vi to get the desired results, I am Ok with it.
    Thanks a lot for your help.
    Venkat
    Solved!
    Go to Solution.
    Attachments:
    MOS_FUT_automation.zip ‏61 KB

    Hi, i saw ur comments with an attachment,
    I'm not sure if this is the way you need to get to your outcome, but here is one solution.
    Attachments:
    MOS_FUT_automation.zip 32 KB
    and i was wondering do u still have it? and can you change it the 8.5? as im using labview 8.5
    if not could you take screen shot from me.
    Im quite interested in your program on how u create MOS_Scores_Generic_Overall_27Oct09.xls

  • Color on excel using ole

    Hi!
    i want to color(yellow) the last line of an excel.
    here is a part of the code :
      DESCRIBE TABLE excel_2 LINES w_lines.
    CREATE OBJECT application 'excel.application'.
      SET PROPERTY OF application 'visible' = 1.
      CALL METHOD OF application 'Workbooks' = workbook.
      CALL METHOD OF workbook 'Open'
        EXPORTING
          #1 = pa_file.
      CALL METHOD OF application 'Worksheets' = sheet
        EXPORTING
          #1 = 1.
      SET PROPERTY OF sheet 'Name' = 'Employee Performance'.
      CALL METHOD OF sheet 'Activate'.
      DATA: w_test TYPE string.
      DATA: w_test_lines TYPE string.
      w_test_lines = w_lines.
      CONCATENATE 'A' w_test_lines INTO w_test.
      CONCATENATE w_test ':Z' w_test_lines  INTO w_test.
      CONDENSE w_test NO-GAPS.
    *CALL METHOD OF application 'RANGE' = gs_range
    *    EXPORTING
    *      #1 = 'w_test'.
    * SET PROPERTY OF gs_range 'HORIZONTALALIGNMENT' = 1.
    *  CALL METHOD OF gs_range 'FONT' = gs_font.
    *  SET PROPERTY OF gs_font 'BOLD' = 1.
      CALL METHOD OF application 'RANGE' = gs_range
        EXPORTING
          #1 = 'A1:Z1'.
      SET PROPERTY OF gs_range 'HORIZONTALALIGNMENT' = 1.
      CALL METHOD OF gs_range 'FONT' = gs_font.
      SET PROPERTY OF gs_font 'BOLD' = 1.
      CALL METHOD OF application 'Columns' = h_columns
        EXPORTING
          #1 = 'A:Z'.
      GET PROPERTY OF h_columns 'EntireColumn' = h_entirecol.
      SET PROPERTY OF h_entirecol 'Autofit' = 1.
      CALL METHOD OF sheet 'SAVE'   "'Save'
    EXPORTING
      #1 =  pa_file
      #2 = pa_file."filename
      "fileFormat

    Check out this code
    handles for OLE objects
    DATA: H_EXCEL TYPE OLE2_OBJECT,        " Excel object
          H_MAPL TYPE OLE2_OBJECT,         " list of workbooks
          H_MAP TYPE OLE2_OBJECT,          " workbook
          H_ZL TYPE OLE2_OBJECT,           " cell
          H_F TYPE OLE2_OBJECT.            " font
    TABLES: SPFLI.
    DATA  H TYPE I.
    table of flights
    DATA: IT_SPFLI LIKE SPFLI OCCURS 10 WITH HEADER LINE.
    *&   Event START-OF-SELECTION
    START-OF-SELECTION.
    read flights
      SELECT * FROM SPFLI INTO TABLE IT_SPFLI UP TO 10 ROWS.
    display header
      ULINE (61).
      WRITE: /     SY-VLINE NO-GAP,
              (3)  'Flg'(001) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (4)  'Nr'(002) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (20) 'Von'(003) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (20) 'Nach'(004) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (8)  'Zeit'(005) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP.
      ULINE /(61).
    display flights
      LOOP AT IT_SPFLI.
      WRITE: / SY-VLINE NO-GAP,
               IT_SPFLI-CARRID COLOR COL_KEY NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CONNID COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CITYFROM COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CITYTO COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-DEPTIME COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP.
      ENDLOOP.
      ULINE /(61).
    tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-007
           EXCEPTIONS
                OTHERS     = 1.
    start Excel
      CREATE OBJECT H_EXCEL 'EXCEL.APPLICATION'.
    PERFORM ERR_HDL.
      SET PROPERTY OF H_EXCEL  'Visible' = 1.
    CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'c:\kis_excel.xls'
    PERFORM ERR_HDL.
    tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-008
           EXCEPTIONS
                OTHERS     = 1.
    get list of workbooks, initially empty
      CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
      PERFORM ERR_HDL.
    add a new workbook
      CALL METHOD OF H_MAPL 'Add' = H_MAP.
      PERFORM ERR_HDL.
    tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-009
           EXCEPTIONS
                OTHERS     = 1.
    output column headings to active Excel sheet
      PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
      PERFORM FILL_CELL USING 1 2 0 '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).
      LOOP AT IT_SPFLI.
    copy flights to active EXCEL sheet
        H = SY-TABIX + 1.
        PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
        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.
    changes by Kishore  - start
    CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
      CALL METHOD OF H_EXCEL 'Worksheets' = H_MAPL." EXPORTING #1 = 2.
      PERFORM ERR_HDL.
    add a new workbook
      CALL METHOD OF H_MAPL 'Add' = H_MAP  EXPORTING #1 = 2.
      PERFORM ERR_HDL.
    tell user what is going on
      SET PROPERTY OF H_MAP 'NAME' = 'COPY'.
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-009
           EXCEPTIONS
                OTHERS     = 1.
    output column headings to active Excel sheet
      PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
      PERFORM FILL_CELL USING 1 2 0 '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).
      LOOP AT IT_SPFLI.
    copy flights to active EXCEL sheet
        H = SY-TABIX + 1.
        PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
        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.
    changes by Kishore  - end
    disconnect from Excel
         CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING  #1 = 'C:\SKV.XLS'.
      FREE OBJECT H_EXCEL.
      PERFORM ERR_HDL.
          FORM FILL_CELL                                                *
          sets cell at coordinates i,j to value val boldtype bold       *
    FORM FILL_CELL USING I J BOLD VAL.
      CALL METHOD OF H_EXCEL 'Cells' = H_ZL EXPORTING #1 = I #2 = J.
      PERFORM ERR_HDL.
      SET PROPERTY OF H_ZL 'Value' = VAL .
      PERFORM ERR_HDL.
      GET PROPERTY OF H_ZL 'Font' = H_F.
      PERFORM ERR_HDL.
      SET PROPERTY OF H_F 'Bold' = BOLD .
      PERFORM ERR_HDL.
    ENDFORM.
    *&      Form  ERR_HDL
          outputs OLE error if any                                       *
    -->  p1        text
    <--  p2        text
    FORM ERR_HDL.
    IF SY-SUBRC <> 0.
      WRITE: / 'Fehler bei OLE-Automation:'(010), SY-SUBRC.
      STOP.
    ENDIF.
    ENDFORM.                    " ERR_HDL

  • How to output a logo stored as standard text to excel using OLE

    Hi Experts,
    I have a requirement to write a program which creates an excel spreadsheet to download data from SAP.  The client would like the spreadsheet formatted with merged cells, background colours, different size fonts and in the top left corner of the spreadsheet to show their logo. 
    They have similar functionality in another report, however, this requires a template (containing all of the formatting) to be stored on the user's PC.  They do not want to have to do this with the new download.
    After checking the many postings on this forum I have worked out how to do most of the requirements, but as yet have still not been able to work out how to populate their logo to the spreadsheet.  They already have their logo stored as standard text (SO10), so would prefer to use this if possible.
    Any advise and/or sample code would ge greatly appreciated.
    Thanks
    Sandra

    Hi Surendra,
    We have the same requirement. We want to do some format changes to "Generic FSG Drill Template". I am able to do few changes. But when we run the report, we are able to see PDF, html output. But 'Exce' report comes with blank. Can you help on this. How were you able to see logo in excel file.
    Can you send the suggestions if any to my mail ([email protected])
    Thanks in advance.
    Thanks,
    Techie.
    Edited by: user1138068 on May 30, 2011 7:04 AM

  • Reports Generation in Microsoft Excel using Forms Server

    How can I generate reports in Microsoft Excel from an web-enabled forms application, as using Dynamic Data Exchange invokes Excel on the Application Server? My work-around was to generate the file on the application server, save it ,exit the Excel application and then display the excel document using Web.Show_Document. Though this method is successful, the processing time is very high.
    null

    Use text_io package of developer to write records to excel using OLE
    Thanks
    null

  • To upload excel file directly to the application server using OLE concept

    hi experts
    i have done a coding in OLE to download excel with graph to presentation server, is it possible to upload excel with graph directly to the application server  , the excel should have graph while downloading to presentation server fom app server.
    Moderator message - duplicate post locked
    Edited by: Rob Burbank on Jun 25, 2009 9:49 AM

    HI,
    have a look at tcode cg3z and then FM 'C13Z_FILE_UPLOAD_ASCII'.
    What you can do is, first create the file on presentation server using OLE automation, and then using this FM, write the file to Application server

  • ALV download to Excel onto desktop using OLE concept.

    Hi Experts,
    I requriement is , through my se38 program i need to download report output to excel.
    i did this using OLE concepts code and excel is being downloaded good.
    But problem is all columns data is dumped into First column. But in my ALV i have 20 columns. So i except data in excel sheet to be in 20 columns.
    Below is the OLE code i used
    CREATE OBJECT wa_excel 'EXCEL.APPLICATION'. "Create object for Excel
      SET PROPERTY OF wa_excel  'VISIBLE' = 1. "In background Mode
      CALL METHOD OF wa_excel 'WORKBOOKS' = w_workbook.
      CALL METHOD OF w_workbook 'ADD'. "Create a new Workbook
      SET PROPERTY OF wa_excel 'SheetsInNewWorkbook' = 3. "No of sheets
    * Downloading header details to first sheet
      PERFORM download_sheet TABLES i_final USING 1 'Master Material Details'.
      GET PROPERTY OF wa_excel 'ActiveSheet' = w_worksheet.
    * Protect the first worksheet with a password
      CALL METHOD OF w_worksheet 'PROTECT
        EXPORTING #1 = 'infy@123'.
    * Save the Excel file
      GET PROPERTY OF wa_excel 'ActiveWorkbook' = w_workbook.
      CALL METHOD OF w_workbook 'SAVEAS'
        EXPORTING #1 = p_infile.
      FREE OBJECT: w_worksheet, wa_excel.
    FORM download_sheet TABLES p_tab  USING p_sheet TYPE i   p_name  TYPE string.
      CALL METHOD OF wa_excel 'WORKSHEETS' = w_worksheet
        EXPORTING
        #1 = p_sheet.
      CALL METHOD OF w_worksheet 'ACTIVATE'.
      SET PROPERTY OF w_worksheet 'NAME' = p_name.
      CALL METHOD OF wa_excel 'Range' = w_range
        EXPORTING
        #1 = 'A1'
        #2 = 'D1'.
      CALL METHOD OF w_range 'INTERIOR' = w_int.
      SET PROPERTY OF w_int 'ColorIndex' = 6.
      SET PROPERTY OF w_int 'Pattern' = 1.
    * Initially unlock all the columns( by default all the columns are locked )
      CALL METHOD OF wa_excel 'Columns' = w_columns.
      SET PROPERTY OF w_columns 'Locked' = 0.
    * Locking and formatting first column
      CALL METHOD OF wa_excel 'Columns' = w_columns
       EXPORTING
       #1 = 1.
    * Locking and formatting second column
      CALL METHOD OF wa_excel 'Columns' = w_columns
        EXPORTING
        #2 = 2.
      SET PROPERTY OF w_columns  'Locked' = 2.
      SET PROPERTY OF w_columns  'NumberFormat' = '@'.
    * Export the contents in the internal table to the clipboard
      CALL METHOD cl_gui_frontend_services=>clipboard_export
        IMPORTING
          data                 = p_tab[]
        CHANGING
          rc                   = w_rc
        EXCEPTIONS
          cntl_error           = 1
          error_no_gui         = 2
          not_supported_by_gui = 3
          OTHERS               = 4.
    * Paste the contents in the clipboard to the worksheet
      CALL METHOD OF w_worksheet 'Paste'.
    * Autofit the columns according to the contents
      CALL METHOD OF wa_excel 'Columns' = w_columns.
      CALL METHOD OF w_columns 'AutoFit'.
      FREE OBJECT: w_columns, w_range.
    Please help me if there is any SET Property of WA_EXCEL with which i can handle ALV data into Diffrenet columns.
    Regards,
    jayant.

    hi nabheet,
    we have implemnted this logic and it is workign fine. Bit it takes long time to download data in Excel sheet. Actually it is happening feild by field.
    Please advice any perfomance tuning to this logic.
    Rgs,
    jayant

  • Data download to multiple sheets in Excel without using OLE

    Hi,
    Please let me know if it is possible to download data to multiple sheets in excel without using OLE method
    I am in SRM system and the OLE methods are not working
    Please share some sample code or reference links if any
    Thanks
    SekharJ
    Edited by: SekharJ on Sep 8, 2009 8:43 AM

    Here is my code
      LOOP AT it_final INTO wa_final.
        AT FIRST.
          l_ixml = cl_ixml=>create( ).
          l_document = l_ixml->create_document( ).
          l_element_flights  = l_document->create_simple_element(
                      name = 'PO_Details'
                      parent = l_document ).
        ENDAT.
        l_element_airline  = l_document->create_simple_element(
                    name = 'PO'
                    parent = l_element_flights  ).
        l_value = wa_final-object_id.
        l_rc = l_element_airline->set_attribute( name = 'Objectid' value =
                                                             l_value ).
        l_value = wa_final-description.
        l_rc = l_element_airline->set_attribute( name = 'Description' value =
                                                             l_value ).
        l_value = wa_final-number_int.
        l_rc = l_element_airline->set_attribute( name = 'Item' value =
                                                             l_value ).
        l_value = wa_final-description1.
        l_rc = l_element_airline->set_attribute( name = 'Description1' value =
                                                             l_value ).
        l_value = wa_final-quantity.
        l_rc = l_element_airline->set_attribute( name = 'Quantity' value =
                                                             l_value ).
        l_value = wa_final-capex.
        l_rc = l_element_airline->set_attribute( name = 'Capex' value =
                                                             l_value ).
        l_value = wa_final-ser_num.
        l_rc = l_element_airline->set_attribute( name = 'SerialNo' value =
                                                             l_value ).
        l_value = wa_final-plant.
        l_rc = l_element_airline->set_attribute( name = 'Plant' value =
                                                             l_value ).
        l_value = wa_final-loc.
        l_rc = l_element_airline->set_attribute( name = 'Location' value =
                                                             l_value ).
        l_value = wa_final-bundle.
        l_rc = l_element_airline->set_attribute( name = 'Bundle' value =
                                                             l_value ).
      ENDLOOP.
      l_streamfactory = l_ixml->create_stream_factory( ).
      l_ostream = l_streamfactory->create_ostream_itable( table =
    l_xml_table ).
      l_renderer = l_ixml->create_renderer( ostream  = l_ostream
                                            document = l_document ).
      l_rc = l_renderer->render( ).
      l_xml_size = l_ostream->get_num_written_raw( ).
        CALL METHOD cl_gui_frontend_services=>gui_download
          EXPORTING
            bin_filesize = l_xml_size
            filename     = 'c:\temp\flights.xlsx'
            filetype     = 'BIN'
          CHANGING
            data_tab     = l_xml_table
          EXCEPTIONS
            OTHERS       = 24.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    Edited by: SekharJ on Sep 8, 2009 12:04 PM
    Edited by: SekharJ on Sep 8, 2009 12:15 PM

  • I have a problem in formatting cells in Excel while using OLE method.

    Hi All,
    I have a problem in formatting cells in Excel while using OLE method.
    My requirement is to have certain fields of a cell as text and amount fields should be in number format.
    How to format a cell in Excel in OLE method of downloading data to excel.
    For example I have plant field whose value is 0002 in internal table while coming to excel it is showing as 2 .
    I want that field to be shown as 0002.(text format)
    Material field whose value in internal table is 000000000000000051 is shown as 51 which has to be shown as
    000000000000000051.(text format).
    Amount field should be in number format so that totalling is possible .
    So I need some cells in text format and some in number format.
    Please suggest a sloution.
    Thanks in advance,
    Regards,
    vidyulatha.U

    https://forums.sdn.sap.com/click.jspa?searchID=21931962&messageID=6852860
    hope this helps.

  • Prevent copy of excel cells using OLE

    Hi All,
    I have protected my excel worksheet. But the cells can be copied. I want to prevent this copy of cells using OLE.
    I have gone through the EXCEL proerties. But dont know how to exact use them?
    Thanks in Advance
    -neha

    Hello Neha,
    I don't think CutCopyMode is the correct answer
    Try the below code. It prevents the selection of cells, hence preventing copying.
    REPORT  zkris_ole_protectsheet.
    *                  Start of Selection                                  *
    START-OF-SELECTION.
      TYPE-POOLS ole2 .
      DATA:
             workbook TYPE ole2_object,
             excel     TYPE ole2_object,
             sheet TYPE ole2_object,
             cells 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.
    * naming and activating the index sheet
      SET PROPERTY OF sheet 'NAME' = 'Index'.
      CALL METHOD OF sheet 'ACTIVATE'.
      CALL METHOD OF sheet 'Cells' = cells
        EXPORTING
        #1 = 3
        #2 = 3.
      SET PROPERTY OF cells 'Value' = 'You cannot select me'.
      CALL METHOD OF sheet 'PROTECT'
        EXPORTING
          #1 = 'pass' " Password
          #2 = 1 " Protect Drawing Objects
          #3 = 1 " Protect Contents
          #4 = 1." Protect Scenarios
      SET PROPERTY OF sheet 'EnableSelection' = -4142.

  • Excel output Left justified using OLE

    Hi,
    Can anyone please let me know how to align all the cells in the excel sheet as LEFT JUSTIFIED using OLE? I have few numeric values and by default it will be on the right side, i want to make it left justified.
    Edited by: Pradeep Kumar on Jan 19, 2011 1:36 PM

    Its obvoius that you will always find numeric values of right aligned.
    I had faced a similar kind of issue while downloading PSTLZ  US Postal Codes. You can try this way:
    Place a apostrophe to the field you need to be left aligned
    ' ' ' '           " This  defines your apostrophe
    You can check this in excel. Just place a equal sign and apostrophe infront of the value and press enter. The value will be left aligned.
    Try the same thing in your code.
    It was a very old change for me. Trying to get some sample code snippet for referance.
    Here it goes:
    CONSTANTS: c_prefix VALUE '='.
        CONSTANTS: c1_prefix VALUE ' " '.
        CONCATENATE  c_prefix
                   c1_prefix
                   i_lfa1-pstlz
                   INTO i_lfa1-pstlz
    ~ Last edited for adding the code snippet
    Edited by: K.Manas on Jan 19, 2011 9:35 AM

  • Is it possible to create Excel Sheet using OLE automation in App server

    Hi,
       Is it possible to create Excel Sheet using OLE automation in Application server(Open Dataset)
    Thanks in advance...

    Unless your application server is on Windows OS, or it is connected to a Windows server by RFC. What is the requirement exactly, I don't understand?

  • Excel from abap using OLE, trying to make an excel cell-property currency

    Hello everyone,
    I have build an abap application which generates a price list as a MS Excel file using OLE techniques (ole2incl).
    One small thing in the excel file is lacking and I hope some one can help me out:
    I want to give certain cells in excel the "cell property - currency", so that excel shows the amounts as currency values. 
    Has anyone done or seen that before?
    Thanks a lot in advance.
    Kind regard, Archie Oomen

    Hi,
    I am having a similiar problem trying to fix the CELL format as TEXT.
    No matter how I try, it often ends up as 'GENERAL.
    Have you resolved your issue?
    Prehaps, you could share it if you had already rectify your problem.
    Thanks a lot

Maybe you are looking for

  • What are the pros and cons of storing heavely used CFCs in the application scope?

    I've been storing all the required CFCs for a site in the application scope. During onApplicationStart I do something like this application.objSomeCfc =CreateObject('component', 'com.someCfc').init(). Here is my reasoning. Get the CFCs initialized on

  • WebDynpro ABAP applicaiton theme editing using NWDS

    Dear SDNs, Can we edit WebDynpro ABAP themes using NWDS? or do i need to install Elcipse again. If it is possible using NWDS, what are the prerequisites. Where can i get Theme editior plugin to NWDS and guide me on how to add. I have already a knowle

  • [solved] pm-utils, how to run a script as logged-in user AFTER resume

    All the scripts in /etc/pm/sleep.d are run as root. Is there any way for me to put a script such that it runs as my logged-in user AFTER all the scripts in /etc/pm/sleep.d. I tried putting su -c "command" - <username> but that doesn't have the full u

  • Currency Format in chart

    Hi, I have displayed bar chart in pdf. The chart is currently displaying chart data like 1,757.25. I want to change it to dutch format like 1.757,25 and also a euro symbol should be added as a prefix. Can this be done by modifying the alt text of the

  • Windows Server 2008 R2 Slow LAN Transfer (Receive)

    Using Windows 7 Ultimate and Windows Server 2008 R2 Two machines, connected via 1GB 1000base-T LAN, with a 1Gb switch between... and yes, I've tried swapping cables and ports. Server has two RAID5's, a 6 platter and an 8 platter. Workstation has two