Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Export to Excel using Jsp

 
Raghu Kalyan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi , i have a jsp which has data and needs to be exported to excel sheet. I included the below two lines in my jsp, <%response.setContentType("application/vnd.ms-excel;charset=windows-1251");%> <%response.setHeader("Content-Disposition", "attachment; filename=downloadOrders.xls" );%> i have one column which stores data like 1.1,2.1,3.1,... But in english it is printing correctly when i switch to russian language through regional settings in my PC. It is printing like below, 01月01日 (for 1.1) 02月01日 (for 2.1) Can you please help to resolve this issue wheather i need to change the charset or need to modify the code. Thanks in advance
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kalyan, Please check your private messages.

Eric
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try to change the encoding and see what happens?

Eric
 
Elie Hirschman
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Resurrecting this to share:
I combined simple techniques found here: http://rgagnon.com/javadetails/java-0586.html
and here: http://www.theserverside.com/discussions/thread.tss?thread_id=36310

1. Table data
Table data gets dynamically generated, and I surround it with a div tag:


2. Export button
on the page with my TABLE data, I add the following HTML:


3. Export Script
add this JS on top:


3. The JSP Export page
This new page excel.jsp does all the work:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic