title: How to solve Package should contain a content type part [M1.13] in Word Document
body: <p>I am trying to create a header in word file using Apache POI but i am getting, Package should contain a content type part [M1.13]  exception.I am using the following jars</p>
  
  <pre><code>dom4j-1.7-2.jar
  poi-ooxml-3.9-2.jar
  poi-3.9.jar
  poi-scratchpad-3.9.jar
  xmlbeans-2.4.0.jar
  openxml4j.jar
  poi-ooxml-schemas-3.9.jar
  </code></pre>
  
  <p>the code i am trying to run is </p>
  
  <pre><code>   public class TestHeader {
  
  /**
   * @param args
   * @throws IOException
   * @throws XmlException
   */
  public static void main(String[] args) throws IOException, XmlException {
      InputStream input = new FileInputStream("D:\\test.docx");
      XWPFDocument document = new XWPFDocument(input);
      XWPFHeaderFooterPolicy headerPolicy = new XWPFHeaderFooterPolicy(
              document);
  
      XWPFHeader header = headerPolicy.getDefaultHeader();
      List&lt;XWPFTable&gt; table = header.getTables();
  
      for (XWPFTable xwpfTable : table) {
          xwpfTable.getRow(1).getCell(0).setText("aaa"); // document.setTable(0,
                                                          // xwpfTable);
          // header.insertTable(1, xwpfTable);
      }
      // System.out.println(header.getTables());
      FileOutputStream out = new FileOutputStream("D:\\test.docx");
      document.write(out);
      out.close();
  
     }
  
  }
  </code></pre>
  
  <p>This is the exception i am getting</p>
  
  <pre><code>Exception in thread "main" org.apache.poi.POIXMLException: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should contain a content type part [M1.13]
  at org.apache.poi.util.PackageHelper.open(PackageHelper.java:41)
  at org.apache.poi.xwpf.usermodel.XWPFDocument.&lt;init&gt;(XWPFDocument.java:120)
  at com.core.poi.TestHeader.main(TestHeader.java:24)
  Caused by: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should contain a content type part [M1.13]
  at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:178)
  at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:662)
  at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:269)
  at org.apache.poi.util.PackageHelper.open(PackageHelper.java:39)
  ... 2 more
  </code></pre>
  
  <p>Somebody please help me.</p>