how to convert jsp data to excel??

Discussion in 'Java' started by rishi, May 17, 2007.

  1. rishi

    rishi Guest

    I m working on one project where in that there is a
    report section in which we display data on jsp by
    feching the data from the database.all is working good
    but i want to include on button on jsp page and after
    clicking that button that jsp page genrate excel sheet
    and excel sheet display the data in the same sequence
    how the jsp displaying the data.
    If anyone have code for generating the excel sheet
    please provide me the code.
    rishi, May 17, 2007
    #1
    1. Advertising

  2. rishi

    Joe Attardi Guest

    rishi wrote:
    > I m working on one project where in that there is a
    > report section in which we display data on jsp by
    > feching the data from the database.all is working good
    > but i want to include on button on jsp page and after
    > clicking that button that jsp page genrate excel sheet
    > and excel sheet display the data in the same sequence
    > how the jsp displaying the data.
    > If anyone have code for generating the excel sheet
    > please provide me the code.
    >


    Please stop spamming the group. If someone has an answer for your
    question they will post it.
    Joe Attardi, May 17, 2007
    #2
    1. Advertising

  3. rishi

    Nino Guest

    On May 17, 5:19 am, rishi <> wrote:
    > I m working on one project where in that there is a
    > report section in which we display data on jsp by
    > feching the data from the database.all is working good
    > but i want to include on button on jsp page and after
    > clicking that button that jsp page genrate excel sheet
    > and excel sheet display the data in the same sequence
    > how the jsp displaying the data.
    > If anyone have code for generating the excel sheet
    > please provide me the code.


    I have created a file that creates a CSV file and stores it on the
    server. After the file has been created, users can click on a link to
    download it. This file can be opened using Excel and other spreadsheet
    programs, but you will not get the same "nice" formatting you would
    get that is displayed on HTML.

    Here the code snippet:

    <% try {
    String fileName = "/<directory to store file>/
    export-"+request.getParameter("e")+".csv";
    DataOutputStream oFile = new DataOutputStream(new
    FileOutputStream(fileName));

    StringBuffer sb = new StringBuffer();
    sb.append("User ID,Name,Email\n");

    db_query = "select user_id, name, email from TABLE'";
    db_result = stmt.executeQuery(db_query);
    while (db_result.next()) {
    sb.append( db_result.getString("user_id") +","+
    db_result.getString("name") +","+ db_result.getString("email") +"\n");
    }

    oFile.writeBytes(sb.toString());
    oFile.close();

    } catch (Exception e) {
    flag_error = true;
    } %>
    Nino, May 17, 2007
    #3
  4. rishi

    Guest

    On May 17, 8:19 am, rishi <> wrote:
    > I m working on one project where in that there is a
    > report section in which we display data on jsp by
    > feching the data from the database.all is working good
    > but i want to include on button on jsp page and after
    > clicking that button that jsp page genrate excel sheet
    > and excel sheet display the data in the same sequence
    > how the jsp displaying the data.
    > If anyone have code for generating the excel sheet
    > please provide me the code.


    http://faq.javaranch.com/view?JspAndExcel

    Tobi
    , May 17, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wayne
    Replies:
    3
    Views:
    8,186
    RGonzalez
    Sep 30, 2003
  2. davout
    Replies:
    2
    Views:
    5,649
    seshagirik
    Jul 6, 2006
  3. Replies:
    0
    Views:
    4,347
  4. Replies:
    5
    Views:
    472
  5. =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=

    Problem with Excel reports ::::Excel 2003 Migration To Excel 2007

    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=, Oct 5, 2007, in forum: ASP .Net
    Replies:
    15
    Views:
    1,494
    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=
    Oct 24, 2007
Loading...

Share This Page