Search in sources :

Example 1 with BodyElementType

use of org.apache.poi.xwpf.usermodel.BodyElementType in project Gargoyle by callakrsos.

the class ReadDoc method main.

/**
	 * @작성자 : KYJ
	 * @작성일 : 2016. 1. 25.
	 * @param args
	 */
public static void main(String[] args) {
    String filesname = "(APP)(사양서)AprvSampleApp.docx";
    try {
        XWPFDocument doc = new XWPFDocument(new FileInputStream(filesname));
        doc.getBodyElements().forEach(b -> {
            BodyElementType elementType = b.getElementType();
            if (BodyElementType.TABLE.name().equals(elementType.name())) {
                XWPFTable table = (XWPFTable) b;
                System.out.println(table);
            } else if (BodyElementType.PARAGRAPH.name().equals(elementType.name())) {
                System.out.println(b);
            } else if (BodyElementType.CONTENTCONTROL.name().equals(elementType.name())) {
                System.out.println(b);
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : BodyElementType(org.apache.poi.xwpf.usermodel.BodyElementType) XWPFTable(org.apache.poi.xwpf.usermodel.XWPFTable) XWPFDocument(org.apache.poi.xwpf.usermodel.XWPFDocument) FileInputStream(java.io.FileInputStream)

Aggregations

FileInputStream (java.io.FileInputStream)1 BodyElementType (org.apache.poi.xwpf.usermodel.BodyElementType)1 XWPFDocument (org.apache.poi.xwpf.usermodel.XWPFDocument)1 XWPFTable (org.apache.poi.xwpf.usermodel.XWPFTable)1