We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Facing problem to split table based on business logic


Please refer Attached Document which represent my current problem related to splinting table b/w pages.

We are using Aspose.Word API to generate the document. Can you please provide a sample in C# which uses Aspose.Word API to split the table.


Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. You can not insert Page break into the table, so you should split your table to few separate tables and insert page breaks between these tables. For example see the following code:

//Open document

Document doc = new Document(@"Test059\in.doc");

//Create DocumentBuilder

DocumentBuilder builder = new DocumentBuilder(doc);

//Get collection of Rows from the document

NodeCollection rows = doc.GetChildNodes(NodeType.Row, true);

//Loop though rows

foreach (Row row in rows)


if (!row.IsFirstRow)


if (row.FirstCell.CellFormat.Shading.BackgroundPatternColor == Color.FromArgb(255,255,0,0))


//Create new Paragraph and insert it after old table

Paragraph par = new Paragraph(doc);

row.ParentTable.ParentNode.InsertAfter(par, row.ParentTable);

//Create new Table

Table newTab = new Table(doc);

//Copy rows after current row into the new Table

Node currentRow = row;

while (currentRow != null)


if (currentRow.NextSibling != null)


currentRow = currentRow.NextSibling;






currentRow = currentRow.NextSibling;



//Insert new table into the document

par.ParentNode.InsertAfter(newTab, par);

//Insert Page brek between tables






//Save output document


Hope this helps.

Best regards.

Hi Alexey,

Thanks for your response. Problem with having multiple tables is that Gap appears between two tables. As per our requirement tables on same page should be combined.

Let me know resolution for ASAP.




Thanks for your inquiry. You can’t determine whether table can fit in a page or not. Aspose.Words document represents content and formatting of a document, not its layout into lines and pages. This feature is called pagination and it is not released yet.

Best regards.