How do I change color of a particular word document using apache poi?
问题 Current output: Needed output: above are the snapshots of the .docx and below is the code sample code, I want to change the color of a after it is replaced by @ . r.setColor("DC143C") doesn't work: for (XWPFParagraph p : docx.getParagraphs()) { List<XWPFRun> runs = p.getRuns(); if (runs != null) { for (XWPFRun r : runs) { String origText = r.getText(0); if (origText != null && origText.contains("a")) { origText = origText.replace("a", "@"); r.setText(origText, 0); } } } } 回答1: If the need is