views:

605

answers:

1

I try to write down the result of the POI unit test at: code here, by adding the line

daDoc.write(new FileOutputStream("C:\\wordtest.doc"));

to the end of the method testRangeReplacementAll. The new document is corrupt when I try to open it with word 2003.

Any suggestions to fix this?

+1  A: 

I would at least try to narrow this down, since that test does a number of things.

  1. Can you open the original file in Word 2003 ?
  2. can you open the file and immediately resave as another without doing any replacements. Does that open in Word 2003 ?
  3. can you perform one replacement at least ?
Brian Agnew
I can only replace text which has an equal length to the placeholder. Means ${xy} can be replaced with 12345 and not with 1234 or 123456
Martin K.
Can you open the original file in Word 2003 ? << yes can you open the file and immediately resave as another without doing any replacements. Does that open in Word 2003 ? << i can open the original file. The replace result can't be opened.I use the .doc file from the JUnit test case: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/data/testRangeReplacement.doc?view=coLike I said, the test went fine but the result can't be opened if i save it to a new .doc file.
Martin K.