如何使用Apache POI

时间:2018-06-25 08:15:33

标签: java apache-poi

我正在尝试使用Apache POI删除包含特定字符串的文档的特定段落。我在第二个答案中找到了一段代码:

https://stackoverflow.com/a/44326734/8504176

FileInputStream fis = new FileInputStream(fileName);
XWPFDocument doc = new XWPFDocument(fis);
fis.close();
// Find a paragraph with todelete text inside
XWPFParagraph toDelete = doc.getParagraphs().stream().filter(p -> StringUtils.equalsIgnoreCase("todelete", p.getParagraphText()))
        .findFirst().orElse(null);
if (toDelete != null) 
  {
    doc.removeBodyElement(doc.getPosOfParagraph(toDelete));
    OutputStream fos = new FileOutputStream(fileName);
    doc.write(fos);
    fos.close();
 }

但是equalsIgnoreCase()抛出错误,但我没有得到它:

  

线程“ main”中的异常java.lang.RuntimeException:无法编译   源代码-错误的符号类型:   com.sun.xml.internal.ws.util.StringUtils.equalsIgnoreCase

如何解决此问题?预先感谢

0 个答案:

没有答案