Move the current line to next page on condition. LINQ Reporting Engine

@alexey.noskov
In word document, I would like to move the current line to next page when I see number one (1) at the begin of the line.
Example:

1 DLL051 TEST NAME FIRST NAME LAST NAME PAGE: 1
1 DLL026 TEST NAME FIRST NAME LAST NAME PAGE: 2
1 DLL088 TEST NAME FIRST NAME LAST NAME PAGE: 3

I am using the below, but its moving the line after the current line to next page.

<<foreach [items in PrintLineData]>><<[items.PrintLine]>><<if [items.PrintLine.StartsWith(“1”)]>><<[“\f”]>><<else>><<[“\r\n”]>><</if>><</foreach>>

How can I move the current line to next page if it has 1 at the beginning. If it is possible, can this be avoided for the first page. Please advise.

@manikantakondepati

Please try using the following template instead:

<<foreach [items in PrintLineData]>><<if [items.PrintLine.StartsWith(“1”)]>><<[“\f”]>><</if>><<[items.PrintLine]>><<[“\r\n”]>><</foreach>>

To avoid inserting a page break for the first item, you can further change your template as follows:

<<foreach [items in PrintLineData]>><<if [items.PrintLine.StartsWith(“1”) && IndexOf() != 0]>><<[“\f”]>><</if>><<[items.PrintLine]>><<[“\r\n”]>><</foreach>>

@ivan.lyagin

<<foreach [items in PrintLineData]>><<if [items.PrintLine.StartsWith(“1”) && IndexOf() != 0]>><<[“\f”]>><</if>><<[items.PrintLine]>><<[“\r\n”]>><</foreach>>

That worked like a charm, Thank you…

can we further improvise the template to remove number one (“1”) on the first page.

I know we can use doc.Range.Replace function outside the template, just checking to see if we can do this in the template.

@manikantakondepati

can we further improvise the template to remove number one (“1”) on the first page.

Am I right thinking that you want to remove “1” when outputting <<[items.PrintLine]>>? If so, then you can use other System.String members such as Substring directly in templates to achieve that. Here is an example: <<[items.PrintLine.Substring(1)]>>.

@ivan.lyagin

1 DLL051 TEST NAME FIRST NAME LAST NAME PAGE: 1
1 DLL026 TEST NAME FIRST NAME LAST NAME PAGE: 2
1 DLL088 TEST NAME FIRST NAME LAST NAME PAGE: 3

I wanted to use the number one (“1”) as a page break, which is accomplished by the conditional block you provided below.

<<foreach [items in PrintLineData]>><<if [items.PrintLine.StartsWith(“1”) && IndexOf() != 0]>><<[“\f”]>><</if>><<[items.PrintLine]>><<[“\r\n”]>><</foreach>>

Attached the output,

Now, I wanted to remove number one (“1”) and zero (“0”) which are at the beginning of the lines from the attached document.testing.docx (21.1 KB)

Can you please help me with the updated conditional block for this.

@manikantakondepati

As far as I see from the output, there are four extra characters at a beginning of every line. Then, to exclude the extra characters while outputting, you can change your template as follows:

<<foreach [items in PrintLineData]>><<if [items.PrintLine.StartsWith(“1”) && IndexOf() != 0]>><<[“\f”]>><</if>><<[items.PrintLine.Substring(4)]>><<[“\r\n”]>><</foreach>>

@ivan.lyagin Awesome, thanks a ton… Working as expected.