Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

To generate Word Documents  RSS feed

 
Smita Sant
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Our application is using GWT / GXT for the UI layer. We need to generate Word documents for the reports that we generate. We cannot go for licensed versions , the reports contains charts and we our requirement is to export this to a word document. Can you provide me that options available to create word docs from Java.
 
Tim Moores
Saloon Keeper
Posts: 3511
77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For actual Word documents, I think the only free option is the Apache POI library (or using the OpenOffice Java API, but that has a big learning curve). If you only need something that Word can open and display then you might look into generating RTF, a format that's easier to create and alter than .doc or .docx.
 
Smita Sant
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You for the prompt response. I did a quick check of the POI option a while ago, and read reviews that POI for word was very limited. I was not sure if we could use it for the charts and images.
Again , I saw some other options like docx4j, docmosis etc. Again, did a quick check but I cannot be sure if they are meant for reading of word files only.
 
Tim Moores
Saloon Keeper
Posts: 3511
77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like you need to look into these tools more thoroughly so that you become sure whether or not they can serve your purposes.
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have the budget for it perhaps you can buy Aspose.Words for Java. From its site:
Aspose.Words for Java is an advanced class library for Java that enables you to perform a great range of document processing tasks directly within your Java applications.

Aspose.Words for Java supports DOC, OOXML, RTF, HTML and OpenDocument formats. With Aspose.Words you can generate, modify, and convert documents without using Microsoft Word.
 
Smita Sant
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You, I will research on that one too. I also found reference to OpenOffice UNO (Universal Network Objects) , Do you know if this refers to the OpenOffice Java API that was referred to in this same thread.
 
Tim Moores
Saloon Keeper
Posts: 3511
77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that's the same thing.
 
Smita Sant
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another related question - If my firm is ready to invest money on this and If I have the freedom to use paid products what are the reliable options that I have
 
Smita Sant
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I tried using Aspose , but it again has limiations with resepct to charts. We will need bar charts , stacked bar charts , pie charts and the like in word document. Can you suggest some tools that ake it possible to create such a document using java
 
Tim Moores
Saloon Keeper
Posts: 3511
77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are various libraries you can use to create such charts, foremost JFreeChart. You'll get an image that you can then add to the document.
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Microsoft word has this "Round Trip" XML format, meaning if you save as XML, word will be able to open that XML file as a word document.

If you export a word document as XML and put it on your server, you can use it as a template and manipulate the xml in java in a number of ways (search and replace, etc) and then download it as a word document.
In my project, I use certain keywords in the word document [USERNAME] that will be replaced with the actual user name when the user downloads it.

If you need more than simple replace, there is a library called java2word that uses this XML concept to create and manipulate word documents. It bills itself as "The missing library to generate MS Word Documents from Java code without any special components."

a new version was just released in February. If you don't wish to use the library, it at least will have some good examples in the code of how you could do it yourself.

EDIT: I haven't tried to do any fancy charts with java2word. I would agree that creating images in JFreeChart and then putting them in as images would be the way to go. Is the requirement that you have to have actual functioning Microsoft charts in your document?
 
Smita Sant
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
THank You , I will look into the tools and libraries mentioned.

My requirement does not need functioning Microsoft charts. I will only need the images . Need to generate a sort of report that displays the GWT components that the UI displays.

 
Bryan Glass
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I may be too late, but I just created an application that exports to DOCX. I used the docx4j library: http://www.docx4java.org
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!