• 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

Can Servlet out data as MS-WORD format?

 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,
I would like a servlet get data from DB and format the data, then output as a WORD file when user click on the link, is it possible? Thanks.
 
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try setting the content type of the response to application/msword. I haven't tried it, but it is a standard content type.
 
Ken Shamrock
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to format the WORD/Excel files? Or just attach a plain text on those files? Thanks!
 
Author
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Originally posted by Ken Shamrock:

Is it possible to format the WORD/Excel files?


well dear
You can surely format them, in case of Excel, set the proper content type & while outputting the data, dont start with standard HTML tags but only start with "<table><tr><td>" & so on...
this will help you to format the Excel tables...
with WORD you can format as standard text.
hth
MB
 
Ken Shamrock
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, thanks. Let me try.
 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a jakarta project called POI.
It's a java API for manipulating MS file formats.
It include several subprojects, like the Horrible Document Format (For MS-WORD format) and the Horrible Spreadsheet Format (for Excel files).
You can find more info in the POI website:
http://jakarta.apache.org/poi/
For manipulating Excel files, there is another solution:
You can do it using JDBC. MS provides an ODBC driver for Excel, so you can use JDBC and the Sun JDBC-ODBC driver to read Excel files.
Check the Javaworld Java/Microsoft Excel series:
http://www.javaworld.com/javaworld/javaqa/2001-06/04-qa-0629-excel.html

HTH
 
Ken Shamrock
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all,
I've tried output simple information as XLS or WORD doc. (It's Strange that with <html> I can still the displayed format in the xls file)
Another idea comes, you know, an excel file can consist of several spreadsheets, if I want to do this, must I need to use the POS mentioned by Juanjo Bazan ? Thanks
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also need a servelt to generate a word doc.
It did when i set the contenttype to
application/msword .But when it got saved it dint save with a .doc.I had to open with ms word.
.I need it to have .doc format so that i can print it. do help.
thanks
 
No prison can hold Chairface Chippendale. And on a totally different topic ... my stuff:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic