This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Generate Excel file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Generate Excel file" Watch "Generate Excel file" New topic
Author

Generate Excel file

M Yuvi
Greenhorn

Joined: Mar 19, 2008
Posts: 9
Hi,

The requirement is to read the data available in the database and send them as excel stream to another web application - in specific a JSP page.

1. Everytime I read the records from the database, should I generate an Excel sheet and store the excel file physically before sending it across? What is the better way to implement this?

2. Which API is better to use to generate the excel sheet, write the data into it, read the data from it and send it across as excel stream?

3. How do I send the data as excel stream to the other application?

Thanks
Yuvi
Gerardo Tasistro
Ranch Hand

Joined: Feb 08, 2005
Posts: 362
You can use the jxl Java Excel API. Create a writable workbook to an output stream. Then use that output stream to channel the bytes into a post you can send to the receiving URL.

This example shows how to post using Java

http://samindaw.wordpress.com/2008/11/24/how-to-post-or-upload-a-file-to-a-url-or-servelet-using-java/

In this code:



The file is accessed as a File, but you can get the FilePart to load from a stream by using


And putting a ByteArrayPartSource as the source.

The ByteArrayPartSource in turn gets the byte[] from the output stream you used to store the excel file (ByteArrayOutputStream maybe?)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generate Excel file
 
Similar Threads
reading files
Generate Excel sheet and populate data in new IE browser
jExcelAPI: How to change format cells text in excel as general format
Jsp to Excel
read data from excel sheet and put it into the postgresql database