Table header row and first row of data is not on same page

Dear Aspose,

I am facing issue for table appearience. we display contants in table format. issue is that during the display there may arise condition that header of the table appears as last line of page and data starts displaying from next page. We don't want such condition. We want to ensure that header of the table and at least first row of data appears on same page. Please advice how we can do it in aspose.

1. Is it possible via setting some table properties in word template. we do not want to use page break before table.

2. used template for table display is attached with thread.

3. Condition for which i am talking about is depicted in attached document.

thanks

arvind

Hi Arvind,


Thanks for your inquiry.

You can restrict content inside the Cells of a Row from being split across a page. In Microsoft Word this can be found under Table Properties as the option ‘Allow Row to break across Pages’. In Aspose.Words this is found under the RowFormat object of a Row as the property RowFormat.AllowBreakAcrossPages. Please read the following article for more details:
http://www.aspose.com/docs/display/wordsnet/Keeping+Tables+and+Rows+from+Breaking+across+Pages

I hope, this helps.

Best regards,

Hi thanks for reply,

Actualy my requirement is to ensure that header of the table and at least first row of data come together. it should not split in different pages as shown in sent attachment.

Solution provided by you is regarding not splitting row data on different pages. we need method so that header of table and first (at least) row of data lies on same page.we don't want situation where header of row comes on one page and data startes from other page.

thanks

arvind

Hi Arvind,


Thanks for the additional information. I think, you can implement the following workflow to achieve this:

1) Implament IFieldMergingCallback Interface.
2) In the FieldMergingCallback event, insert a hidden Bookmark at a suitable place inside the first Row using DocumentBuilder. We just need to flag the first Row in Table and you can skip all the remaining records.
3) Now come to the statement right after ExecuteWithRegions method in the Main method.
4) Move the cursor to the hidden Bookmark (i.e. inserted in the first Row during MailMerge) using DocumentBuilder
5) Get the Table using GetAncestor method like: Table table = (Table)builder.CurrentNode.GetAncestor(NodeType.Table);
6) Iterate through first few Rows in this Table and find Page Numbers of each Row. You can use LayoutCollector.GetStartPageIndex method to get 1-based index of the page where Row/Cell node begins.
7) If they are not on same page, add some logic here to push back the Row(s) to previous page

I hope, this helps.

Best regards,