Search in sources :

Example 6 with XWPFTableRow

use of org.apache.poi.xwpf.usermodel.XWPFTableRow in project poi by apache.

the class XWPFWordExtractor method appendTableText.

private void appendTableText(StringBuffer text, XWPFTable table) {
    //this works recursively to pull embedded tables from tables
    for (XWPFTableRow row : table.getRows()) {
        List<ICell> cells = row.getTableICells();
        for (int i = 0; i < cells.size(); i++) {
            ICell cell = cells.get(i);
            if (cell instanceof XWPFTableCell) {
                text.append(((XWPFTableCell) cell).getTextRecursively());
            } else if (cell instanceof XWPFSDTCell) {
                text.append(((XWPFSDTCell) cell).getContent().getText());
            }
            if (i < cells.size() - 1) {
                text.append("\t");
            }
        }
        text.append('\n');
    }
}
Also used : XWPFTableCell(org.apache.poi.xwpf.usermodel.XWPFTableCell) XWPFSDTCell(org.apache.poi.xwpf.usermodel.XWPFSDTCell) XWPFTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow) ICell(org.apache.poi.xwpf.usermodel.ICell)

Example 7 with XWPFTableRow

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

the class MSWord method mergeCellHorizon.

/**
	 * 수평셀 병합
	 *
	 * @param table
	 * @param rowNum
	 * @param colNum
	 * @param span
	 */
public void mergeCellHorizon(XWPFTable table, int rowNum, int colNum, int span) {
    XWPFTableRow row = table.getRow(rowNum);
    XWPFTableCell cell = row.getCell(colNum);
    CTDecimalNumber grdSpan = cell.getCTTc().getTcPr().getGridSpan();
    if (grdSpan == null) {
        grdSpan = cell.getCTTc().getTcPr().addNewGridSpan();
    }
    grdSpan.setVal(BigInteger.valueOf((long) span));
}
Also used : XWPFTableCell(org.apache.poi.xwpf.usermodel.XWPFTableCell) CTDecimalNumber(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDecimalNumber) XWPFTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow)

Example 8 with XWPFTableRow

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

the class MSWord method addTableCell.

private static void addTableCell(DIRECTION dir, XWPFTable table, int currentRow, int span) {
    int dirRowIndex = 0;
    if (DIRECTION._0 == dir) {
        dirRowIndex = currentRow + 1;
    } else if (DIRECTION.UP_DOWN == dir) {
        dirRowIndex = currentRow - 1;
    }
    XWPFTableRow belowRow = table.getRow(dirRowIndex);
    if (belowRow != null) {
        // 병합된 span만큼 셀을 추가한다.
        for (int i = 0; i < span - 1; i++) {
            belowRow.createCell();
        }
    }
}
Also used : XWPFTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow)

Aggregations

XWPFTableRow (org.apache.poi.xwpf.usermodel.XWPFTableRow)8 XWPFTableCell (org.apache.poi.xwpf.usermodel.XWPFTableCell)7 XWPFParagraph (org.apache.poi.xwpf.usermodel.XWPFParagraph)3 XWPFTable (org.apache.poi.xwpf.usermodel.XWPFTable)3 CTTblPr (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr)3 FileOutputStream (java.io.FileOutputStream)2 OutputStream (java.io.OutputStream)2 ICell (org.apache.poi.xwpf.usermodel.ICell)2 XWPFDocument (org.apache.poi.xwpf.usermodel.XWPFDocument)2 XWPFRun (org.apache.poi.xwpf.usermodel.XWPFRun)2 XWPFSDTCell (org.apache.poi.xwpf.usermodel.XWPFSDTCell)2 CTDecimalNumber (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDecimalNumber)2 CTHeight (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHeight)2 CTShd (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTShd)2 CTString (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString)2 CTTbl (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl)2 CTTcPr (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcPr)2 CTTrPr (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTrPr)2 CTVerticalJc (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTVerticalJc)2 File (java.io.File)1