Free Support Forum - aspose.com

Apose pdf for Java: RowSpan in Tables won't work

Hello
i am trying to do a rowspan in one cell but it won’t work.
Is it a bug or is my code wrong?

My code:

Cell cell11 = new Cell(table, “some text”);
cell11.setRowSpan(2);
row1.getCells().add(cell11);

Cell cell12 = new Cell(table,“some more text”);
row1.getCells().add(cell12);

//add another row
Row row2 = new Row(table);
table.getRows().add(row2);

Cell cell21 = new Cell(table,“another some text”);
row2.getCells().add(cell21);

Cell cell22 = new Cell(table,“another some more text”);
row2.getCells().add(cell22);

//add table to sec1
sec1.getParagraphs().add(table);


thanks for help
vland

Hi,
I’m sorry,setRowSpan method is not supported in Cell class. We add this method to keep the identical interface with the Cell in .net. You can use NestedTable to get the same effect with setRowSpan. In that way, your code can be rewritten as follows:

Cell cell11 = new Cell(table, “some text”);
//cell11.setPadding( new MarginInfo(10, 0, 0, 0));
Row row1 = table.getRows().add();
row1.getCells().add(cell11);

Cell cell12 = new Cell(table);
row1.getCells().add(cell12);
Table table2 = new Table(cell12);
table2.getRows().add().getCells().add(“some more text”);
table2.getRows().add().getCells().add(“another some more text”);
cell12.addNestedTable(table2);

You can also use the setPadding method to adjust the position of the content (like the code which has been commented).
Hopefully, this will help, thank you for your advice.

Thanks for help,
i did another workaround i put emtpy cells into the table.
vland

Hello,
my customer didn’t like my workaround with empty cells for the rowspan.
Could you please support the rowspan in the aspose java pdf?


thanks
vland

Hello vland,

This function is very difficult to implement. We will not support this issue in the next release. We will support this function in the future, but we don’t know when we will provide this function.

Thank you for using our product.

Hello,

anything new about this issue?

sincerly

vland

Hello Vland,

We recently have released a version of Aspose.Pdf for Java 2.6.0 which includes the method Cell.setRowSpan(..); which can serve your purpose. Please try using this version and in case you face any problem or you have any further query, please feel free to contact.

You can download Aspose.Pdf for Java 2.6.0 from here.