Search in sources :

Example 51 with XWPFDocument

use of org.apache.poi.xwpf.usermodel.XWPFDocument 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

XWPFDocument (org.apache.poi.xwpf.usermodel.XWPFDocument)51 Test (org.junit.Test)15 FileOutputStream (java.io.FileOutputStream)11 File (java.io.File)9 XWPFParagraph (org.apache.poi.xwpf.usermodel.XWPFParagraph)9 XWPFRun (org.apache.poi.xwpf.usermodel.XWPFRun)9 InputStream (java.io.InputStream)6 OutputStream (java.io.OutputStream)6 FileInputStream (java.io.FileInputStream)4 XWPFTable (org.apache.poi.xwpf.usermodel.XWPFTable)4 OPCPackage (org.apache.poi.openxml4j.opc.OPCPackage)3 NPOIFSFileSystem (org.apache.poi.poifs.filesystem.NPOIFSFileSystem)3 XMLSlideShow (org.apache.poi.xslf.usermodel.XMLSlideShow)3 XWPFWordExtractor (org.apache.poi.xwpf.extractor.XWPFWordExtractor)3 XWPFFooter (org.apache.poi.xwpf.usermodel.XWPFFooter)3 XWPFHeader (org.apache.poi.xwpf.usermodel.XWPFHeader)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ZipFile (java.util.zip.ZipFile)2 HSLFSlideShow (org.apache.poi.hslf.usermodel.HSLFSlideShow)2 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)2