Free Support Forum - aspose.com

Row span missing?

Hi support,

The cell object has a method to set the column span. I didn't notice the one for row span. Is there any solution to achieve vertically merged cells ? Inserting empty cells is not the perfect solution : every cell has borders, and if my "parent" cell has more text than other cells from the table, than its borders will be pushed to match the text, even if this could be avoided if there wouldn't be boundaries between the merged cells. Thus, other cells will be resized and this is undesirable.

If there isn't any simple solution at this moment, please approximate the time when this option will be available. This option is very important for our product.

Best regards,
Milan Cutlac

Hello milan,

You are right. You cannot set the Row span for Cell. But you can work another way around: using addNestedTable(Table nestedTable) method. We are not planning to provide cell.setRowSpan method because the nested table can get the same effect.

Thank you for using our product!

Hi Sandy.Zhang,

Please consider the following case, and confirm if it can be acomplished using nested tables:

I have a table with two columns and three rows, with 6 cells. But I want to obtain a custom table, with just four cells, like this:

Custom table cells Original table cells
cell 1 = 1st and 2nd cell from 1st column
cell 2 = 3rd cell from 1st column
cell 3 = 1st cell from 2nd column
cell 4 = 2nd and 3rd cell from 2nd column.

I don’t want to parse the original table: it is here just for the issue description . I just want to create the custom table from scratch .

Regards,
Milan

Hello milan,

I think you can get what you want through this way:

First, you create a main Table with two columns and two rows;

Second, you create a nest Table with one column and two rows, and add this table to the 1st cell of 1st row from the main Table;

Third, you create a nest Table with one column and two rows, and add this table to the 2nd cell of 2nd row from the main Table.

Then you can finish your work. Hopefully this works. Thank you for using our product!

Hi Sandy.Zhang,

I attach two images : one is about the table I want to obtain : “desired table.jpg”, and the other is the one that results from your solution : “your table.jpg”. The table drawed in “desired table.jpg” is just a piece from a table with tens of rows and columns with plenty of horizonatally&vertically chaotic merged cells.

Thank you for looking into this,
Milan

Hello milan,

I have seen your image: “desired table.jpg”. You can get the desired effect via the following code:

Table table = new Table(sec1);
table.setColumnWidths(“100 100”);

//add a row
Row row1 = new Row(table);
table.getRows().add(row1);

Cell cell1 = new Cell(row1);
row1.getCells().add(cell1);

Table nestedTable1 = new Table(sec1);
nestedTable1.getRows().add().getCells().add(“put more content here, so you can get this cell have a big height”);
nestedTable1.getRows().add().getCells().add(“little”);
cell1.addNestedTable(nestedTable1);


Cell cell2 = row1.getCells().add();
Table nestedTable2 = new Table(sec1);
nestedTable2.getRows().add().getCells().add(“little”);
nestedTable2.getRows().add().getCells().add(“put more content here, so you can get this cell have a big height”);
cell2.addNestedTable(nestedTable2);

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

But the cell’s border doesn’t function well for nestedTable at present. You can use the nestedTable’s table border instead, although there are some difference between them. We are working on it and will give you a solution in the next release.

Thank you for using our product.

Hi Sandy.Zhang,

I want to obtain "desired table.jpg" without adding extra characters or empty spaces and lines to fill the cells. As far as I can see, nested tables can be used when the final form of the table is known. Take for this affirmation the attachment that comes with this entry. The table from it is build at runtime, and the information about row span and column span comes with the cells. Every time a cell that has span information is received, a new review and re-arrangement for the inserted cells and nested tables is required. And this can turn to a difficult cell&table management.

Thank you for looking into this,
Milan

Hello milan,

I have seen your “custom table.png”. Maybe this table is too difficult for Aspose Pdf for Java to generate. We are trying to find a convenient way to help you to get that kind of Table. But We cannot estimate when we will provide that function. We will notice you as soon as we find a solution.

I’m sorry to bring your so much trouble. Thank you for using our product!