Export Data to Excel using PL/SQL

Hello.....
Can anyone tell me of a straight-forward way to export a result set to an excel file using PL/SQL?
Thanks,
Christine

my oracle DB is on unix box and i created that directory on unix server...
SQL> select directory_path from all_directories where directory_name = 'SERVER_PATHWAY_FILES_LOCATION1';
DIRECTORY_PATH
/d02/oradata/CSV_Files
SQL> [pre]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Export data into Excel from PL/SQL Block

    Hi,
    Please tell me how to export data into excel comming out from PL/SQL code in APEX.
    We can simply export data into excel if we have Report region, but my query is dynamic for which i had to use PL/SQL block. Now i want to export that data into excel.
    Thanks & Regards,
    Smith

    Hi,
    Take a look here http://spendolini.blogspot.com/2006/04/custom-export-to-csv.html
    Regards
    Paul

  • Export data to Excel + use of xsd

    Hi,
    I'd like to export data from oracle to excel using pl/sql. These files go to subcontractors who will have to make some kind of customization to that data. I want to prevent these subcontractors from writing trash to this excelfile (writing text to a numbercolumn). As far as I know, this can be done using xml schema (supported since excel 2003).
    Is it possible to generate an excelfile using pl/sql and also include an xml-schema according to the columntype defined inside the database?
    Oracle Version is 11GR1
    Thanks

    Thanks for your reply.
    As far as my understanding of xml and xsd is correct: XML is used to transfer data to an excel-sheet. This is the data from a table/query or something like that.
    The XML Schema defines the structure of this data. Lets say you have the following table:
    create table test(
    x number
    ,y varchar2(20)
    Exporting the content of this table might result in the following excel-sheet
    x | y
    |20 | test |
    |30 | test |
    Because this excelfile is sent to a subcontractor, I can't control the data he inserts into x or y. He might insert
    x | y
    |20 | test |
    |30 | test |
    |test | 40 |
    When trying to import this table, there would be errors. Now I'll call the subcontractor telling him that he's not allowed to insert text into x. To avoid this situation, I'd like to use XML Schema. If there is another way to prevent this situation from happening, pls tell me.

  • Export data to excel using DOI(desktop Office integration) technique

    Hi Experts,
    I have the requirement to export data to excel file, I have some idea using OLE but no idea of exporting to excel using DOI, Please help me by providing sample code for it.
    My requirement also include merging of cells and coloring of cells.
    Thanks
    Rohit

    For merging of cells you can refer following code!
    [Merging of cells.|https://www.sdn.sap.com/irj/scn/wiki?path=/display/community/oleconceptfordownloadingthereportoutputintoexcel]
    Regards,
    Lalit Mohan Gupta.

  • Export datas to Excel (Using Web Utilities)

    Hi,
    This is the procedure to export the datas from Data Block to the excel sheet. It woks fine in the client-server arch (by replaceing CLIENT_OLE2 with OLE2). But i need to execute in Appication Server Arch. so I prefixed "CLIENT_" , but it is not working. Is there any suggestion to implement it.
    PROCEDURE pr_Forms_to_Excel(p_block_name IN VARCHAR2 DEFAULT NAME_IN('system.current_block')) IS
    -- Declare the OLE objects
    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;
    range CLIENT_OLE2.OBJ_TYPE;
    range_col CLIENT_OLE2.OBJ_TYPE;
    -- Declare handles to OLE argument lists
    args CLIENT_OLE2.LIST_TYPE;
    -- Declare form and block items
    form_name VARCHAR2(100);
    f_block VARCHAR2(100);
    l_block VARCHAR2(100);
    f_item VARCHAR2(100);
    l_item VARCHAR2(100);
    cur_block VARCHAR2(100) := NAME_IN('system.current_block');
    cur_item VARCHAR2(100) := NAME_IN('system.current_item');
    cur_record VARCHAR2(100) := NAME_IN('system.cursor_record');
    item_name VARCHAR2(100);
    baslik VARCHAR2(100);
    row_n NUMBER;
    col_n NUMBER;
    filename VARCHAR2(100);
    ExcelFontId CLIENT_OLE2.list_type;
    BEGIN
    -- Start Excel
    application:=CLIENT_OLE2.CREATE_OBJ('Excel.Application');
    CLIENT_OLE2.SET_PROPERTY(application, 'Visible', 'True');
    -- Return object handle to the Workbooks collection
    workbooks:=CLIENT_OLE2.GET_OBJ_PROPERTY(application, 'Workbooks');
    -- Add a new Workbook object to the Workbooks collection
    workbook:=CLIENT_OLE2.GET_OBJ_PROPERTY(workbooks,'Add');
    -- Return object handle to the Worksheets collection for the Workbook
    worksheets:=CLIENT_OLE2.GET_OBJ_PROPERTY(workbook, 'Worksheets');
    -- Get the first Worksheet in the Worksheets collection
    -- worksheet:=CLIENT_OLE2.GET_OBJ_PROPERTY(worksheets,'Add');
    args:=CLIENT_OLE2.CREATE_ARGLIST;
    CLIENT_OLE2.ADD_ARG(args, 1);
    worksheet:=CLIENT_OLE2.GET_OBJ_PROPERTY(worksheets,'Item',args);
    CLIENT_OLE2.DESTROY_ARGLIST(args);
    -- Return object handle to cell A1 on the new Worksheet
    go_block(p_block_name);
    baslik := get_block_property(p_block_name,FIRST_ITEM);
    f_item := p_block_name||'.'||get_block_property(p_block_name,FIRST_ITEM);
    l_item := p_block_name||'.'||get_block_property(p_block_name,LAST_ITEM);
    first_record;
    LOOP
    item_name := f_item;
    row_n := NAME_IN('SYSTEM.CURSOR_RECORD');
    col_n := 1;
    LOOP
    IF get_item_property(item_name,ITEM_TYPE)<>'BUTTON' AND
    get_item_property(item_name,VISIBLE)='TRUE'
    THEN
    -- Set first row with the item names
    IF row_n=1 THEN
         args := CLIENT_OLE2.create_arglist;
         CLIENT_OLE2.add_arg(args, 1);
         CLIENT_OLE2.add_arg(args, col_n);
         cell := CLIENT_OLE2.get_obj_property(worksheet, 'Cells', args);
         CLIENT_OLE2.destroy_arglist(args);
         --cell_value := CLIENT_OLE2.get_char_property(cell, 'Value');
         ExcelFontId := CLIENT_OLE2.get_obj_property(Cell, 'Font');
         CLIENT_OLE2.set_property(ExcelFontId, 'Bold', 'True');
    baslik:=NVL(get_item_property(item_name,PROMPT_TEXT),baslik);
    args:=CLIENT_OLE2.CREATE_ARGLIST;
    CLIENT_OLE2.ADD_ARG(args, row_n);
    CLIENT_OLE2.ADD_ARG(args, col_n);
    cell:=CLIENT_OLE2.GET_OBJ_PROPERTY(worksheet, 'Cells', args);
    CLIENT_OLE2.DESTROY_ARGLIST(args);
    CLIENT_OLE2.SET_PROPERTY(cell, 'Value', baslik);
    CLIENT_OLE2.RELEASE_OBJ(cell);
    END IF;
    -- Set other rows with the item values
    args:=CLIENT_OLE2.CREATE_ARGLIST;
    CLIENT_OLE2.ADD_ARG(args, row_n+1);
    CLIENT_OLE2.ADD_ARG(args, col_n);
    cell:=CLIENT_OLE2.GET_OBJ_PROPERTY(worksheet, 'Cells', args);
    CLIENT_OLE2.DESTROY_ARGLIST(args);
    IF get_item_property(item_name,DATATYPE)<>'NUMBER' THEN
    CLIENT_OLE2.SET_PROPERTY(cell, 'NumberFormat', '@');
    END IF;
    CLIENT_OLE2.SET_PROPERTY(cell, 'Value', name_in(item_name));
    CLIENT_OLE2.RELEASE_OBJ(cell);
    END IF;
    IF item_name = l_item THEN
    exit;
    END IF;
    baslik := get_item_property(item_name,NEXTITEM);
    item_name := p_block_name||'.'||get_item_property(item_name,NEXTITEM);
    col_n := col_n + 1;
    END LOOP;
    EXIT WHEN NAME_IN('system.last_record') = 'TRUE';
    NEXT_RECORD;
    END LOOP;
    -- Autofit columns
    range := CLIENT_OLE2.GET_OBJ_PROPERTY( worksheet,'UsedRange');
    range_col := CLIENT_OLE2.GET_OBJ_PROPERTY( range,'Columns');
    CLIENT_OLE2.INVOKE( range_col,'AutoFit' );
    CLIENT_OLE2.RELEASE_OBJ( range );
    CLIENT_OLE2.RELEASE_OBJ( range_col );
    -- Get filename and path
    args := CLIENT_OLE2.CREATE_ARGLIST;
    CLIENT_OLE2.ADD_ARG( args, p_block_name );
    CLIENT_OLE2.ADD_ARG( args,'Excel Workbooks (*.xls, *.xls');
    filename := CLIENT_OLE2.INVOKE_CHAR( application,'GetSaveAsFilename',args );
    CLIENT_OLE2.DESTROY_ARGLIST( args );
    -- Save as worksheet
    IF NVL(filename,'0')<>'0' THEN
    args := CLIENT_OLE2.CREATE_ARGLIST;
    CLIENT_OLE2.ADD_ARG( args,filename );
    CLIENT_OLE2.INVOKE( worksheet,'SaveAs',args );
    CLIENT_OLE2.DESTROY_ARGLIST( args );
    END IF;
    -- Close workbook
    --CLIENT_OLE2.INVOKE( workbook ,'Close');
    -- Release the OLE objects
    CLIENT_OLE2.RELEASE_OBJ(worksheet);
    CLIENT_OLE2.RELEASE_OBJ(worksheets);
    CLIENT_OLE2.RELEASE_OBJ(workbook);
    CLIENT_OLE2.RELEASE_OBJ(workbooks);
    --CLIENT_OLE2.INVOKE(application, 'Quit');
    CLIENT_OLE2.RELEASE_OBJ(application);
    -- Focus to the original location
    go_block(cur_block);
    go_record(cur_record);
    go_item(cur_block||'.'||cur_item);
    END;
    Thanks in advance.
    Rizly

    Hi Simon,
    It is not giving any error message, but not generaitng the output also. But if i removed all the prefixed CLIENT_ , then I will get the out put in the Application Server machience (Export the datas from the argument DataBlock to the Excel sheet) , but I need the same in the Client Machience, thats why I prefixed the CLIENT_, but i thing even though it wont for every methods, because i read like that in the Webutil Demo Documentation.
    Thank U, Thank U Very much
    Rizly

  • Export data to excel from oracle ?

    Hi,
    Is it possible to export the table data to an excel sheet??? If yes, please let me know how to achieve it !!!
    Regards
    Venkat

    Numerous threads about this issue....
    Just a pair of example...
    Export from oracle to excel
    Export Data to Excel using PL/SQL
    If you were not satisfied ... , you could search extensively the forums:
    http://forums.oracle.com/forums/search.jspa?threadID=&q=export+data+to+excel&objID=f75&dateRange=lastyear&userID=&numResults=15
    Greetings...
    Sim

  • Error in Exporting HRMS people data to excel using WEB EDI.

    Hi ,
    I am using an existing integrator to export people data to excel using WEB ADI.
    When the excel opens it first shows the it is trying to download data, but later shows an error message saying that an error has occurred in the script on this page
    line 18
    Char 5
    Error Object doesn't support this property or method.
    Can anyone please throw some light as to what can be the cause of the error.
    Regards
    Deepak

    Hi experts,
    When I click the "Upload" button on GL Journal WebADI, The following error message is displayed:
    http://myservername:port/OA_HTML/BneApplicationService?bne:encoding=UTF-8
    I think this error is similar as your previous discussion, and I tried the solution as you mentioned, but not worked. If there is any new solution for the errors of this kind?
    Some Environment parameters are as following:
    Product: EBS 12.1.1
    Browser: IE 7.0 and Firefox 3.5.5
    Hope for your advice.
    Thanks in advance.

  • How to export data with column headers in sql server 2008 with bcp command?

    Hi all,
    I want know "how to export data with column headers in sql server 2008 with bcp command", I know how to import data with import and export wizard. when i
    am trying to import data with bcp command data has been copied but column names are not came.
    I am using the below query:-
    EXEC master..xp_cmdshell
    'BCP "SELECT  * FROM   [tempdb].[dbo].[VBAS_ErrorLog] " QUERYOUT "D:\Temp\SQLServer.log" -c -t , -T -S SERVER-A'
    Thanks,
    SAAD.

    Hi All,
    I have done as per your suggestion but here i have face the below problem, in print statment it give correct query, in EXEC ( EXEC master..xp_cmdshell @BCPCMD) it was displayed error message like below
    DECLARE @BCPCMD
    nvarchar(4000)
    DECLARE @BCPCMD1
    nvarchar(4000)
    DECLARE @BCPCMD2
    nvarchar(4000)
    DECLARE @SQLEXPRESS
    varchar(50)
    DECLARE @filepath
    nvarchar(150),@SQLServer
    varchar(50)
    SET @filepath
    = N'"D:\Temp\LDH_SQLErrorlog_'+CAST(YEAR(GETDATE())
    as varchar(4))
    +RIGHT('00'+CAST(MONTH(GETDATE())
    as varchar(2)),2)
    +RIGHT('00'+CAST(DAY(GETDATE())
    as varchar(2)),2)+'.log" '
    Set @SQLServer
    =(SELECT
    @@SERVERNAME)
    SELECT @BCPCMD1
    = '''BCP "SELECT 
    * FROM   [tempdb].[dbo].[wErrorLog] " QUERYOUT '
    SELECT @BCPCMD2
    = '-c -t , -T -S '
    + @SQLServer + 
    SET @BCPCMD
    = @BCPCMD1+ @filepath 
    + @BCPCMD2
    Print @BCPCMD
    -- Print out below
    'BCP "SELECT 
    * FROM   [tempdb].[dbo].[wErrorLog] " QUERYOUT "D:\Temp\LDH_SQLErrorlog_20130313.log" -c -t , -T -S servername'
    EXEC
    master..xp_cmdshell
    @BCPCMD
      ''BCP' is not recognized as an internal or external command,
    operable program or batch file.
    NULL
    if i copy the print ourt put like below and excecute the CMD it was working fine, could you please suggest me what is the problem in above query.
    EXEC
    master..xp_cmdshell
    'BCP "SELECT  * FROM  
    [tempdb].[dbo].[wErrorLog] " QUERYOUT "D:\Temp\LDH_SQLErrorlog_20130313.log" -c -t , -T -S servername '
    Thanks, SAAD.

  • Problems in exporting data to Excel from WebDynpro

    Hi,
    I'm trying to transport data to Excel using the WebDynpro Binary Cache. The table data I have has certain special characters like & , < and > . I get an XML Parse error while trying to retrieve the XML List from the Binary Cache. The detailed error is Whitespace is not allowed. If table data is without these special characters Excel Export happens fine.
    Any help is highly appreciated.
    Thanks,
    Bala

    I got the same error message and find the solution (knowing that this is an old thread, but maybe in future it can helps someone)
    I've changed my TableUtilities class (getting from this excellent blog: /people/sap.user72/blog/2006/05/04/enhancing-tables-in-webdynpro-java-150-custom-built-table-utilities), adding the CDATA Element
    Method: DownloadToExcel
    for (int j = 0;j<columnInfos.size();j++)
                             String attributeName = (String)columnInfos.get(j);
                             xml_file.append("<")
                                       .append(attributeName)
                                       .append(">")
                                       .append("<![CDATA[")
                                       .append(elem.getAttributeValue(attributeName))
                                       .append("]]>")
                                       .append("</")
                                       .append(attributeName)
                                       .append(">\n");
                        xml_file.append("</")
                                  .append(_nodename)
                                  .append("Element>\n");

  • Problem in exporting data to excel in nwds 7.3

    Hi All,
    I was using the following code for exporting data to excel in NWDS 7.3
    private IWDCachedWebResource getCachedWebResource(byte[] file, String name,
    WDWebResourceType type) {
    IWDCachedWebResource cachedWebResource = null;
    if (file != null) {
    cachedWebResource = WDWebResource.getWebResource(file, type);
    cachedWebResource.setResourceName(name);
    return cachedWebResource;
    I was getting the error in the following line cachedWebResource = WDWebResource.getWebResource(file, type); when I clicked the quick help it ststed the getWebResource method is depricated.  Kindly provide some assistance on what is the new method in its place.
    Thank you
    Regards,
    Preet Kaur

    Hi Ganesh,
    Thanks that worked fine, but when we go further we are facing problem ie
    byte[] excelXMLFile;
    IWDCachedWebResource cachedExcelResource = null;
    String fileName = dataNode.getNodeInfo().getName() + ".xls";
    try {
    // create Excel 2003 XML data as a byte array for the given context node,
    // attributes and headers
    excelXMLFile = toExcel(dataNode, columnInfos).getBytes("UTF-8");
    // create a cached Web Dynpro XLS resource for the given byte array
    // and filename
    cachedExcelResource = getCachedWebResource(
    excelXMLFile, fileName, WDWebResourceType.XLS);
    // Store URL and file name of cached Excel resource in context.
    if (cachedExcelResource != null) {
    wdContext.currentContextElement().setExcelFileURL(
    cachedExcelResource.getURL());
    wdContext.currentContextElement().setExcelFileName(
    cachedExcelResource.getResourceName());
    // Open popup window with a link to the cached Excel file Web resource.
    openExcelLinkPopup();
    } else {
    wdComponentAPI.getMessageManager().reportException(
    "Failed to create Excel file from table!", true);
    } catch (UnsupportedEncodingException e) {
    wdComponentAPI.getMessageManager().reportException(
    e.getLocalizedMessage(), true);
    } catch (WDURLException e) {
    wdComponentAPI.getMessageManager().reportException(
    e.getLocalizedMessage(), true);
    The above bold lines also would need to be converted to inputstream, but not sure how to correct that
    We are following the below pdf for the implementation.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/edc2f3c2-0401-0010-8898-acd5b6a94353?QuickLink=index&overridelayout=true
    Thank you
    Regards,
    Jaspreet Kaur

  • Export data to excel and table column headers

    I noticed that with LV 2012 when I call the method "Export Data to Excel" for a table, the table headers (= column names) are not exported to excel.
    Am I right? I think that the column names should be exported too...
    As a matter of fact when you call the method "Export to simplified image" the column names are included
    How can I export the table column names to excel?
    Vix
    In claris non fit interpretatio
    Using LV 2013 SP1 on Win 7 64bit
    Using LV 8.2.1 on WinXP SP3
    Using CVI 2012 SP1 on Win 7 64bit, WinXP and WinXP Embedded
    Using CVI 6.0 on Win2k, WinXP and WinXP Embedded

    In this document there is a full description of how to export data from LabVIEW to Excel.
    Using a table, the method "Export data to excel" should export the "currently selected data", and data can be programmatically selected using ActiveCell property (as described here).
    With ActiveCell I can select the column headers too (using negative numbers for row and/or column), and I do this.
    And so I expect that when I select "Export data to Excel", the column headers should be exported too (because I selected them!).
    I think that the actual behavior is a bug, rather that an expected behavior.
    Don't you agree?
    Vix
    In claris non fit interpretatio
    Using LV 2013 SP1 on Win 7 64bit
    Using LV 8.2.1 on WinXP SP3
    Using CVI 2012 SP1 on Win 7 64bit, WinXP and WinXP Embedded
    Using CVI 6.0 on Win2k, WinXP and WinXP Embedded

  • How export data in Excel From Visual Composer

    Hay everybody,
    I would like to export my data result from Visual Composer to Excel. I've tried with an export data buton, but the exported file has a very bad format in Excel. I've tried an hyperlink buton which contain the Reptname data of the query too, but I can't keep my filters. This second solution can be nice for the format. If anyone knows how I can keep my filters, I would be fine.
    Thanks

    I did not get solution by using BW 3.5 , can we export data to Excel ? I am refering
    [HOW TO EXPORT DATA FROM VISUAL COMPOSER|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/47fe4fef-0d01-0010-6f87-ed8ecb479123?overridelayout=true] following link??

  • Export data to excel in alv

    hi everybody ,
    could you give me an example about export data to excel with no ole objects?

    You can use FM - ALV_XXL_CALL , it exports the data with formatting and column heading.
    REPORT  ZSKC_ALV_XXL.
    TYPE-POOLS : KKBLO.
    DATA : ITAB LIKE T100 OCCURS 0,
           T_FCAT_LVC TYPE LVC_S_FCAT OCCURS 0 WITH HEADER LINE,
           T_FCAT_KKB TYPE KKBLO_T_FIELDCAT.
    START-OF-SELECTION.
    * Get data.
      SELECT * UP TO 20 ROWS
      FROM   T100
      INTO   TABLE ITAB
      WHERE  SPRSL = SY-LANGU.
      CHECK SY-SUBRC EQ 0.
    * Create the field catalog.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
       EXPORTING
          I_STRUCTURE_NAME             = 'T100'
        CHANGING
          CT_FIELDCAT                  = T_FCAT_LVC[]
        EXCEPTIONS
          INCONSISTENT_INTERFACE       = 1
          PROGRAM_ERROR                = 2
          OTHERS                       = 3.
      CHECK SY-SUBRC EQ 0.
    * make sure you pass the correct internal table name in the field catalog.
      t_fcat_lvC-tabname = 'ITAB'.
      MODIFY T_FCAT_LVC TRANSPORTING TABNAME WHERE TABNAME NE SPACE.
    * Transfer to KKBLO format.
      CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO'
        EXPORTING
          IT_FIELDCAT_LVC                 = T_FCAT_LVC[]
        IMPORTING
          ET_FIELDCAT_KKBLO               = T_FCAT_KKB
       EXCEPTIONS
         IT_DATA_MISSING                 = 1
         IT_FIELDCAT_LVC_MISSING         = 2
         OTHERS                          = 3.
      CHECK SY-SUBRC EQ 0.
    * Call XXL.
      CALL FUNCTION 'ALV_XXL_CALL'
        EXPORTING
          I_TABNAME                    = 'ITAB'
          IT_FIELDCAT                  = T_FCAT_KKB
        TABLES
          IT_OUTTAB                    = ITAB[]
        EXCEPTIONS
          FATAL_ERROR                  = 1
          NO_DISPLAY_POSSIBLE          = 2
          OTHERS                       = 3.
      IF SY-SUBRC <> 0.
      ENDIF.

  • Export data to excel from jsf

    How can I export data to excel sheet using jsf ..Any components available..
    Thanks in advance.

    There is no JSF component which does all the task, but there are enough ways to achieve this. You can use a reporting framework, such as JasperReports or BIRT. You can use a Java Excel API, such as Apache POI HSSF or Andy Khan's JExcelAPI. You can write a plain vanilla CSV or HTML TABLE file which can also be read by Excel.

  • Export Data To Excel From DVWP

    Hi,
    I created DVWP in SPD.
    Is it possible to Export Data To Excel From DVWP?
    What should I do?
    Thanks in advance!

    Hello,
    try this:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/c2e2eb0c-202e-49c1-80cb-2fbf5159b10c/how-to-export-dataview-webpart-to-an-excel-file?forum=sharepointcustomizationprevious
    Via script:
    http://ameyakawale.wordpress.com/2011/08/04/exporting-dataview-webpart-data-into-excel-using-javascript/
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/e01ed0bb-63bc-49fc-b1ff-5d2342f897ae/exporting-data-view-webpart-to-excel-spreadsheet?forum=sharepointcustomizationprevious
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

Maybe you are looking for