for(Page page:pages){ List<Row> rows=page.getRows(); XWPFTable table = document.createTable(rows.size(), totalColumn); table.getCTTbl().getTblPr().unsetTblBorders(); table.getCTTbl().addNewTblPr().addNewTblW().setW(BigInteger.valueOf(DxaUtils.points2dxa(tableWidth)));
XWPFDocument doc = new XWPFDocument(); XWPFTable table = doc.createTable(1,2); table.getCTTbl().addNewTblGrid().addNewGridCol().setW(BigInteger.valueOf(6000)); table.getCTTbl().getTblGrid().addNewGridCol().setW(BigInteger.valueOf(2000)); table.getRow(0).getCell(0).setText("1A"); table.getRow(0).getCell(1).setText("1B"); XWPFTableRow newrow = table.createRow(); newrow.getCell(0).setText("2A"); newrow.getCell(1).setText("2B");
public static void main(String[] args) throws IOException { XWPFDocument document = new XWPFDocument(); XWPFTable tableOne = document.createTable(); XWPFTableRow tableOneRowOne = tableOne.getRow(0); tableOneRowOne.getCell(0).setText("Header1"); tableOneRowOne.addNewTableCell().setText("header2"); XWPFTableRow tableOneRowTwo = tableOne.createRow(); tableOneRowTwo.getCell(0).setText("Data1"); tableOneRowTwo.getCell(1).setText("Data2"); FileOutputStream outStream = new FileOutputStream("test.doc"); document.write(outStream); outStream.close(); }
XWPFTable table = document.createTable();
XWPFTable table = document.createTable(rows, cols);
XWPFTable table = document.createTable();
destDoc.createTable();
XWPFTable table = document.createTable();
run.setText("The table:"); XWPFTable ltable = document.createTable(1,1);
XWPFTable table = document.createTable(3,5);
XWPFTable table = document.createTable();
XWPFTable table = document.createTable();
public static void createSimpleTable() throws Exception { try (XWPFDocument doc = new XWPFDocument()) { XWPFTable table = doc.createTable(3, 3); table.getRow(1).getCell(1).setText("EXAMPLE OF TABLE"); // table cells have a list of paragraphs; there is an initial // paragraph created when the cell is created. If you create a // paragraph in the document to put in the cell, it will also // appear in the document following the table, which is probably // not the desired result. XWPFParagraph p1 = table.getRow(0).getCell(0).getParagraphs().get(0); XWPFRun r1 = p1.createRun(); r1.setBold(true); r1.setText("The quick brown fox"); r1.setItalic(true); r1.setFontFamily("Courier"); r1.setUnderline(UnderlinePatterns.DOT_DOT_DASH); r1.setTextPosition(100); table.getRow(2).getCell(2).setText("only text"); try (OutputStream out = new FileOutputStream("simpleTable.docx")) { doc.write(out); } } }
XWPFTable table = document.createTable(4, 3);
for(Page page:pages){ List<Row> rows=page.getRows(); XWPFTable table = document.createTable(rows.size(), totalColumn); table.getCTTbl().getTblPr().unsetTblBorders(); table.getCTTbl().addNewTblPr().addNewTblW().setW(BigInteger.valueOf(DxaUtils.points2dxa(tableWidth)));
XWPFTable table = doc.createTable(nRows, nCols);
run.addBreak(); table = document.createTable(rw, cl); table.getCTTbl().getTblPr().unsetTblBorders();