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');
}
}
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));
}
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();
}
}
}
Aggregations