• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Generate Excel file

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?)
 
Remember to always leap before you look. But always take the time to smell the tiny ads:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic