Generate Excel Output

Hi All!
I would very much appreciate if you could send me the code for generating Excel output.
Thanks,
Waqas
[email protected]

Hi,
Here's the code for generating the excel output, you can write this in button press of form which calls the excel report.It automatically opens a new excel sheet , and then it executes the SQL query, after that each rows will get filled with the values.
First of all you need to makeall the queries in the report in to a single query.
declare
     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;
     rowcount integer;
     i integer;
     cursor c2 is select 1 from dual;
     cursor c1 is /* write your select query that fetches the required values */
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');
rowcount := 0;i:=1;
for rec1 in c2 loop
rowcount := rowcount + 1;
-- For the headings
args := CLIENT_OLE2.create_arglist;
CLIENT_OLE2.add_arg(args,rowcount);
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','Column 1 Heading');
CLIENT_OLE2.release_obj(cell);
args := CLIENT_OLE2.create_arglist;
CLIENT_OLE2.add_arg(args,rowcount);
CLIENT_OLE2.add_arg(args,2);
cell := CLIENT_OLE2.get_obj_property(worksheet,'Cells',args);
CLIENT_OLE2.destroy_arglist(args);
CLIENT_OLE2.set_property(cell,'Value','Column2 Heading');
CLIENT_OLE2.release_obj(cell);
end loop;
for rec1 in c1 loop
rowcount := rowcount + 1;
args := CLIENT_OLE2.create_arglist;
CLIENT_OLE2.add_arg(args,rowcount);
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',rec1.field1);
CLIENT_OLE2.release_obj(cell);
/*null value may create problems,then use the if condition as follows*/
args := CLIENT_OLE2.create_arglist;
CLIENT_OLE2.add_arg(args,rowcount);
CLIENT_OLE2.add_arg(args,14);
cell := CLIENT_OLE2.get_obj_property(worksheet,'Cells',args);
CLIENT_OLE2.destroy_arglist(args);
IF rec1.field2 IS NOT NULL THEN
CLIENT_OLE2.set_property(cell,'Value',rec1.field2);
ELSE
     CLIENT_OLE2.set_property(cell,'Value',' ');
END IF;
CLIENT_OLE2.release_obj(cell);
end loop;
CLIENT_OLE2.release_obj(worksheet);
CLIENT_OLE2.release_obj(worksheets);
CLIENT_OLE2.release_obj(workbook);
CLIENT_OLE2.release_obj(workbooks);
CLIENT_OLE2.release_obj(application);
EXCEPTION WHEN OTHERS THEN
     MESSAGE(SQLCODE||' - '||SQLERRM); MESSAGE(' ');
end;
Hope this helps .
Regards,
Nycy

Similar Messages

  • Reports which generate Excel output do not open under ie8/Oracle Forms

    Hello,
    we run Oracle Forms (regardless whether under Jinitiator 1.3.1.22(28) or SUN JVM) and generate Excel output with Oracle Reports (web.show_document). This works well under Internet Explorer 6 (ie6) but not under Internet Explorer 8 (ie8).
    The effect ist that a new browser window opens and closes very quickly without anything further happening.
    I honestly assume that this has not to do with oracle reports but ask this nevertheless in this forum as there might be people which made the same experiences...
    I additionally found out that the same problem exists when gerenating excel or ms word output via a db procedure (with http. modules). There I found that suppressing the question (open/save/cancel) before opening a file (via the windows explorer file type association menu) helped with excel and ms word output (but this might be regarded as a not satisfying workaround).
    The problem persists with other applications' file types than XLS or DOC which are also correctly registered on the client.
    I'm not sure whether mimetypes sent along with the files (which were obviously correct with ie6) play a role in this problem.
    Peter

    Hello,
    Your problem with IE 8 seems to be similar to the one discussed here :
    IE7 windows opened and closed immediatly
    http://www.experts-exchange.com/Software/Internet_Email/Web_Browsers/Interne
    t_Explorer/Q_23304982.html
    You can test the solution suggested :
    We have found the setting that we needed, under the Internet Options
    Security tab, if you select the internet zone, and click the custom level
    button, then scroll down to the Downloads section, the first option is
    Automatic prompting for file downloads, setting this to enable keeps IE 7
    from interfering with this sort of download.
    Example with screen shots :
    http://www.celt.iastate.edu/webct/securitysettings.html
    Regards

  • Problems in generating excel output

    Hi all,
    I'm facing a problem submitting a report with XML output (XML Publisher 5.0.1). I created a RTF template in order to generate an excel output but when I launch the concurrent, its status after few minutes becomes "Warning" logging java.lang.OutOfMemoryError. The strangest thing is that the PDF output generates normally without errors or warnings.
    I've found on metalink a note in which they suggest to create a configuration file (xdo.cfg) where i've declared a temporary folder in order to split the XML in two parts to allow the XDO to create correctly my excel output....but it didnt work! :(
    After that I added to my concurrent execution options the string "-Xmx512m" to increase the memory for that particular task (even if i think that 128 mb for a XML file of 5 MB are more than necessary)... but no results (in this case i've had another error "java.io.FileNotFoundException: /opt/app/oracle//admin/out//o2260792.out (No such file or directory)" ).
    Can someone help me??
    Is it a normal behaviour?? It seems to be a joke, cause in metalink they suggest everybody to apply patches and patches!!
    Thx all

    Hi Nisha,
    Refer to that link.....May be it will helpful for you....
    Are You All Able to get the Output In EXCEL Format
    Otherwise you can do one thing......Add one more Viewer option for XML type data... Most probably earlier For viewing the XML data you are using Browser... So by default whenever you are trying to see the output it is opening it in Browser....
    Now add one more Viewer option For XML as Microsoft Excel......
    So After making two viewer option for XML data whenever you will try to see the output of XML data it will ask you...Viewing option...1.Browser 2. Excel
    Choose Excel here it will not give you any error and you will be able to open the output in Excel format.....
    Regards
    Ravi

  • Reports to generate excel output

    Update reports 9i to reports 10g, and the reports output to excel they generate error.
    Reports Error Page
    Wed Oct 20 15:10:31 GMT-05:00 2004
    java.lang.NullPointerException
    java.lang.NullPointerException
         at com.evermind.server.http.EvermindBodyContent.setCharacterEncoding(EvermindBodyContent.java:458)
         at com.evermind.server.http.EvermindPageContext.pushBody(EvermindPageContext.java:630)
         at oracle.jsp.runtime.OracleJspRuntime.pushBodyIfNeeded(OracleJspRuntime.java:1385)
         at repuc1_excel._jspService(_repuc1__excel.java:54)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:349)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
         at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:604)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)

    Try adding charset to the content type
    e.g:
    <%@ page contentType="application/vnd.ms-excel;charset=ISO-8859-1" %>

  • Reports 10g (9.0.4.0) to generate excel output

    The following line cause error to execute the report
    <%@ page contentType="application/vnd.ms-excel" %>

    Hi,
    Change the line to:
    <%@ page contentType="application/vnd.ms-excel; charset=<your_charset>" %>
    Replace <your_charset> above with the value.
    Navneet.

  • XML Publisher Report EXCEL output Huge stored as Web Pages

    Hello
    I have a XML Publisher Report which generates EXCEL output and the output file size is huge.
    What I notice that it is stored as Web Pages *.htm; *.html (Save as Type) in Excel this is the reason it is huge.
    If I save as Microsoft Office Excel Workbook *.xls it Reduce the size.
    I don't know how to save as ".xls" through XML Publisher using PL/SQL.
    Any body knows? please Help..
    XML Publisher Template Builder for WORD
    Version 5.6 Build 45
    PATCH        BUG_NUMBER
    XDO.H     *3263588*
    4.5.0     *3554613*
    5.0.0     *3822219*
    5.5.0     *4206181*
    5.0.1     *4236958*
    5.6.0     *4561451*
    5.6.1     *4905678*
    5.6.2     *5097966*
    5.6.3     *5472959*
    Thanks.

    Hi Vetsrini,
    We're on 10.1.3.4.1 and siebel 8.1.1.3 and when trying to open a report from within siebel in the output format EXCEL (selected from the parameter applet), it just opens the document in the browser.
    Is there a way to get it to open directly in Excel? I guess the reason is the file extension*.EXCEL, how could we get the extension to be in excel format (xls)?
    We don't want our users to have to do this themself.
    Regards,
    Hakan

  • Excel output gets expanded when developing Xml publisher report !!

    I am developing a report using XML publisher which generates Excel output ....
    And my layout keeps repeating for every unique delivery...(i am passing 'x' deliveries as input)
    1) When i try to generate a pdf output, my report works fine but when i try to generate an excel output the table size expands..
    2) The jpg file inserted in the rtf(layout template) appears when i generate pdf report and does not appear in the excel output..
    What could be the reason ??

    Hi;
    Please see below thread which could be helpful for your issue:
    XML PUBLISHER report in Excel out put problem
    Regard
    Helios

  • Excel output in Reports6i

    Hi,
    I am having problem in generating excel output. I am using reports6i and i am generating output from web. While generating,i am getting the output in excel. But my problem is, in my excel output i am having a field called barcode which is a varchar2 type and having values like (7889999677)number data. So if i generated the excel output file automatically it is showing that data in excel as right aligned data cell. I want that particular cell should be left aligned since it is varchar2 type. Can anybody solve this problem.
    Thanks in advance
    M.C. Meenakshi

    I guess that you are using DESFORMAT=DELIMITED. If so, you don't have any control over formatting etc. Remember that a delimited file only consists of data and a delimiter like 2.4;1.6;6.3;1.1;1.2!
    If it's possible, install Oracle Reports10g (part of Developer Suite 10g) and use the new way to generate an Excel Report.
    Metalink Note 24819.1 describes how to make a report template in MS Excel. This will be opened and customized in Oracle Reports. When running the report, MS Excel will be automatically started (or via Excel browser plugin) and display the data. Quite nice!!!
    Regards,
    Martin Malmström

  • Excel output: Cell Size not adequate

    Hi all,
    I am designing an XML Report whose default output format is excel.
    To one field, I am assigning a long text. When I run the report and generate excel output, the text is not shown fully. I have to manually increase the column size in excel to see the entire text
    Is there some setting in RTF such that I can force the column to expand to accommodate entire string at all times?
    Thanks,
    Rahul

    Hi,
    I am using 10.1.3.4.1 BI Publisher. When I upload my .rtf template in Backoffice 13.0.1, the cell sizes get adjusted in a random manner. The size doesn't remain same in the Back office application from what I have created in .rtf temlpate. How can I fix the cell size in BI publisher so that it doesn't get auto adjusted in BackOffice application.
    Please help to resolve this issue. Any suggestion is appreciated.
    Thanks & Regards
    Quest

  • Hide column in Excel output?

    I have a .cfm file generating Excel output using CFContent.
    The client want to have certain data in a hidden column.
    I am already using XML to freeze the header and I tried
    hiding the column by using a <LeftColumnVisible> tag within
    the WorkSheetOptions (which is what Excel generates when you hide a
    column). But it doesn't come through in the CF output.
    Any suggestions?
    Ken

    Thanks. But "Exclude XML output" does not work dynamically. It cannot be set to "No" or "Yes" programmetically.
    What I would like is to provide my user a parameter "Show Column X? (Yes/No)". Based on user's choice, the Excel output should display or hide column X.
    Thanks for the response!

  • Error when opening BIP 10.1.3.3 Excel output in Excel 2002

    We have BIP 10.1.3.3 and Excel 2002 in use. When generating Excel output with BIP, we always get an error in Excel that the generated file can't be opened. Access is denied because of some error with resource 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'. (Unfortunately, I only get a German error message).
    Does anyone has an idea, how to change settings in BIP or Excel to work around this error?
    Thanks in advance!
    Marco

    Hi Tim,
    the German error message is:
    Diese Datei kann nicht geöffnet werden, weil:
    Zugriff verweigert
    Fehler beim Bearbeiten der Ressource 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'.
    Zeile 3, Position 57.
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    It seems, that Excel 2002 can't do anything with this DOCTYPE. But what would be a workaround?
    Best regards,
    Marco

  • How to embed an attachment in rtf(excel output) from oracle reports

    Hi,
    I have a requirement to embed an attachment from oracle reports(fnd_lobs) into rtf template which will generate excel output.
    Can you please provide me suggestions on this.
    Thanks,
    Kavya

    Hi,
    I will judge few records whether to display or not. i am using one variable to handle its display.
    i want to avoid using IF in my templated .
    Please suggest the best way
    Regards,
    Phani Reddy

  • Limitations in excel output

    TIM,
    Recently I have seen many threads regarding issues on excel output,
    The XHTML output has lot of limitations,
    Most of the users are aware of it, but seems like many are not…!
    Many threads related to excel output(APPS) remained unanswered
    few threads from last 3days
    some of the data for same records is going on to the next page in excel??
    Performance Issue generating excel output with huge XML data
    Performance Issue generating excel output with huge XML data
    EBS - XMLP 5.6.2 - OPP Performance... - Excel Output
    EBS - XMLP 5.6.2 - OPP Performance... - Excel Output
    Excel output in EBS?
    Excel output in EBS?
    could you post something on these limitations and enhancements coming up the way.
    That could help many user on this forum.
    Thanks
    ss

    Hello Tim,
    First time posting a message in this forum. We have a report that we export to Excel for users to analyse it futher. Report consists of all percentages with % sign at the end of each value in the cells. Negetive numbers are highlighted in red enclosed in brackets with % sign at the end. All numbers are rounded to one decimal in the source query, so the XML data has values rounded to one decimal. When we export the report to Excel, all positive numbers are rounding to 2 decimal points and negetive numbers to one decimal point. When exported to PDF, all values are rounded to one decimal. Is there a way to fix this in Excel output?
    Thanks in advance.

  • How to find out the BI Publisher Version from the Excel output generated.

    Hi
    Can any one tell me How to find out the BI Publisher Version from the Excel output file generated using BI publisher.
    Edited by: 781689 on Aug 1, 2010 10:22 PM

    Hello,
    This forum is the "Oracle Reports" OTN Forum.
    The "BI Publisher" OTN Forum is here :
    BI Publisher
    Regards

  • How to generate excel file as output using OWB

    Hi,
    I have a requirement to generate an excel file as output using OWB.
    I am trying for a direct approach to create excel files.
    Though I know that excel can be created from a .csv file, I am looking for a direct approach to generate excel file without involving any .csv to excel conversion externally.
    Regards,
    Sri

    so, we are trying to do it by the help of oracle heterogeneous services. In my opinion it is possible (it depends on feature of ODCB Excel driver)
    For more details look at thread (it is about MS SQL Server but maybe it helps)
    Oracle to SQL SERVER
    Regards,
    Oleg

Maybe you are looking for