public static TableRow with(Object ... colls) { return new TableRow(colls); }
/** * You always have to use TableRow to add new rows to the table. Eg.: * <code> * tbl.addRow( TableRowV2.with("Simple String cell") ); * </code> * See documentation on method "TableRowV2.with" for very detailed information. * * @param row * @return */ public TableRow addRow(TableRow row) { //the row will have cells. The Row knows how to do the rest... txt.append(row.getContent()); return row; }
TableV2 tbl = new TableV2(); tbl.addRow( TableRow.with("Table Header in all Pages", "Usefull for reports").withStyle().repeatTableHeaderOnEveryPage().create() ); tbl.addRow( TableRow.with("Simple String cell", "Another simple String cell") ); tbl.addRow( TableRow.with( TableCell.with(Paragraph.with("TableCell- Style to the whole cell, Par").create()), "Simple String" ).withStyle().bold().create() ); tbl.addRow( TableRow.with("Style to the whole cell, Str", "String").withStyle().bold().create() ); tbl.addRow( TableRow.with( TableCell.with(Paragraph.with("TableRowV2 with merge").create()).withStyle().gridSpan(2).create() ).withStyle().bold().create() ); tbl.addRow( TableRow.with( TableCell.with(Paragraph.withPieces( ParagraphPiece.with("Paragraph with Style inside TableCell").withStyle().bold().fontSize("20").create() ).create()).withStyle().bgColor("00FFFF").create(), "String" )); tbl.addRow( TableRow.with("this google logo: ", "Image here: "+ img + " == image before") ); tbl.addRow( TableRow.with("111", "") ); tbl.addRow( TableRow.with("LAST", "LAST") );
@Ignore @Test public void test93() { IDocument myDoc = new Document2004(); // String xmlTemplate = Utils.readFile("/home/leonardo/Desktop/paulo_93.doc"); //String xmlTemplate = Utils.readFile("/home/leonardo/Desktop/template_branco.xml"); String xmlTemplate = Utils.readFile("/home/leonardo/Desktop/template.doc"); TableV2 tbl = new TableV2(); tbl.addRow(TableRow.with("Simple String cell", "Another String simple cell")); xmlTemplate = replacePh(xmlTemplate, "<w:t><phTabela></w:t>", tbl.getContent()); System.out.println(xmlTemplate.trim()); //System.out.println(tbl.getContent()); //TestUtils.createLocalDoc(xmlTemplate.replace("</w:body>", tbl.getContent() + "</w:body>")); TestUtils.createLocalDoc(xmlTemplate.trim()); }
@Test public void testWithHeaderOnEveryPage() { TableV2 tbl = new TableV2(); tbl.addRow( TableRow.with("").withStyle().repeatTableHeaderOnEveryPage().create() ); tableBasicCheckings(tbl.getContent()); assertEquals(1, TestUtils.regexCount(tbl.getContent(), "<w:tblHeader/>")); //empty paragraph assertEquals(1, TestUtils.regexCount(tbl.getContent(), "<w:p><w:r></w:r></w:p>")); //empty paragraph }
@Test public void testStringEmptyString() { TableV2 tbl = new TableV2(); tbl.addRow( TableRow.with("") ); tableBasicCheckings(tbl.getContent()); assertEquals(0, TestUtils.regexCount(tbl.getContent(), "<w:tblHeader/>")); //empty paragraph assertEquals(1, TestUtils.regexCount(tbl.getContent(), "<w:p><w:r></w:r></w:p>")); //empty paragraph }
@Test public void testStringOnly() { TableV2 tbl = new TableV2(); tbl.addRow( TableRow.with("str01", "str02").withStyle().repeatTableHeaderOnEveryPage().create() ); assertEquals(1, TestUtils.regexCount(tbl.getContent(), "<w:t>str01</w:t>")); assertEquals(1, TestUtils.regexCount(tbl.getContent(), "<w:t>str02</w:t>")); tableBasicCheckings(tbl.getContent()); }
public static TableRow with(Object ... colls) { return new TableRow(colls); }
/** * You always have to use TableRow to add new rows to the table. Eg.: * <code> * tbl.addRow( TableRowV2.with("Simple String cell") ); * </code> * See documentation on method "TableRowV2.with" for very detailed information. * * @param row * @return */ public TableRow addRow(TableRow row) { //the row will have cells. The Row knows how to do the rest... txt.append(row.getContent()); return row; }