Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

creating excel file by servlet

 
Ramneek Handa
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
For getting reports in excel the one way is to export the data from database and display the report. but this is very difficult to do where I need to genrate it daliy.
that will be the best if this can be done on fly /dinamically by setting some mime type or something like that.
do somebody can help me out in that direction.
regards,
Bobby ;-}
 
Anil Vupputuri
Ranch Hand
Posts: 527
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
U can specify the MIME type using


 
Ramneek Handa
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that's fine setting mime to html/excel but that is just to tell the browser that the response is having excel sheet. it will not prepare the report in excel format.
how to create excel sheet from servlet/jsp/java so that it could be readable through MS Excel, that's something i wanted to know .
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Excel is often set up to automatically start and load when you click on a csv file (comma-separated-values), so this is probably the simplest way to get an "excel" file from a servlet. Generate your rows and columns in csv, with an appropriate mime type and a filename of something.csv. Then when the user saves the results to disk and clicks on it later, Excel should start up and load the data.
 
Ramneek Handa
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Frank that's a good idea . I will make use of it to start with but I was looking for something where I can create report in proper format(having good presentation) instead of just value. I have a strong feeling that there should be a way for doing that through some api or whatever.
rgds.
 
Anil Vupputuri
Ranch Hand
Posts: 527
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ramneek Handa:
that's fine setting mime to html/excel but that is just to tell the browser that the response is having excel sheet. it will not prepare the report in excel format.
how to create excel sheet from servlet/jsp/java so that it could be readable through MS Excel, that's something i wanted to know .

Yeah ...
This link may be useful writing CSV file..http://search.java.sun.com/query.html?col=nforum&q p=%2Bboard%3A%22discuss.sun.java.servlet.development.kit%22&qt=excel

[This message has been edited by Anil Vupputuri (edited March 20, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic