Write to excel using Range function - Excel_write_range.vi

I am using the write using range Excel function to dump some data into Excel.
My data is an array consisting of decimal numbers (data type double) but I have to use "Number To Fractional String" before I can dump this array into Excel. And then when I open the output excel file, you have all these warnings for each cell saying, "number displayed as string". Is there a way to instead dump numbers (in format double) into the Excel. That way each cell in the excel output file will already be formatted as a number instead of string.
Thanks in advance.

I'm assuming you're actually using ActiveX to write out Excel files. I say this because a lot of people say "Excel files" when they're really talking about spreadsheet-formatted files, generated using the Write to Spreadsheet File VI. That said, the "Value" ("Value 2" in newer versions of Excel) is a variant, so you can wire any datatype to it. Just wire the numeric value directly.

Similar Messages

  • Not able to write to Excel using Client_OLE2 and webutil

    Hi
    I am working on Windows 2000 Pro SP4 Oracle Forms Builder 10.1.2.0.2
    I am using webutil to invoke Excel Application .
    The following code invokes Excel application and saves in the path specified as Test_Excel and writes the "Test Data to be written" to R1C1 when I use OLE2.
    But when I replace OLE2 with Client_OLE2 the Excel file is getting created but the data is not written to the cell.
    PL/SQL :could not find program unit being called is the error.
    Can anybody help me solve this issue ?
    Thanks in advance.
    FUNCTION WRITE_TO_EXCEL(
    excel_file_name in varchar2, ---for eg.. C:\Test_Excel.xls
    buf in varchar2 ) ----Test Data to be written
    return boolean is
    application CLIENT_OLE2.OBJ_TYPE;
    workbooks CLIENT_OLE2.OBJ_TYPE;
    workbook CLIENT_OLE2.OBJ_TYPE;
    worksheets CLIENT_OLE2.OBJ_TYPE;
    worksheet CLIENT_OLE2.OBJ_TYPE;
    cell CLIENT_OLE2.OBJ_TYPE;
    args CLIENT_OLE2.LIST_TYPE;
    begin
    application := CLIENT_OLE2.CREATE_OBJ ('Excel.Application');
    CLIENT_OLE2.SET_PROPERTY(application, 'Visible', 'True');
    workbooks := CLIENT_OLE2.GET_OBJ_PROPERTY(application, 'Workbooks');
    workbook := CLIENT_OLE2.Invoke_Obj(workbooks, 'Add');
    worksheets := CLIENT_OLE2.Get_Obj_Property(workbook, 'Worksheets');
    worksheet := CLIENT_OLE2.Invoke_Obj(worksheets,'Add');
    args:=CLIENT_OLE2.create_arglist;
    CLIENT_OLE2.add_arg(args,1);
    CLIENT_OLE2.add_arg(args,1);
    cell:=CLIENT_OLE2.get_obj_property(worksheet, 'Cells', args);
    CLIENT_OLE2.destroy_arglist(args);
    CLIENT_OLE2.set_property(cell,'Value', buf);
    CLIENT_OLE2.release_obj(cell);
    CLIENT_OLE2.Release_Obj(worksheet);
    CLIENT_OLE2.Release_Obj(worksheets);
    args := CLIENT_OLE2.Create_Arglist;
    CLIENT_OLE2.Add_Arg(args,excel_file_name);
    CLIENT_OLE2.Invoke(workbook, 'SaveAs', args);
    CLIENT_OLE2.Destroy_Arglist(args);
    args := CLIENT_OLE2.CREATE_ARGLIST;
    CLIENT_OLE2.ADD_ARG(args,'Caption');
    CLIENT_OLE2.INVOKE(application,'Run',args);
    CLIENT_OLE2.destroy_arglist(args);
    CLIENT_OLE2.Release_Obj(workbook);
    CLIENT_OLE2.Release_Obj(workbooks);
    CLIENT_OLE2.Invoke(application, 'Quit');
    CLIENT_OLE2.Release_Obj(application);
    return(TRUE);
    exception
    when others then
    message (error_type||'-'||error_code||':'||error_text);
    message (' ');
    SET_APPLICATION_PROPERTY(CURSOR_STYLE,'default');
    CLIENT_OLE2.RELEASE_OBJ(application);
    CLIENT_OLE2.RELEASE_OBJ(workbooks);
    CLIENT_OLE2.RELEASE_OBJ(workbook);
    CLIENT_OLE2.release_obj(worksheet);
    CLIENT_OLE2.release_obj(worksheets);
    return(FALSE);
    END;

    What line is actually causing the error? Also, I assume you tested the exact same code which works when using straight OLE2 (and not the webutil client_ version)?
    Regards
    Grant Ronald
    Oracle Product Management

  • Creating a table in Excel using ActiveX functions

    Hi,
    I am new to labview and have have a project where i need to create tables in labview using activeX, i cannot seem to get the Invoke node Table (under range) to work, any help would be much appreciated.

    This question is not related to LV at all. So in general, this question is more for MSDN (Microsoft Developer Network).
    That being said, here the steps you have to implement in LV:
    Open Automation Server Excel._Application
    Set property Visible to true (otherwise, you won't see the result unless you save the workbook)
    Create a Workbool
    In the Workbook, create a Worksheet (that's what you call a "table")
    That's it.
    Norbert
    PS: Due to "reference lifetime", you want to keep the VI running (e.g. event based waiting for a button press) otherwise Excel will shutdown as soon as you release the reference to Excel._Application.

  • Help to write using anlytical functions or singe count instead of many

    HI,
    Could you some one help to write as single count instead of many (.Or) Is there any way to write below query using analytical functions?
    SELECT paper_code,paper_code_description, numCandidates, cast(numAwaitingApproval as varchar2(10)) as numAwaitingApproval, (numawaitingtrans + numawaitingibtran) as numAwaitingSubmission, (numibsub + numsub) as numSubmittedForMarking
           FROM(
             SELECT e.paper_code,
      translate_paper(e.paper_code,:v_year,:v_month,:v_iblanguage,:v_paper_type) AS paper_code_description,
      COUNT(e.candidate)                                                     AS numcandidates,
      COUNT(DECODE(status, 'AWAITING AUTHENTICATION',1))                     AS numAwaitingApproval,
      COUNT(DECODE(status, 'AWAITING TRANSFER',1))                           AS numawaitingtrans,
      COUNT(DECODE(status, 'AWAITING IB TRANSFER',1))                        AS numawaitingibtran,
      COUNT(DECODE(status, 'SUBMITTED',1))                                   AS numsub,
      COUNT(DECODE(status, 'IB SUBMITTED',1))                                AS numibsub
    FROM e_assessment_cands e,
      candidate_component_reg ccr,
      person_subject_session pss
    WHERE e.year                = :v_year
    AND e.month                 = :v_month
    AND e.e_coursework          = :v_e_coursework
    AND e.school_code           = :v_school_code
    AND ccr.split_session_year  = e.year
    AND ccr.split_session_month = e.month
    AND ccr.candidate           = e.candidate
    AND ccr.paper_code          = e.paper_code
    AND ccr.subject             =:v_subject
    AND ccr.subject_option      =COALESCE(:v_subject_option,ccr.subject_option)
    AND ccr.lvl                 =COALESCE(:v_lvl,ccr.lvl)
    AND ccr.language            =COALESCE(:v_language,ccr.language)
    AND ccr.component           =COALESCE(:v_component,ccr.component)
    AND pss.year                = ccr.split_session_year
    AND pss.month               = ccr.split_session_month
    AND pss.subject             = ccr.subject
    AND pss.lvl                 = ccr.lvl
    AND pss.subject_option      = ccr.subject_option
    AND pss.language            = ccr.language
    AND pss.role                = :v_role
    AND pss.person_code         = :v_person_code
    GROUP BY e.paper_code)

    Hi,
    user575115 wrote:
    HI,
    Could you some one help to write as single count instead of many (.Or) If you're using Oracle 11, look at SELECT ... PIVOT.
    If you'd like help. post CREATE TABLE and INSERT statements for some sample data, and the results you want from that data.
    Always say which version of Oracle you're using.
    Given that you need numCnadidates and numAwaitingApproval, using COUNT twice seems to be the simplest and most efficient way to do it.
    If you don't need the other COUNTs, such as numawaitingtrans, then don't compute them.
    Is there any way to write below query using analytical functions?Analytic functions can give you a COUNT without reducing the result set to one row per group. It lookw like you do want to reduce the result set to one row per group, however, so I don't see how analytic functions would help in this problem.

  • Powershell use Connection String to query Database and write to Excel

    Right now I have a powershell script that uses ODBC to query SQL Server 2008 / 2012 database and write to EXCEL
    $excel = New-Object -Com Excel.Application
    $excel.Visible = $True
    $wb = $Excel.Workbooks.Add()
    $ws = $wb.Worksheets.Item(1)
    $ws.name = "GUP Download Activity"
    $qt = $ws.QueryTables.Add("ODBC;DSN=$DSN;UID=$username;PWD=$password", $ws.Range("A1"), $SQL_Statement)
    if ($qt.Refresh()){
    $ws.Activate()
    $ws.Select()
    $excel.Rows.Item(1).HorizontalAlignment = $xlCenter
    $excel.Rows.Item(1).VerticalAlignment = $xlTop
    $excel.Rows.Item("1:1").Font.Name = "Calibri"
    $excel.Rows.Item("1:1").Font.Size = 11
    $excel.Rows.Item("1:1").Font.Bold = $true
    $filename = "D:\Script\Reports\Status_$a.xlsx"
    if (test-path $filename ) { rm $filename }
    $wb.SaveAs($filename, $xlOpenXMLWorkbook) #save as an XML Workbook (xslx)
    $wb.Saved = $True #flag it as being saved
    $wb.Close() #close the document
    $Excel.Quit() #and the instance of Excel
    $wb = $Null #set all variables that point to Excel objects to null
    $ws = $Null #makes sure Excel deflates
    $Excel=$Null #let the air out
    I would like to use connection string to query the database and write results to EXCEL, i.e.
    $SQL_Statement = "SELECT ..."
    $conn = New-Object System.Data.SqlClient.SqlConnection
    $conn.ConnectionString = "Server=10.10.10.10;Initial Catalog=mydatabase;User Id=$username;Password=$password;"
    $conn.Open()
    $cmd = New-Object System.Data.SqlClient.SqlCommand($SQL_Statement,$conn)
    do{
    try{
    $rdr = $cmd.ExecuteReader()
    while ($rdr.read()){
    $sql_output += ,@($rdr.GetValue(0), $rdr.GetValue(1))
    $transactionComplete = $true
    catch{
    $transactionComplete = $false
    }until ($transactionComplete)
    $conn.Close()
    How would I read the columns and data for $sql_output into an EXCEL worksheet. Where do I find these tutorials?

    Hi Q.P.Waverly,
    If you mean to export the data in $sql_output to excel document, please try to format the output with psobject:
    $sql_output=@()
    do{
    try{
    $rdr = $cmd.ExecuteReader()
    while ($rdr.read()){
    $sql_output+=New-Object PSObject -Property @{data1 = $rdr.GetValue(0);data2 =$rdr.GetValue(1)}
    $transactionComplete = $true
    catch{
    $transactionComplete = $false
    }until ($transactionComplete)
    $conn.Close()
    Then please try to use the cmdlet "Export-Csv" to export the data to excel like:
    $sql_output | Export-Csv d:\data.csv
    Or you can export to worksheet like:
    $excel = New-Object -ComObject Excel.Application
    $excel.Visible = $true
    $workbook = $excel.Workbooks.Add()
    $sheet = $workbook.ActiveSheet
    $counter = 0
    $sql_output | ForEach-Object {
    $counter++
    $sheet.cells.Item($counter,1) = $_.data1$sheet.cells.Item($counter,2) = $_.data2}
    Refer to:
    PowerShell and Excel: Fast, Safe, and Reliable
    If there is anything else regarding this issue, please feel free to post back.
    Best Regards,
    Anna Wang

  • How can we write the excel function =Normsdist() in Java?

    Hi,
    I need to use one function in my java program to compute N(z) . In excel the function is =Normsdist(z). Is there any built-in library function for this in Java? How can I accomplish this? Please give me some solutions...
    Thanks.

    I need to use one function in my java program to
    compute N(z) . In excel the function is
    =Normsdist(z). Is there any built-in library
    function for this in Java? No.
    How can I accomplish
    this? Please give me some solutions...
    Thanks.Write your own, or use a 3rd party library.

  • Using analytical function to calculate concurrency between date range

    Folks,
    I'm trying to use analytical functions to come up with a query that gives me the
    concurrency of jobs executing between a date range.
    For example:
    JOB100 - started at 9AM - stopped at 11AM
    JOB200 - started at 10AM - stopped at 3PM
    JOB300 - started at 12PM - stopped at 2PM
    The query would tell me that JOB1 ran with a concurrency of 2 because JOB1 and JOB2
    were running started and finished within the same time. JOB2 ran with the concurrency
    of 3 because all jobs ran within its start and stop time. The output would look like this.
    JOB START STOP CONCURRENCY
    === ==== ==== =========
    100 9AM 11AM 2
    200 10AM 3PM 3
    300 12PM 2PM 2
    I've been looking at this post, and this one if very similar...
    Analytic functions using window date range
    Here is the sample data..
    CREATE TABLE TEST_JOB
    ( jobid NUMBER,
    created_time DATE,
    start_time DATE,
    stop_time DATE
    insert into TEST_JOB values (100, sysdate -1, to_date('05/04/08 09:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 11:00:00','MM/DD/YY hh24:mi:ss'));
    insert into TEST_JOB values (200, sysdate -1, to_date('05/04/08 10:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 13:00:00','MM/DD/YY hh24:mi:ss'));
    insert into TEST_JOB values (300, sysdate -1, to_date('05/04/08 12:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 14:00:00','MM/DD/YY hh24:mi:ss'));
    select * from test_job;
    JOBID|CREATED_TIME |START_TIME |STOP_TIME
    ----------|--------------|--------------|--------------
    100|05/04/08 09:28|05/04/08 09:00|05/04/08 11:00
    200|05/04/08 09:28|05/04/08 10:00|05/04/08 13:00
    300|05/04/08 09:28|05/04/08 12:00|05/04/08 14:00
    Any help with this query would be greatly appreciated.
    thanks.
    -peter

    after some checking the model rule wasn't working exactly as expected.
    I believe it's working right now. I'm posting a self-contained example for completeness sake.I use 2 functions to convert back and forth between epoch unix timestamps, so
    I'll post them here as well.
    Like I said I think this works okay, but any feedback is always appreciated.
    -peter
    CREATE OR REPLACE FUNCTION date_to_epoch(p_dateval IN DATE)
    RETURN NUMBER
    AS
    BEGIN
    return (p_dateval - to_date('01/01/1970','MM/DD/YYYY')) * (24 * 3600);
    END;
    CREATE OR REPLACE FUNCTION epoch_to_date (p_epochval IN NUMBER DEFAULT 0)
    RETURN DATE
    AS
    BEGIN
    return to_date('01/01/1970','MM/DD/YYYY') + (( p_epochval) / (24 * 3600));
    END;
    DROP TABLE TEST_MODEL3 purge;
    CREATE TABLE TEST_MODEL3
    ( jobid NUMBER,
    start_time NUMBER,
    end_time NUMBER);
    insert into TEST_MODEL3
    VALUES (300,date_to_epoch(to_date('05/07/2008 10:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 19:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (200,date_to_epoch(to_date('05/07/2008 09:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 12:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (400,date_to_epoch(to_date('05/07/2008 10:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 14:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (500,date_to_epoch(to_date('05/07/2008 11:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 16:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (600,date_to_epoch(to_date('05/07/2008 15:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 22:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (100,date_to_epoch(to_date('05/07/2008 09:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 23:00','MM/DD/YYYY hh24:mi')));
    commit;
    SELECT jobid,
    epoch_to_date(start_time)start_time,
    epoch_to_date(end_time)end_time,
    n concurrency
    FROM TEST_MODEL3
    MODEL
    DIMENSION BY (start_time,end_time)
    MEASURES (jobid,0 n)
    (n[any,any]=
    count(*)[start_time<= cv(start_time),end_time>=cv(start_time)]+
    count(*)[start_time > cv(start_time) and start_time <= cv(end_time), end_time >= cv(start_time)]
    ORDER BY start_time;
    The results look like this:
    JOBID|START_TIME|END_TIME |CONCURRENCY
    ----------|---------------|--------------|-------------------
    100|05/07/08 09:00|05/07/08 23:00| 6
    200|05/07/08 09:00|05/07/08 12:00| 5
    300|05/07/08 10:00|05/07/08 19:00| 6
    400|05/07/08 10:00|05/07/08 14:00| 5
    500|05/07/08 11:00|05/07/08 16:00| 6
    600|05/07/08 15:00|05/07/08 22:00| 4

  • Using Substitution variables in Range function in FR

    Hi,
    According to one of my report requirement, I want to show current quarter’s weeks till the current week. Just to elaborate more I am able to show current quarters all weeks but unable to show till current week. I had created Current quarters starting week (CurrQtrSW) as a substitution variable and CurrWeek as other substitution variable when I keep these two SV's in Range function it is throwing me error and my report is not running. Can anybody help me in this?
    It is urgent
    Thanks in Adv.

    If you're using the standard 13 week quarters and they are labeled that way, you can just use Week1 as the starting point (as opposed to having weeks 1-52 in your essbase cube).
    Have you restarted essbase/FR Studio since adding the sub vars? It can sometimes require one or both to fully recognize them.
    Hope this helps.
    Cheers, Iain

  • How to use the function EXEC_SQLCMD_MSQ in Excel?

    Hi Friends,
    can anyone explain how to use use this function EXEC_SQLCMD_MSQ in Excel to get the result.
    I have written excel macro to use this function,  statement like "Select * from t001" but the function doesn't reply any value.
    My objective is to pass the (any, generalised)
    sql statment to this function and get the result in Excel file.
    Please give the solution for this.
    Thanks
    Shankar

    Hello Shanker,
    The Fm EXEC_SQLCMD_MSQ is used in report RSMSQ020.
    U can do the same in ur report.
    If useful reward the points.
    Regards,
    Vasanth

  • Write an excel file using File adapter

    Hi,
    I have a scenario in which i have to write an excel file in the target system.
    I tried creating a tab delimited file conversion and just named the file as .xls.
    When i saw the output file it did look like a excel but a report that i have written to read a excel file cant read it.
    The report says 0 records found. It works for other excel sheets that are created manually.
    So will this method noit work for creating excel files?
    Is using the jexcel api the only option for this?

    Have u had a chance to see this excellent blog by shabarish...
    chekc this
    /people/shabarish.vijayakumar/blog/2009/04/05/excel-files--how-to-handle-them-in-sap-xipi-the-alternatives
    http://wiki.sdn.sap.com/wiki/display/XI/CODE-CreateanExcelFileviatheJExcel+API

  • To format an Excel worksheet invoked by oracle form using DDE functions

    I'm exporting data from oracle form6 into excel sheet using DDE functions.
    Is there any DDE functions to format the excel sheet.

    Maybe you can use format commands through DDE (if the DDE server suports them) but I personally don't know.
    My approach is to record an excel macro which formats your sheet and then invoke the macro through DDE. You can fill cells with control numbers (like number of rows, number of cells) so you can make your macro even smarter by reading these numbers.

  • How to write data which i am reading from spectrum in excel using Report Generation toolkit.

    Hello All,
     I wrote code for reading data from Spectrum analyzer and also for writing in excel using report generation toolkit. When i run program values get read and excel sheet opens also but i cant see anything written in it.
    So if anyone can help me in this i will be very gald. I am attaching screenshot of my program and also attaching .vi file. As i am using drivers you can see some of vi.
    Thanking You,
    Pallavi 
    Solved!
    Go to Solution.
    Attachments:
    Channel_Power.jpg ‏123 KB
    Channel Power_Toolkit.vi ‏64 KB

    Hi Palavi,
    you try to select a specific worksheet what is not existing, therefore just select "Channel Power" (and not Power Channel) and it should work for you.
    Regards,
    Tobias

  • Excel value range with Report Generation Toolkit

    I have an excel sheet.  I want to find out the range for cells with values.  At least, I want the find out what's the last row that has values in it.  I tried "Excel Get Last Row.vi" in the report generation toolkit, but it would treat a blank cell as a valued cell if it is filled with another color.  Therefore, that won't work. 
    I don't want to use active x, and I don't want to write a separate vi to search for the last row.  I want to see is there a way to use the report generation toolkit.  Can I somehow get a hidden method from the class?  I would think that, since they are charging for the report generation toolkit, a simple function like that should be included.  Thanks!
    Kudos and Accepted as Solution are welcome!

    I am pretty sure that the Report Generation Toolkit does use ActiveX, so you are using it even if you dont want to.
    Seems to be how the UsedRange function is being used in the toolkit.
    See here for some examples: http://blog.contextures.com/archives/2012/03/01/select-actual-used-range-in-excel-sheet/
    I tried, and it does not find the blank cells with colored backgrounds.
    This will require some activeX modifications though.
    Kenny

  • 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.

  • How to make an array with ActiveX Excel using Excel_RangeSetValue2?

    Hello,
    I want to make an array on Excel. For that, I'm using two functions : Excel_WorksheetGetRange and Excel_RangeSetValue2.
    I write the array on Excel file but only the first case of the array is copied.
    Here, a part of my program :
    char * DataToWrite = {"A", "B", "C", "D"}
    char cCell[10];
    VARIANT             vCell, Data;
    ExcelObj_Worksheet hWorksheet;
    ExcelObj_Range      hRange;
      CA_VariantSetCString (&vCell,cCell);        //cCell = A1:A4
      Excel_WorksheetGetRange (hWorksheet, NULL, vCell, CA_DEFAULT_VAL, &hRange);
      CA_VariantSetCString (&Data,DataToWrite );
      Excel_RangeSetValue2 (hRange, NULL, Data);
    Here what I obtain when I'm compiling on Excel file :
    A
    A
    A
    A
    Solved!
    Go to Solution.

    You should use other instructions to fill the range of cells:
    strcpy (msg, "A1:A4");
    CA_VariantSetCString (&MyVariant, msg);
    Excel_WorksheetRange (ExcelWorksheetHandle, NULL, MyVariant, CA_DEFAULT_VAL, &ExcelRangeHandle);
    Excel_RangeActivate (ExcelRangeHandle, NULL, NULL);
    // Create a SafeArray from array of data
    CA_VariantSet2DArray (&MyVariant, CAVT_CSTRING, righe, 1, array);
    // Transfer data to Excel range
    Excel_SetProperty (ExcelRangeHandle, NULL, Excel_RangeValue2, CAVT_VARIANT, MyVariant);
    ClearObjHandle (ExcelRangeHandle);
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

Maybe you are looking for

  • Itunes wont let me back up the iphone 5 i just restored because it says its not set up.

         I had a problem previously where I reset my password and shortly forgot it. In that time, I tried to restore it and then back it up but I couldn't restore it because Find My IPhone was enabled. Unfortunately the only way to disable Find My IPhon

  • IPhone DEAD after 2.0.2 update!

    I updated and iTunes said the update failed due to an unknown error after backing up the iPhone. The phone, still connected, had the apple logo. I disconnected and still nothing but a logo. After several minutes I performed a reset by holding down po

  • Problem opening excel

    Hi, When I try to open excel after export of report from BW I get a request to enter userID and password to access the server. How can I remove this message. thanks

  • Can a G4 Desktop OS 8.6 be hooked up to cable modem high speed?

    Can anyone help me set up my apple G4 desktop os 8.6 to work with a high speed cable modem to get internet access?

  • Disk utilities repair permissions

    I am trying to repair permissions on my imac OSX2.8. When I get into the repair permissions on the start up disk everything seams fine. The indicator bar starts filling up with the blue and white rotating filler. But thats as far as it goes. It will