/** * It can receive a String, TableCell or any other IElement. * for String, text will be wrapped on a Paragraph. * * Use TableCell when you need to apply style to the Cell. Eg.: Background color. * PS.: If you need to apply "bold", "italic" or "underline" to the cell, use a Paragraph with its Pieces. * * If you pass an IElement, the getContent() method will be blindly call. So be careful on what you pass. * Remember you can always wrap elements or build your own String XML that represents what you want - Be creative! * * You can also pass 2 different kinds objects at the same time. Eg.: * <code> * tbl.addRow( TableRowV2.with( TableCell.with(Paragraph.with("Paragraph01").create()), "Simple String" ).withStyle().bold().create() ); * </code> * **/ public static TableCell with(Object cell) { if(cell instanceof TableCell){ //it is already TableCell so no need to create another instance //it is a Paragraph at this moment. It needs Column Top and Bottom ((TableCell) cell).txt.insert(0, "\n <w:tc>\n {styleCellPh}"); ((TableCell) cell).txt.append("\n </w:tc>"); return (TableCell) cell; }else{ TableCell tableCell = new TableCell(cell); return tableCell; } }
/** * It can receive a String, TableCell or any other IElement. * for String, text will be wrapped on a Paragraph. * * Use TableCell when you need to apply style to the Cell. Eg.: Background color. * PS.: If you need to apply "bold", "italic" or "underline" to the cell, use a Paragraph with its Pieces. * * If you pass an IElement, the getContent() method will be blindly call. So be careful on what you pass. * Remember you can always wrap elements or build your own String XML that represents what you want - Be creative! * * You can also pass 2 different kinds objects at the same time. Eg.: * <code> * tbl.addRow( TableRowV2.with( TableCell.with(Paragraph.with("Paragraph01").create()), "Simple String" ).withStyle().bold().create() ); * </code> * **/ public static TableCell with(Object cell) { if(cell instanceof TableCell){ //it is already TableCell so no need to create another instance //it is a Paragraph at this moment. It needs Column Top and Bottom ((TableCell) cell).txt.insert(0, "\n <w:tc>\n {styleCellPh}"); ((TableCell) cell).txt.append("\n </w:tc>"); return (TableCell) cell; }else{ TableCell tableCell = new TableCell(cell); return tableCell; } }