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.
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.
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.
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.
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
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?