This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am trying to work on a project that would allow me to do text replacement in pdf & word file.
I spend some time using iText to edit pdf(doing text replacement), but it does not work efficiently. The formatting is lost, words overlap etc.
I am now trying to do similar thing in word document. I am trying to use poi project from poi.apache.org. I am not able to do text replacement or editing existing word document.
When i run the program , i am generating output file : Copy.doc. When i try to open the file it give me the following error: word was unable to read this document. It may be corrupt
Please suggest what needs to be done.
Joined: Mar 22, 2005
I'm surprised you even got the code to compile; that means you're using an old version of POI. When I tried it just now I had to replace "usesUnicode" by "isUnicode" to get it compile against POI 3.7. Then I was able to create and open the output file using both LibreOffice and Mellel just fine (I don't have Word around). And, also important, the replacement was done correctly :-)
Try upgrading to the latest POI version; each new version has lots of bug fixes.
Joined: May 18, 2005
I am using poi3.7. I also made the change replace "usesUnicode" by "isUnicode".
Following is my code
Not sure if i have to make some other change to make this thing work correctly.
Joined: May 18, 2005
I am working on poi 3.7 and running the test case testRangeInsertion from file TestRangeInsertion.java. I added the following lines of code
and the final function is as follows:
I am not able to open the output file generated from the above test case. Any suggestions. This problem is similar to the above problem. I am not able to understand why the newly created file is corrupted/not opening using MS word.
I am able to read and edit document and also the code you posted is making new document file but that document file
is not able to open in MS Word 2007. Did you find any solution to problem ??
please reply... Its urgent...
Joined: Jun 22, 2009
Hello Ulf Dittmer,
As you have said that you are able to create and open the output file using both LibreOffice and Mellel just fine
and you don't have MS Word around. So if you can open the file with MS word and check if you are able to do that.
Because i am not able to open it with Office 2007.
I have used POI 3.7 and POI 3.8 Beta 3, same result with both APIs