• Post Reply Bookmark Topic Watch Topic
  • New Topic

Export to excel using JSP  RSS feed

 
Johnson Xavier
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am exporting data to excel using java. i am using the following code
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","attachment; filename=" + "SeachResult"+".xls");

The SearchResult.xls will contain name and email ids. The email ids are displayed in the excel sheet with the url(ie,if we click the email id, it will load the mail client). I want to diaplay the mail id as a simple text(with out link to the mail client). Please help me in this regards.
[ December 12, 2005: Message edited by: Bear Bibeault ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a section in the JSP FAQ on displaying results in Excel.
In it, there is an example showing how to display simple CSV or HTML Tables.

If you want to do more than this, (like controlling the formatting) you will have to find a third party library that will allow you to work directly with Microsoft Office files via Java. There is a link to one of those libraries in the JSP FAQ.
 
Johnson Xavier
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben Souther,
Thank you very much for your reply.
 
payal agrawal
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the URL below:

How to view database data in XLS format using servlets
http://www.java-tips.org/content/view/849/40/
 
Anoop Chandran
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's better to use jxl frame work when working with excel/ java as jxl has lots of features which can be explored.
http://jexcelapi.sourceforge.net/


WritableWorkbook samplebook = Workbook.createWorkbook(out);
WritableSheet sample = highTransBook.createSheet("Sample", 0);
sample.setPageSetup(PageOrientation.LANDSCAPE);
WritableFont times20font = new WritableFont(WritableFont.TIMES, 20, WritableFont.BOLD, true);
WritableCellFormat times20format = new WritableCellFormat(times20font);
Label label1 = new Label(0,0, "Sample Ref", times20format);
sample.addCell(label1);
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!