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