Can aspose word search each pages last row and first row in a cross pages table ?
In table each row,I set some cell border top and border bottom to be none when the two rows data are partial same(can not merge them).
But the data is to long that make table cross page, so if I set border top or bottom to none, will make table cross page without top border and bottom border.
Could this be solved?
The code I make cell border none cell.CellFormat.Borders[BorderType.Top].LineStyle = LineStyle.none;
And the development environment is .NET framework 4.7
@Hankch Sure, you can use LayoutCollector to check first and last row on the page in multi-page table. For example the following code highlights the the last row with blue and the first with yellow:
Document doc = new Document(@"C:\Temp\in.docx");
LayoutCollector collector = new LayoutCollector(doc);
// Get the table, for demonstration purposes us the first table.
Table t = doc.FirstSection.Body.Tables[0];
int currentPage = -1;
Row prevRow = null;
foreach (Row currentRow in t.Rows)
{
int pageIdx = collector.GetStartPageIndex(currentRow);
if (pageIdx > currentPage)
{
currentPage = pageIdx;
if (prevRow != null)
{
// Highlight with blue.
foreach (Cell c in prevRow.Cells)
c.CellFormat.Shading.BackgroundPatternColor = Color.Blue;
}
// Highlight with yellow.
foreach (Cell c in currentRow.Cells)
c.CellFormat.Shading.BackgroundPatternColor = Color.Yellow;
}
prevRow = currentRow;
}
doc.Save(@"C:\Temp\out.docx");
@Hankch Yes, cross-page table in Aspose.Words DOM is represented as one table. MS Word documents are flow documents and there is no page concept. The document layout is built on the fly when you open document in MS Word.
Please see our documentation to learn more about Aspose.Words Document Object Model.