aspose file tools*
The moose likes JSF and the fly likes JSF   database to excel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF   database to excel " Watch "JSF   database to excel " New topic
Author

JSF database to excel

kenji kunoichi
Ranch Hand

Joined: Jun 02, 2007
Posts: 46
hi ,
I want make a small project in JSF in which I will feed all the values in database to be fed to an excel sheet . Right now I can connect to the database and show up all the values in JSP pages but how to take it to excel like client-machine user will just click a button and whole thing of the database will be downloaded as an excel sheet.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

There isn't anything such as a "JSF database". JSF apps can use databases (or not), but JSF itself doesn't get involved with databases.

One of the simplest ways to output an Excel spreadsheet is to format a CSV text file and set the MIME type of the output to "excel". I don't remember the exact value, but it's going to look roughly like "x-application/vnd-xls" or something of that sort. The output itself won't be an XLS file, but Excel will automatically know what to do with a CSV file.

If you actually want to output something in "Excel" format - whether it's traditional XLS or XML XML, you need some heavyweight support. The Apache Poi project is good for that.

In either event, JSF is designed to output HTML, and neither of the 2 "Excel formats" nor CSV are HTML. So you're better off using a servlet or JSP to do the Excel output. Since JSF session-scope beans are actually just ordinary Servlet session objects, you can do your data entry using JSF to edit a session object (backing bean), then have your display servlet/JSF reference that session object to produce the output.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
Consider Paul's rocket mass heater.
 
subject: JSF database to excel