public void example() throws Exception{ XWPFdocument document = new XWPFdocument(); //Append a link to appendExternalHyperlink("https://poi.apache.org", " link to POI", document.createParagraph()); document.write(new FileOutputStream("resultat.docx")); } public static void appendExternalHyperlink(String url, String text, XWPFParagraph paragraph){ //Add the link as External relationship String id=paragraph.getdocument().getPackagePart().addExternalRelationship(url, XWPFRelation.HYPERlink.getRelation()).getId(); //Append the link and bind it to the relationship CTHyperlink clink=paragraph.getCTP().addNewHyperlink(); clink.setId(id); //Create the linked text CTText ctText=CTText.Factory.newInstance(); ctText.setStringValue(text); CTR ctr=CTR.Factory.newInstance(); ctr.setTArray(new CTText[]{ctText}); //Insert the linked text into the link clink.setRArray(new CTR[]{ctr}); }