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

Writing Word Files From Java

 
Bartender
Posts: 1973
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Are there good solutions (mature or relatively stable) to write word documents from Java, say from a ByteArrayOutputStream?

Apache's HWPF POI project sounds like it's in it's infancy. Also, I couldn't find any examples how to use it.

OpenOffice has an API you could program to. Let OO output the word documents for you. Not sure how easy this might be.

Is anyone out there using either of the two technologies above?

If not, can you recommend a better way to go about creating Word docs from Java?

Thanks.

- mike
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The one time I had to do this, I used iText and rendered to RTF, which Word can read.
 
Sheriff
Posts: 22815
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've used POI last year to read a Word file. The results were disappointing. No idea how much it has improved since then.
 
Mike London
Bartender
Posts: 1973
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply.

From the sounds of the Apache forum "We're really looking for somebody to lead this project ...." type of language, it doesn't sound like it's come that far.

What do you think about using OpenOffice's API and letting OpenOffice handle the dirty work?

Not sure how easy or doable this is.

-- M
 
Rob Spoor
Sheriff
Posts: 22815
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's probably the best solution. Unfortunately, "best" usually does not mean "easiest".
 
Mike London
Bartender
Posts: 1973
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, thanks. Appreciate your follow up.

mike
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IMO, POI is OK at extracting text, but not so much at creating or altering existing files. OpenOffice can do it all, but I've found its Java API to have a steep learning curve, and consequently have yet to use it for anything serious.

For something formatted that Word can open RTF would be my choice. If you create an empty file in Word with all the formattings, and placeholders for the actual content, and then save it as RTF, you can create nicely looking documents simple by text search-and-replace. Or use iText to create RTF from scratch.
 
Mike London
Bartender
Posts: 1973
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used iText a couple years ago and really liked it.

That's probably the best solution.

Has iText changed a lot lately?

Thanks.

mike
 
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
iText has been progressing steadily, although the PDF part has probably seen more attention than the RTF part.

Be aware that there's a new branch of iText (iText 5), which is fairly recent and has a different license that may require users to pay up for using it. Plus, the RTF part has been split off from the PDF part. But my impression is that v5 does not so far do much more than v2.1, so sticking to v2.1 should not be problem for the time being.
 
Mike London
Bartender
Posts: 1973
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
great info, thank you!
 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic