title: Editing Word Document using Apache POI
body: <p>I am trying to read a word document template and then replace the variables from the template, with user given data.without changing the heading or style as on the tempate.I'm not sure that what I am doing is correct way or not but this is the way I started:</p>
  
  <pre><code>'XWPFDocument docx = new XWPFDocument(
              new FileInputStream(
                      "D://TestDocumentPrep/src/XXXXX_TestReport_URL_Document.docx"));
      XWPFWordExtractor we = new XWPFWordExtractor(docx);
      String textData = we.getText();
      String newTestData=textData.replace("$var_source_code$", list.get(1))
              .replace("$var_rsvp_code$", list.get(2))
              .replace("$var_ssn$", list.get(3))
              .replace("$var_zip_code$", list.get(4))
              .replace("$var_point_for_business$",
                      anotherData.getPointForBusiness())
              .replace("$var_E1_url$", anotherData.getE1url())
              .replace("$var_E2_url$", anotherData.getE2url())
              .replace("$var_E3_url$", anotherData.getE3url());
      System.out.println(newTestData);'
  </code></pre>
  
  <p>This is what I have done.But Its reading the content of the word document as a string and replacing the variables.Now how to put the replaced string in word document in the template format?</p>
  
  <p><a href="http://www.coderanch.com/t/534754/java/java/Editing-pdf-word-content-text" rel="nofollow noreferrer">Here I found something but Not exactly my solution</a>
  <br>
   <br>
  <a href="http://www.tutorialspoint.com/apache_poi_word/index.htm" rel="nofollow noreferrer">Here also I found something but not exact solution</a></p>