我正在使用POI库用Java编写一个小程序。当前,我需要在.doc文件中创建一个新的超链接。我找到了解决此问题的方法,但是它是针对XWPFDocument(.docx文件)的,而我需要一种针对HWPFDocument(.docx文件)的方法。
这是方法:
private void populateRow(List<SeEntryModel> seEntries, TableRow r, TableCell c, String versionFromTemplate) {
for (SeEntryModel seEntryModel : seEntries) {
if (seEntryModel.getVersion().equals(versionFromTemplate)) {
StringBuilder textToAdd = new StringBuilder();
List<URL> listOfEvidence = seEntryModel.getListOfEvidence();
for (URL evidence : listOfEvidence) {
// TODO add Hyperlinks
}
}
c = r.getCell(4);
Paragraph p = c.getParagraph(0);
CharacterRun run = p.getCharacterRun(0);
run.insertBefore(textToAdd.toString());
return;
}
}
}
以下是指向类似问题的链接,但它们与XWPFDocument类(.docx格式)有关: How to create a email link in POI Word Format