Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2007

Tip: Looking for answers? Try searching our database.

how to convert jsp data to excel??

Thread view: 
rishi - 17 May 2007 13:19 GMT
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.
Joe Attardi - 17 May 2007 18:42 GMT
> I m working on one project where in that there is a
> report section in which we display data on jsp by
[quoted text clipped - 5 lines]
> 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.
Nino - 17 May 2007 18:50 GMT
> I m working on one project where in that there is a
> report section in which we display data on jsp by
[quoted text clipped - 5 lines]
> 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;
} %>
TobiMc3@gmail.com - 17 May 2007 19:17 GMT
> I m working on one project where in that there is a
> report section in which we display data on jsp by
[quoted text clipped - 5 lines]
> If anyone have code for generating the excel sheet
> please provide me the code.

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

Tobi


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.