Create CSV file with headers

I have a process that creates an Excel page APEX. Works very well, but how do you add in column headers, so that they appear in Excel?

Thank you

BEGIN
-Set the MIME type
owa_util.mime_header ("application/octet", FALSE);
-Place the name of the file
HTP.p ('Content-Disposition: attachment; filename = "SDU.csv" ');
-Close the HTTP header
owa_util.http_header_close;
-To loop through all the rows in the EMP
FOR x in get_students LOOP
HTP. PRN(x.Administration ||) ',' ||
x.last_name | ',' ||
x.first_name | ',' ||
x.MI | ',' ||
'Y' || Chr (13));
END LOOP;
-Send an error code while the rest of the HTML code does not
htmldb_application.g_unrecoverable_error: = true;

bobmagan wrote:
So, the first line in the file will become the headers? Right now, the 1st line of data is not displayed as an Excel headers.

Then add headers before the loop:

    -- Set the MIME type
    owa_util.mime_header( 'application/octet', FALSE );
    -- Set the name of the file
    htp.p('Content-Disposition: attachment; filename="SDU.csv"');
    -- Close the HTTP Header
    owa_util.http_header_close;
    -- Excel header
    htp.prn('administration,last_name,first_name,mi,"Yes/NO"' || chr(13));
    -- Loop through all rows in EMP
    FOR x in get_students LOOP
      htp.prn(x.administration || ',' ||
              x.last_name || ',' ||
              x.first_name || ',' ||
              x.mi || ',' ||
              'Y' || chr(13)
             );
    END LOOP;

SY.

Tags: Database

Similar Questions

  • creating CSV files - output contains comma - work around?

    Greetings,

    It is:

    Is there a way to bypass the databases containing commas

    When you create csv files?

    I have the process down to create a .csv file and stored on the server and

    or by e-mail to go out. The problem I have is that one of the db fields being withdrawn

    the database has a comma in there and so cause problems for me in

    creation of the csv file.

    Fields of DB:

    -emp_number

    -emp_name (name, first name)

    -activity_code

    -report_date

    -time_total

    When the file is created it recognizes the comma in the emp_name field

    and separates the name and surname and creates separate

    columns for them in the CSV files that do not match with the db field

    names in the row 1 of csv.

    I already searched the forum to see if this has been asked before. Or the other

    my eyes is too crossed everyone reading or I'm not in the

    appropriate search criteria.

    Any help will be greatly appreciated.

    Leonard

    double quotes the data part.

  • Try to save a copy of the contacts and emails in windows live to get the error cannot create .csv file

    Try saving a copy of contacts and emails in windows live to get the error can not create .csv file any help appreciated.

    First create new folders to the location where you want it on a local hard drive. Then use the Browse button in the Export Wizard to navigate to the files you created. Once the export is complete, copy the files to their final destination.

    Windows Live products and services are not covered by these forums. You will find support, solutions and forums for them to the Windows Live Solution Center. When you ask a question here, you should give your version of the software, because the answers vary depending on the version. In WLMail to find, has press on ALT - H. If it doesn't show you the version and the build number, press on escape to two times, and then Alt - F B.

    Noel

  • Captivate 8: PDF export created a file with the extension PDF... but it's actually a video. Shouldn't it exported slides as appropriate PDF document?

    In Adobe Captivate, there is a 'PDF export' checkbox when you publish your project.

    He checked the box, and the publication of project created a file with the extension PDF... but it's actually a video. Shouldn't it exported slides as appropriate PDF document?

    No, it was published in an interactive PDF, has always been the case. It's another way to publish the video, that does not need to deploy it to an LMS or a Web server, you can send the PDF file. However, since Flash player is is more integrated in later versions of the Adobe Reader software, the user is to install it.

  • I also have a .csv file with the name of a jpeg file in a column and a text description of each jpeg format in a second column. Is it possible to automatically insert a jpeg (picture) and its corresponding text, each pair on one page, in an Indesign docum

    I also have a .csv file with the name of a jpeg file in a column and a text description of each jpeg format in a second column. Is it possible to automatically insert a jpeg (picture) and its corresponding text, each pair on one page, in an Indesign document?

    Read about to merge data in the help files.

  • How to download the Csv file with column headers

    Hi all

    This is pavan, using Apex version 4.2.3


    I am trying to download the csv file I followed this link , and I'm able to download excel with headers, when I try to download with headers of this error "'ORA-01858: a non-digit character was found here where was waiting for a digital" I searched in google but could not find the right solution, "


    can anyone help on this please.

    Thanks in advance,


    Kind regards

    Pavan

    This article is 6 years old.

    You should study the solutions that are available for APEX 4.2: data loader or the 'Excel2Collection' plugin (which also manages the CSV files).

    Data Loader

    It is a wizard that generates an Assistant for your application.

    Excel2Collection

    You will use the Excel2Collection (in a single process) to convert the BLOB in a Collection

    Then, in a 2nd address), you just do a "INSERT...". SELECT statement.  Add ' where seq_id > 1 "for files with a header.

    MK

    PS - Use the "EXECUTE IMMEDIATE" article is not necessary.

  • Generation of CSV file with timestamp time information

    CREATE OR REPLACE PROCEDURE extract_proc AS

    number of l_rows;
    Start
    l_rows: = extract_function('select *)
    FROM table1 where date1 between trunc (sysdate) and sysdate
    ',
    ',',
    "MYDIR1,"
    "test.csv");

    end;

    I have a procedure extract_proc shown above which create a CSV file in the MYDIR1 directory on unix.

    I would like to have the timestamp ie ddmmyyyyHH24:MI details in the CSV file name created. That is to say. have a test22072011.csv file name each time it generates with respective timestamp prefix or suffix for the file number. Is it possible to achieve this

    Pls suggest

    Thank you very much

    Well well instead to call it test.csv change it to what you want

    'test'||to_char (sysdate, 'ddmmyyyy')||'.csv'
    

    Published by: Alex Nuijten on July 22, 2011 13:56

  • Need help importing CSV file with commas in the rest of the data

    I have a linux script that gets the CSV files from a remote server and import the data into a table using SQLLoader.

    The problem I have is that the data in the CSV files sometimes contains commas in the text field that is interfering with the import and I have no control over what is in the file.

    my table:

    Create the table my_tab
    * (TIME_STAMP date, *)
    REQUEST_IP varchar2 (30),
    User_id varchar2 (30),
    FACILITY_ID VARCHAR2 (255),
    Number SUBFACILITY_ID,
    DETAIL VARCHAR2 (255)
    *);*

    example of a CSV file:

    * 27032011 story 232708,162.108.20.61,user123,cstmr_view_hlr_history,0,Viewed with 10 results per page for 1234567890 *.
    * 232737,162.108.20.61,user123,cstmr_view_customer,0,Facility 27032011 [display] selected *.
    * 232744,162.108.20.76,user123,cstmr_add_gprs,0,Facility 27032011 [Add x] selected *.
    * 232759,162.108.20.94,user456,cstmr_hlr_request,0,Facility 27032011 [x orders] selected *.
    * 27032011 added 232806,162.108.20.94,user123,cstmr_hlr_request,2,Customer note: note [x], MSISDN [1234567890] *.
    * 232806,162.108.22.96,user789,cstmr_hlr_request,0 27032011, queue update: Action [46], IMSI [1234567890] old [, MSISDN IMSI [1234567890] *.
    * 232815,162.108.20.67,user789,cstmr_view_customer,0,Facility 27032011 [display] selected *.
    * 27032011 232822,162.108.20.67,user123,cstmr_view_customer,5,Screen ' display customer details ': MSISDN [1234567890] *.
    * 27032011 232702,162.108.20.57,user456,cstmr_hlr_request,0,Queue update: Action [45], IMSI [1234567890] old [, MSISDN IMSI [12345678901], AFN [], [PDPREC] *.
    * 27032011 connection 232825,162.169.22.108,user456,adm_login,1,Successful: user [user_name] *.
    * 232829,162.169.22.108,user456,cstmr_view_customer,0,Facility 27032011 [display] selected *.

    How can I get around the commas in the text?

    Published by: cinnamon on April 4, 2011 08:07

    There is a way to do it, but it depends on a few assumptions, and (b) you have to jump through hoops to do it.

    First of all, this only works if there is no comma request_id, user_id or facility_id. (if there is, then you're stuck, because there is no way to determine which commas are part of data and those that are separators.)

    Second, he must know if there are any particular character - say | -who never appears in the detail.

    If you can do both of these assumptions, then what you have to do is:
    (1) create an array that consists of a single VARCHAR2 column large enough to hold longer line of your input data.
    (2) to import your data into this table.
    (3) replace the first five commas in each row of the table with. (or whatever your "unused" character).
    For example:

    UPDATE temp_data_table
    SET row_text = REPLACE(SUBSTR(row_text, 1, INSTR(row_text, ',', 1, 5)), ',', '|') || SUBSTR(row_text,  INSTR(row_text, ',', 1, 5) + 1);
    COMMIT;
    

    (4) write a SQL INSERT command to build your target table according to the values separated by the | characters.

    -Don

  • Error importing CSV files with "hidden" characters using the external Table

    Hi people

    Bit of a strange here.

    Well, we are accustomed to the use of the external Table method to load data from CSV files in the database, but a recent event presented us a problem.

    We have received some CSV files that "look like" regular CSV files, but Oracle will not load them.

    When we looked at the CSV using VIM on a UNIX machine, we saw the following characters 'hidden' between each regular character in the file.
    ^@
    If a string that looks like this when opened in Excel/Wordpad etc.
    "TEST","TEXT"
    Looks like this when exmained with VIM
    ^@"^@T^@E^@S^@T^@"^@,^@"^@T^@E^@X^@T^@"
    Has anyone encountered this before?

    Thank you very much

    Simon Gadd
    Oracle 11g 11.2.0.1.0

    Hi Simon,.

    ^ @ represents the ZERO character (0x00).
    So, most likely, you have a file encoded in Unicode.

    You need to specify the character set in the record specification (and if necessary the byte order mark), for example:

    CREATE TABLE ext_table
    (
      col1 VARCHAR2(10),
      col2 VARCHAR2(10)
    )
    ORGANIZATION EXTERNAL
    (
      TYPE ORACLE_LOADER
      DEFAULT DIRECTORY dump_dir
      ACCESS PARAMETERS
      (
       RECORDS DELIMITED BY '
    ' CHARACTERSET 'UTF16'
      FIELDS TERMINATED BY ','
      )
      LOCATION ('dump.csv')
    )
    REJECT LIMIT UNLIMITED;
    

    http://download.Oracle.com/docs/CD/E11882_01/server.112/e16536/et_params.htm#i1009499

  • DIAdem - import programmatically .csv files with. STP file without dialog box

    Does anyone know how to import programmatically with a .csv files. STP file without opening the import box dialog box every time?

    I've been through the forum and seen for .xls files and solutions through the help file which is recommended to use the ExcelImport command, but these do not seem to work for .csv file types.  I am currently using the DataFileLoad command to import the files, which works very well to load the .csv files, but it forces me to go to the. STP file for each file.

    Does anyone know a better way to import a file .csv programmatically?

    Wow... Who had a fraction of the time that does the method of the dialog box.  I'll have to revise the data portion my DiAdem Advanced manual Plugin.

    Thank you, Brad!

    Steve

  • How to create Hlp files with labwindows 9.0

    Hello

    I used to create the dll with Labwindows 8.5 and use them with TestStand... The advantage is that with the help file, I can add information to the Fp file and loading the DLL with TestStand, the "?" button to open the help file...

    But the problem is that I can't find help with Labwindows 9.0 generation...

    Does anyone know how to create file hlp with Labwindows 9.0?

    The procedure with Labwindows 8.5 has been:

    Modification of the PS file, then generate the Option-> windows help

    Thank you very much

    Ronan

  • How to create a file with a password

    Hi all

    In my application, I create Excel files using the file ' open/create/replace' vi.

    These files contain the data for my tests.

    I want to protect those files with a password, so that an unauthorized person will not be able to open to the OUTSIDE of THE LABVIEW.

    Is this possible?

    If not, is it possible to ensure that unauthorized persons can only open these files in 'read only' + can not save them with a different name and then change?

    Thanks in advance,

    Mentos.

    Hi Mentos,

    1)

    http://forums.NI.com/NI/board/message?board.ID=170&message.ID=333106&query.ID=33090#M333106

    2)

    You can use reference workbook. Use a node with the method invoke ' Save as '.

    Mike

  • Creating a file with cascades bar

    Hi all

    I developed an application for BB10, tested on the Simulator. Now, I want to create a file bar so that I can install it on a device BB10.

    I regieterd and got the SJC files.

    Need steps on how to package the application.

    I built the device-release code, I can see the arm with .so files folder, but cannot find a bar file.

    I can't connect the device and run through the IDE (the device is not available), so need to how to create a bar of gall I can send it to the test.

    Right click on the project-> export-> BlackBerry-> Release Build

  • create CSV file

    Hello friends,

    I want to generate .csv file. & write data inside.

    can someone suggest so any idea for it?

    Thank you & best regards

    Milan

    Try this...

    DataOutputStream os = null;
    FileConnection fconn = null;
    String FileName = "sample.csv;
    try {}
    fconn = (FileConnection) Connector.open ("file:///SDCard/BlackBerry/" + name of file, Connector.READ_WRITE);
    If (! fconn.exists ())
    fconn. Create();
    OS = fconn.openDataOutputStream ();
    String Contact_Title = "First name, family, Email1, Email2, organization, title, such work \n";
    OS. Write (Contact_Title.GetBytes ());
    } catch (Exception e) {}
    System.out.println ("Con:" + e.getMessage ());
    } {Finally
    try {}
    If (null! = os)
    OS. Close();
    If (null! = fconn)
    fconn. Close();
    } catch (IOException e) {}
    System.out.println (e.getMessage ());
    }
    }

  • Create the file with pl/sql procedure

    Hi all

    I do not know how to create a file that will contain the data of the select statements. I'm leaving again in oracle and pl/sql, and I apologize in advance for the questions of the rookie.

    CREATE OR REPLACE PROCEDURE ECM_DATA.check_pad

    IS

    v_padron_check VARCHAR2 (50);

    v_padron_number VARCHAR2 (50);

    BEGIN

    SELECT count (pd.estado)

    IN v_padron_check

    OF par6.padrones_datos pd,.

    PAR6.padrones p,

    PAR6. Fechas f

    If pd.estado not in ('2000 ', 8000')

    AND PD. FILE = P.ARCHIVO

    AND P.FECHA = F.fech_s;

    DBMS_OUTPUT. Put_line ('Št. neuspešnih zapisov: ' | v_padron_check);

    FOR (IN) pad

    SELECT pd.archivo

    OF par6.padrones_datos pd,.

    PAR6.padrones p,

    PAR6. Fechas f

    WHERE the pd.estado not in ('2000 ', 8000')

    AND pd.archivo = p.archivo

    AND P.FECHA = F.fech_s

    )

    LOOP

    dbms_output.put_line (' Padrón št.: ' | pad.archivo);

    END LOOP;

    END;

    /

    Thanks for any help.

    Kind regards

    Robert

    Hi user8660054,

    If you want to create the file on the server where your DB is installed and then use that I provide you. It requires a DIRECTORY (with read/write privileges) to create.

    You can use my proc as below...

    Start

    generic_report_genrtr (p_query_in => ' Select * from user_tables ',)

    p_separator => ","-a comma separated values

    p_dir_in-online "nom_repertoire."

    p_filenm_in-online "OUTPUT_FILE_NM") IS

    end;

Maybe you are looking for