You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by "madhurgrover17@gmail.com" <ma...@gmail.com> on 2014/06/09 11:59:51 UTC

Doc file corruption containing expanding/collapsing headings.

Hi Team,

I am using Apache POI to replace some data in Doc file format.

If the doc file contains *expanding/collapsing headings *and the replaceable
string occurs before that heading in the context then after replacing the
string the new Doc file generated is corrupt.

As per my findings if the /location of  expanding/collapsing headings link's
position changes due to some replace/ then it leads to file corruption.

Code Snippet:
	        HWPFDocument document = new HWPFDocument(fileInputStream);
		Range range = document.getRange();

		//Word-Extractor
		WordExtractor we = new WordExtractor(document);

		//get paragraphs array 
		String[] paragraphArray = we.getParagraphText();

		//traverse through each paragraph
		
		for (int i = 0; i < paragraphArray.length; i++) {
			
			Paragraph paragraph2 = range.getParagraph(i);
			paragraph2.replaceText(paragraph2.text(), "Replacing String");

		}
		document.write(fileOutputStream);	


Please help me in fixing this issue.

Thanks in advance.




--
View this message in context: http://apache-poi.1045710.n5.nabble.com/Doc-file-corruption-containing-expanding-collapsing-headings-tp5715807.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org