Example usage for org.apache.poi.xwpf.usermodel XWPFTable getText

List of usage examples for org.apache.poi.xwpf.usermodel XWPFTable getText

Introduction

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

Prototype

public String getText() 

Source Link

Document

Convenience method to extract text in cells.

Usage

From source file:cn.afterturn.easypoi.word.parse.ParseWord07.java

License:Apache License

private void parseWordSetValue(MyXWPFDocument doc, Map<String, Object> map) throws Exception {
    // ?//from  ww  w . j ava2  s .c  o m
    parseAllParagraphic(doc.getParagraphs(), map);
    // ?,
    parseHeaderAndFoot(doc, map);
    // ?
    XWPFTable table;
    Iterator<XWPFTable> itTable = doc.getTablesIterator();
    while (itTable.hasNext()) {
        table = itTable.next();
        if (table.getText().indexOf(START_STR) != -1) {
            parseThisTable(table, map);
        }
    }

}

From source file:com.qihang.winter.poi.word.parse.ParseWord07.java

License:Apache License

private void parseWordSetValue(MyXWPFDocument doc, Map<String, Object> map) throws Exception {
    // ?//from w  w w.  j  av  a  2 s.c  om
    parseAllParagraphic(doc.getParagraphs(), map);
    // ?,
    parseHeaderAndFoot(doc, map);
    // ?
    XWPFTable table;
    Iterator<XWPFTable> itTable = doc.getTablesIterator();
    while (itTable.hasNext()) {
        table = itTable.next();
        if (table.getText().indexOf("{{") != -1) {
            parseThisTable(table, map);
        }
    }

}

From source file:File.DOCX.ReadDocx.java

public void ReadTable(String path, String filename) {
    try {/*from w  ww  . j a  v  a2 s  .c o  m*/
        FileInputStream fis = new FileInputStream(path + filename + ".docx");
        XWPFDocument xdoc = new XWPFDocument(OPCPackage.open(fis));
        Iterator<IBodyElement> bodyElementIterator = xdoc.getBodyElementsIterator();
        while (bodyElementIterator.hasNext()) {
            IBodyElement element = bodyElementIterator.next();
            if ("TABLE".equalsIgnoreCase(element.getElementType().name())) {
                List<XWPFTable> tableList = element.getBody().getTables();
                for (XWPFTable table : tableList) {
                    System.out.println("Total Number of Rows of Table:" + table.getNumberOfRows());
                    System.out.println(table.getText());
                }
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}