Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating Multiple worsheets in Excel document using servlets

 
bhaskar selvaraj
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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: 42968
73
  • Mark post as helpful
  • send pies
  • 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.
 
Jayesh A Lalwani
Rancher
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Rajesh Ronald Reagan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Ivan Jozsef Balazs
Rancher
Posts: 981
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using text-based templates to generate multi-part sheets in XML format works fine for me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic