• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Generate Excel file

Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?

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


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?)
This is my favorite tiny ad:
a bit of art, as a gift, the permaculture playing cards
    Bookmark Topic Watch Topic
  • New Topic