Search code examples
javaapacheapache-poidocxcompatibility-mode

Created word document using apache poi always open in compatibility mode


I am trying to create word document using XWPF (POI-OOXML 3.16 ). The created word file opens in compatibility mode while using MS word 2016. Any solution? I don't want it to be appearing in compatibility mode.

Here is the simple code:

public static void main(String[] args) throws InvalidFormatException {
    XWPFDocument document = new XWPFDocument();

    try {
        File file = new File("path.docx");
        FileOutputStream out = new FileOutputStream(file);
        document.write(out);
        out.flush();
        out.close();
        document.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

Even though, I am not writing anything in the document, the created document (path.docx) opens in compatibility mode. I am using MS WORD 2016 on macbook pro.


Solution

  • I fixed this by creating an empty docx file using word and then used it to be modified from software