2

I'm using RTF template to create a BI report. I need to limit the number of rows into 3 records on the 1st page only. The remaining records/rows will continue to fill the next pages. I'm also required to print the page total. I used the code below to limit the number of records, however it prints only 1 row. Any help will be appreciated. thanks

<?xdoxslt:set_variable($_XDOCTX, ‘counter’, 0)?>
<?xdoxslt:set_variable($_XDOCTX, ‘lines_page’, 3)?>
<?xdoxslt:set_variable($_XDOCTX, ‘tot_lines’, count(.//PdfDraftPurchaseOrderHeaderVORow))?> 
<?xdoxslt:set_variable($_XDOCTX,’remainder’,0)?>

<?for-each:PdfDraftPurchaseOrderHeaderVORow?>
<?xdoxslt:set_variable($_XDOCTX, ‘counter’, xdoxslt:get_variable($_XDOCTX, ‘counter’)+1)?>
<?if@row:xdoxslt:get_variable($_XDOCTX,’counter’) != xdoxslt:get_variable($_XDOCTX,’tot_lines’)?>
<?if@row:position() mod xdoxslt:get_variable($_XDOCTX, ‘lines_page’) = 0?><?call:breaking?><?end if?><?end if?>
<?end for-each?>

2 Answers2

2

Try using this within the for-each

<?if: position() = 3?> 
<?split-by-page-break:?>
<?end if?> 

I made a simple example and this worked just fine. I got 3 records on the first page, and 6 on the rest.

As for page totals, add this after the element you want to sum, where TotalFieldName is the name of the total variable and Element is the XML number element you want to sum

<?add-page-total:TotalFieldName;Element?> 

Add this in the footer for the page total, where TotalFieldName is the variable we created above, and the NumberFormat is something like 9G999D00

<?show-page-total:TotalFieldName; 'NumberFormat'?>
EdHayes3
  • 1,777
  • 2
  • 16
  • 31
  • Hello, I already fixed the split by page break issue but the page total is still in progress. I found out that the data im adding is in string format so I tried to convert it to number data type but according to oracle documentation, the page totaling function only works if the source XML co6de has raw numeric values. The numbers must not be preformatted. Is there a workaround for this? Thank you for your help – Liezel Francisco Nov 03 '17 at 12:56
  • I read that too, and I don't think there is. should be easy to fix the XML data definition though. – EdHayes3 Nov 04 '17 at 21:49
1

you can use this syntax, if you want to break a page after n number of rows:

<? if position() mod 3 = 0?> 
<?split-by-page-break:?>
<?end if?>

this will break the page after 3 rows, then after 6 rows and so on for every 3 multiple. You can replace 3 with your desired row count.

By the way position() is the row number in your xml data source.


bhuvan karuturi
  • 311
  • 2
  • 8