Hello,
I’m using the LINQ engine. Is it possible to understand when a table goes to a new page, in order to replicate some sub-rows in addition to the title? Are there any other solutions?
@Blegork,
Could you please ZIP and attach your input template document? We will then provide you code example and/or updated template document needed to get desired result according to your requirement.
Hi,
thank you for replying. I am attaching the Java code, and the output document that I would like to have. When I go to a new page, in addition to repeating the header of the table, I would like to repeat the row with the subheader, in the output file it is row number 13, the one in red.
@Blegork,
To get the desired result, you need to update output document after bulding a report, using Aspose.Words API. Please check the following code:
Document doc = new Document("C:\\Temp\\Report_out.docx");
Table table = (Table)doc.getChild(NodeType.TABLE, 0, true);
Row boldRow = new Row(doc);
LayoutCollector collector = new LayoutCollector(doc);
LayoutEnumerator enumerator = new LayoutEnumerator(doc);
double maxPos = 0;
double thisRowPos;
for (Row r : table.getRows())
{
//getting vertical position of row
enumerator.setCurrent(collector.getEntity((Node)r));
thisRowPos = enumerator.getRectangle().getY();
if (thisRowPos > maxPos || Math.abs(maxPos - thisRowPos) < 1)
maxPos = thisRowPos;
Cell cellOfRow = (Cell)r.getChild(NodeType.CELL, 0, true);
Run runOfCell = (Run)cellOfRow.getChild(NodeType.RUN, 0, true);
//remember needed subtitle row
if ((runOfCell != null) && runOfCell.getFont().getBold() && runOfCell.getText().startsWith("Deposito"))
boldRow = (Row)r.deepClone(true);
//if this row's position is less then max pos of page, that means that row is on a new page
if (thisRowPos < maxPos)
{
table.insertBefore(boldRow, r);
boldRow = (Row)boldRow.deepClone(true);
maxPos = 0;
doc.updatePageLayout();
}
}
doc.save("C:\\Temp\\Report_out_final.docx");
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.