I want to do an application in which I want to insert table and an image into msword 2003 doc file . If any one know please help me with a sample code.
There's a library called Apache POI that can work with Word documents (you can find a simple example of how to create a DOC file using it at http://faq.javaranch.com/java/CreateWordDocument), but I think it will be a frustrating experience to use it for changes to complex documents (and I'm not even sure that it would ultimately be successful).
Are you creating a new file, or do you want to modify an existing file? If the former, you might have better luck creating an RTF file - which is a much simpler file format to generate, and which also supports tables and images.
I am already using this Apache POI and I am going to try to modify the existing doc file with the insertion of table and image .
When I inserted a table into doc file with following code for insertion its inserting but with out borders so it is not visible doc file.If you solved this problem I am greatly thanks to you.Thanku in advance
It's neither free nor open source, but there's a really awesome product called Aspose that allows complete manipulation of the MS Word object model. I've used it a fair amount, and it's pretty impressive.
Thank you for replying whether Aspose which you told is an open source. If it is opensource i am pretty happy .Because I am doing an application in which complex doc operation should be done.thanks in advance
I'd advise to create a Word document that looks like the one you want to create, and then save it as RTF. Then you can study the RTF that gets created (which is text, and not too hard to understand). Now you can either a) create an entire RTF file from scratch that contains your content, or b) use an existing RTF file as template which contains placeholders for the content you want to add (something like "$image$" or "$table$"); these can then be replaced with the actual content using string operations.
What do you mean, "provide"? The API documentation is available on the Aspose web site, along with examples and other stuff. What else are you looking for?
It seems that you are looking for an easy solution in which you need to invest neither effort nor money; such a solution does not exist.
harish Rudra wrote:Thank you for replying whether Aspose which you told is an open source. If it is opensource i am pretty happy .Because I am doing an application in which complex doc operation should be done.thanks in advance
No, Aspose is not an open source technology. In fact, from some stack traces that I've seen they employ an obfuscator to protect their product -- a logical decision if you ask me!
They do allow a free trial where Aspose simply applies a watermark to all generated documents indicating it is unlicensed.
We did a lot of searching and quite frankly this is the best solution available -- but it has its price. If you're working on an open source (i.e. not for profit) project, this is probably not the solution for you.
As Ulf pointed out, working with RTF may be an option for you -- but realize that the RTF specification is... extensive. You can download the entire spec here: http://tinyurl.com/yhsgqb5
harish Rudra wrote:I am already using this Apache POI and I am going to try to modify the existing doc file with the insertion of table and image .
When I inserted a table into doc file with following code for insertion its inserting but with out borders so it is not visible doc file.If you solved this problem I am greatly thanks to you.Thanku in advance
hi harish rudra, i need the java code for copying a png image and pasting it in ms word document. It would be really helpful for me if you give me the code for it. thanks in advance.