This discussion is archived
3 Replies Latest reply: Jul 29, 2008 9:49 PM by 494471 RSS

CSV Download without Header, possible?

12793 Newbie
Currently Being Moderated
Good Morning, everyone,

Out enviroment: Apex 3.1.1 under CentOS 5.1 X64 with database 11G.

We are feeding CSV files for our Zebra Printer LabelMatrix Program, the 1st line--Header Title( i.e., Company, ship address , city , zipcode, state, barcode....) is simply extra data and it interferes with Label Matrix Program, so obviously we wish there is an easy way to produce CSV files without title. Currently we use the default CSV link from SQL reports to generate CSV files. Does anybody know how to generate CSV files without the title line? Any suggestions are greatly appreciated.


sean
  • 1. Re: CSV Download without Header, possible?
    pjturley Pro
    Currently Being Moderated
    Hi Sean,

    If you set the report to display no headings then they will not appear in the csv file when you generate them.

    I suspect you will not want to do this as you will want the headings displayed on the screen so you could write a pl/sql process that is fired on a button that will export the data to csv. The code below is an example exporting data from the emp table

    begin
    -- Set the MIME type
    owa_util.mime_header( 'application/octet', FALSE );
    -- Set the name of the file
    htp.p('Content-Disposition: attachment; filename="npdat_report.csv"');
    -- Close the HTTP Header
    owa_util.http_header_close;

    -- Loop through all rows in EMP
    for x in (SELECT empno,
    ename,
    deptno
    from emp)
    loop
    -- Print out a portion of a row,
    -- separated by commas and ended by a CR
    htp.prn(x.empno||','||
    x.ename||','||
    x.deptno||chr(13));
    end loop;
    -- Send an error code so that the
    -- rest of the HTML does not render
    htmldb_application.g_unrecoverable_error := true;
    end;

    Regards

    Paul
  • 2. Re: CSV Download without Header, possible?
    12793 Newbie
    Currently Being Moderated
    Thanks, Paul,

    The non-programming way just works !!!

    I'm an idiot that I don't know such easy tricks even though I have used Apex since 1.6(HTMLDB).

    Regarding the programming way: ( i.e htp.p ... stuff) is also extremely valuable to us too, becuase I believe I can use such technics to produce more complex EDI outgoing files, like ASN( Advanced Shipping Notice ) too, for which our original plan is using UTL_FILE...

    Once again, we really appreciate your help. have a nice day.

    sean

    Hi Sean,

    If you set the report to display no headings then
    they will not appear in the csv file when you
    generate them.

    I suspect you will not want to do this as you will
    want the headings displayed on the screen so you
    could write a pl/sql process that is fired on a
    button that will export the data to csv. The code
    below is an example exporting data from the emp
    table

    begin
    -- Set the MIME type
    owa_util.mime_header( 'application/octet', FALSE );
    -- Set the name of the file
    htp.p('Content-Disposition: attachment;
    filename="npdat_report.csv"');
    -- Close the HTTP Header
    owa_util.http_header_close;

    -- Loop through all rows in EMP
    for x in (SELECT empno,
    ename,
    deptno
    from emp)
    -- Print out a portion of a row,
    -- separated by commas and ended by a CR
    htp.prn(x.empno||','||
    x.ename||','||
    x.deptno||chr(13));
    end loop;
    -- Send an error code so that the
    -- rest of the HTML does not render
    htmldb_application.g_unrecoverable_error := true;
    end;

    Regards

    Paul
  • 3. Re: CSV Download without Header, possible?
    494471 Newbie
    Currently Being Moderated
    Could you use a simple custom header function that, based on wwv_flow.g_excel_format, returns either the screen header values or a null string.

    Not sure what happens if the header function returns null. Would you get a blank row in the csv file for the header row, or no row at all?

    Bill