From Oracle pl/sql open Excel spreadsheet, run a macro, save the spreadsheet

Posted on 2011-10-12
Last Modified: 2012-06-27
From an Oracle database (11.2 in my case) and not from an Oracle Form, execute a pl/sql procedure to

1.  Open an Excel Spreadsheet
2.  Run a macro staored on that spreadsheet
3.  Save the Spreadsheet

I'm also presently looking at open source products and I see information online about doing this from an Oracle Form but not much from just a pl/sql procedure.
Question by:talahi
    LVL 73

    Accepted Solution

    if your database is remote and your spreadsheet is local,  then you can't do it.   pl/sql runs on the db and has no access to anything that isn't on that server.

    if your database is local to the file, then you could do it with an external procedure call,
    or presumedly this would be a windows server, you could try a .net stored procedure that invokes excel
    or, you could try using dbms_scheduler to invoke excel as an external program

    as for the macro,  excel will have to do that itself.  pl/sql has no means of executing anything within excel

    Author Comment

    Excel and db are local.

    I've seen pl/sql code in a forum using the type  ole2.obj_type and believe that only relates when using Oracle Forms and
    OLE2.ADD_ARG(args, 'ExactNameOfTheMacro');
    to run an Excel Macro.  So am I correct in assuming this this can't be used on the db using plsql?

    p_file_name in varchar2,
    p_sheet_name in varchar2,
    p_range in varchar2,
    p_from_row in number,
    p_from_col in number,
    p_to_row in number,
    p_to_col in number,
    p_value out varchar

    -- Declare handles to OLE objects
    application ole2.obj_type;
    workbooks ole2.obj_type;
    workbook ole2.obj_type;
    worksheet ole2.obj_type;
    cell ole2.obj_type;
    cell1 ole2.obj_type;
    LVL 73

    Expert Comment

    correct,  server side pl/sql  can't use ole2 library,  that's forms specific functionality

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
    This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
    This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
    This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now