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

Creating Multiple worsheets in Excel document using servlets

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

I tried to output my html tables into the excel sheet just by setting the response.setContentType method and got succeeded without using any APIs like POI or JXL. Now, can anyone help me to create a multiple workshhets in the same excel file without any APIs and just by using the servelt's setContentType method only..

Regards,
Bhaskar
 
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm 99% sure that this can't be done, because Excel does not support this.
 
bhaskar selvaraj
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:I'm 99% sure that this can't be done, because Excel does not support this.



Hi Dittmer,

Which one is not possible? Creating the Excel file or creating multiple sheets in a single excel file??
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is easily possible to create an Excel file containing multiple sheets using a library like Apache POI. What I don't think is possible is to create HTML tables, and somehow have Excel import that into a document containing multiple sheets (which is what you asked).

My name is Ulf, by the way. If you prefer to call me by my last name, then the polite way to do so is to call me "Mr. Dittmer". First name is fine, though.
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What did you set as your content type? and when you say HTML table, you mean it has <table> <td><tr> tags?
 
bhaskar selvaraj
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I set the content-type as "application/vnd.ms-excel". I am trying to write the html tables (<table> <td><tr> tags) in the excel file as below:

where = "sample.xls";
File f = new File(where);
Writer w = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f)));
w.write("<table border=1>\r\n");

This will create a single worksheet.


Regards,
Bhaskar
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Bhaskar,

I believe you have set the response object's content type to the following.



It means the response object writes this data to ms-excel format.

Serlvet API can only set the content type to microsoft excel format. There is no API for creating for multiple workbook.

If you have verified the generated xls file, you could have noticed only one worksheet possibly without the grey lines. Servlet API supports only the content type to microsoft excel, but not the Excel creation API.

If you have table data or results put it into an arraylist , initialize the jxl write class to write it to multiple worksheet.

Till now Oracle Corp, has not found Servlet API to create excel worksheets.

Regards,
Ronald Reagan Jr
 
bhaskar selvaraj
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ronald,

Thanks for your clarification. Now i am clear that we can generate only one work sheet in the excel using servlets. In order to create multiple worksheet we need to use Java Excel APIs like JXL or APache POI.



Regards,
Bhaskar
 
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using text-based templates to generate multi-part sheets in XML format works fine for me.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic