jQuery in Action, 3rd edition
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

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: 17410

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.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link: http://aspose.com/file-tools
subject: JSF database to excel
jQuery in Action, 3rd edition