代码:
public static OutputStream replaceBySteam(InputStream srcStream, String destPath, Map<String, String> map,String name,String id,HttpServletResponse response) throws Exception {
XWPFDocument document = new XWPFDocument(srcStream);
return replace(document, destPath, map, name, id, response);
}
private static OutputStream replace(XWPFDocument document, String destPath, Map<String, String> map, String name, String id, HttpServletResponse response) {
OutputStream outStream = null;
try {
/**
* 替换段落中的指定文字
*/
Iterator<XWPFParagraph> itPara = document.getParagraphsIterator();
while (itPara.hasNext()) {
XWPFParagraph paragraph = itPara.next();
List<XWPFRun> runs = paragraph.getRuns();
for (XWPFRun run : runs) {
String oneparaString = run.getText(run.getText