Example usage for org.apache.poi.xwpf.usermodel XWPFDocument getBodyElements

List of usage examples for org.apache.poi.xwpf.usermodel XWPFDocument getBodyElements

Introduction

In this page you can find the example usage for org.apache.poi.xwpf.usermodel XWPFDocument getBodyElements.

Prototype

@Override
public List<IBodyElement> getBodyElements() 

Source Link

Document

returns an Iterator with paragraphs and tables

Usage

From source file:org.obeonetwork.m2doc.generator.DocumentGenerator.java

License:Open Source License

/**
 * creates the destination document.//from  ww w.  j a  v  a 2s.  c om
 * 
 * @param inputDocumentFileName
 *            the name of the destination document's file.
 * @return the created document
 * @throws IOException
 *             if an I/O problem occurs.
 * @throws InvalidFormatException
 *             if the generated file has a format problem.
 */
private XWPFDocument createDestinationDocument(String inputDocumentFileName)
        throws IOException, InvalidFormatException {
    FileInputStream is = new FileInputStream(inputDocumentFileName);
    OPCPackage oPackage = OPCPackage.open(is);
    XWPFDocument document = new XWPFDocument(oPackage);
    int size = document.getBodyElements().size();
    for (int i = 0; i < size; i++) {
        document.removeBodyElement(0);
    }
    return document;
}

From source file:org.obeonetwork.m2doc.generator.test.TemplateProcessorTest.java

License:Open Source License

private XWPFDocument createDestinationDocument(String inputDocumentFileName)
        throws IOException, InvalidFormatException {
    FileInputStream is = new FileInputStream(inputDocumentFileName);
    OPCPackage oPackage = OPCPackage.open(is);
    XWPFDocument document = new XWPFDocument(oPackage);
    int size = document.getBodyElements().size();
    for (int i = 0; i < size; i++) {
        document.removeBodyElement(0);//  w w w .  j  a  v  a2 s . c om
    }
    return document;
}