I am trying to modify a docx, but I end up with the following error:
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/poi/javax/xml/stream/XMLStreamReader;
at org.apache.xmlbeans.XmlBeans.buildStreamToNodeMethod(XmlBeans.java:247)
at org.apache.xmlbeans.XmlBeans.<clinit>(XmlBeans.java:134)
at org.apache.xmlbeans.XmlBeans.typeLoaderForClassLoader(XmlBeans.java:715)
at org.openxmlformats.schemas.wordprocessingml.x2006.main.DocumentDocument$Factory.getTypeLoader(Unknown Source:25)
at org.openxmlformats.schemas.wordprocessingml.x2006.main.DocumentDocument$Factory.parse(Unknown Source:0)
at org.apache.poi.xwpf.usermodel.XWPFDocument.onDocumentRead(XWPFDocument.java:177)
at org.apache.poi.ooxml.POIXMLDocument.load(POIXMLDocument.java:184)
at org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(XWPFDocument.java:144)
at cn.com.minstone.modu.component.poi.WordToHtml.createDocx(WordToHtml.java:118)
at cn.com.minstone.modu.component.poi.PoiActivity.lambda$onCreate$2(PoiActivity.java:50)
This is my code :
InputStream inputStream = new FileInputStream(rootPath + fileName);
XWPFDocument xwpfDocument = new XWPFDocument(inputStream);
List<XWPFParagraph> xwpfParagraphs = xwpfDocument.getParagraphs();
for (XWPFParagraph xwpfParagraph : xwpfParagraphs) {
List<XWPFRun> xwpfRuns = xwpfParagraph.getRuns();
for (XWPFRun xwpfRun : xwpfRuns) {
xwpfRun.setBold(false);
xwpfRun.setColor("#FF7F24");
}
}
try (OutputStream fileOut = new FileOutputStream(rootPath + fileName)) {
xwpfDocument.write(fileOut);
}
I am trying to modify a docx, but I end up with the following error:
This is my code :
And I Have added this in onCrate():