Exporting one pdf for each customer from a serialized report containing all customers movements

Stimulsoft Reports.NET discussion
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

Exporting one pdf for each customer from a serialized report containing all customers movements

Post by Fabio Pagano »

Consider this scenario:

I load an mdc file containing a report where, for each customer, are printed his accounting movements. Each customer movements may be on several pages.

The report is sorted for customer: when the customer changes, the page changes too.

Example:

--------------------

Page 1
...Customer code 1:
......Movement 1
......Movement 2
.........
......Movement 50

Page 2
...Customer code 1 (continued):
......Movement 51
......Movement 52
......- End of Customer 1 movements -

Page 3
...Customer code 2:
......Movement 1
......Movement 2
.........
......- End of Customer 2 movements -

--------------------

According to the example above, i would have to generate two pdf files: the first must be sent to the customer 1 (page 1-2), the second must be sent to the customer 2 (page 3).

Please note that, as said before, the report is loaded from an mdc file: the mdc file is generated by me, but i need to do the pdf generation not during the report generation but in a subsequent moment (that's why i load from an mdc file).

If anybody has some suggestion, maybe of great help for me.

My suggestion: loop through pages collection, read the "Customer code" in each page and determine the page range for each customer, then export to pdf for each page range. The problem is that i don't know how to read the customer code associated to each page, see the question embedded in this code:

Code: Select all

Dim page As Stimulsoft.Report.Components.StiPage

For Each page In rpt.RenderedPages

   'Question: how do i get the "Customer code" associated to the page?

Next
Thanks.
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Exporting one pdf for each customer from a serialized report containing all customers movements

Post by Vital »

Yes, you can use page range. This is right way. For detecting new customer you can use property Tag of page. Assign to this property expression which return name of customer. When you load report from mdc file you can read customer name from property TagValue.

Thank you.
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

Exporting one pdf for each customer from a serialized report containing all customers movements

Post by Fabio Pagano »

Thanks for the answer, it worked.
Assign to this property expression which return name of customer.
If i want to add in the page tag other fields, eg. email, so i set the tag property with "{MyTable.CustomerCode}{MyTable.EMail}" the returned TagValue is nothing.

Any suggestion?

Thanks.
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

Exporting one pdf for each customer from a serialized report containing all customers movements

Post by Fabio Pagano »

Another strange behavior.

I am testing with two customers, one on the first page and one on the second page (they have only few movements): on first page the "Page.TagValue" property (setted with "{MyTable.CustomerCode}") returns the second customer code.

If the first customer code has more movements, so he splits over the first two pages, the first page tagvalue has the first customer code, while the second and third page tagvalue have the second customer code (in fact, the second page tagvalue has the incorrect value of the second customer, while that page refers to the first customer).

It seems that the page "TagValue" contains the field value of the next page.

Thanks.
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Exporting one pdf for each customer from a serialized report containing all customers movements

Post by Vital »

New customer starts from new page?
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

Exporting one pdf for each customer from a serialized report containing all customers movements

Post by Fabio Pagano »

Yes, the new customer code is printed on a new page.

I am new to your software (i'm evaluating) so i attach this screenshot to be sure that i am doing good: my customer code is in the field "EstrattoConto.AmCod" which is the Condition of the GroupHeaderBand1.

On GroupHeaderBand1 i have setted the property "Start New Page" = True (see screenshot).

The datasource is a single datatable in which i have one row for each movement and on every row is present the customer code "EstrattoConto.AmCod".

- The screenshot is large, if needed scroll to the right.

Image

I have also added an empty GroupFooterBand1, because i have read in the manuals that the grouping bands must be paired (header and footer), but with no success.

Thanks.
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Exporting one pdf for each customer from a serialized report containing all customers movements

Post by Vital »

Fabio wrote:Another strange behavior.

I am testing with two customers, one on the first page and one on the second page (they have only few movements): on first page the "Page.TagValue" property (setted with "{MyTable.CustomerCode}") returns the second customer code.

If the first customer code has more movements, so he splits over the first two pages, the first page tagvalue has the first customer code, while the second and third page tagvalue have the second customer code (in fact, the second page tagvalue has the incorrect value of the second customer, while that page refers to the first customer).

It seems that the page "TagValue" contains the field value of the next page.

Thanks.
This is problem of report engine. We solved it. Patch will be available in prereliase build from 30 April. At this moment you can use following way:

in BeforePrintEvent of page place following code:

Code: Select all

Page1.ToolTipValue = MyTable.CustomerCode;
Thank you.
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

Exporting one pdf for each customer from a serialized report containing all customers movements

Post by Fabio Pagano »

Ok, remember the other problem too:

If i want to add in the "page tag" other fields, eg. email, so i set the tag property with "{MyTable.CustomerCode}{MyTable.EMail}", the returned TagValue is "Nothing".

The same happens if i set the tag page with something like:

"This is the customer code: {MyTable.CustomerCode}"

It seems that if in the page tag i set something more than a single field, the returned "Page.TagValue" is nothing.

Thanks.
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Exporting one pdf for each customer from a serialized report containing all customers movements

Post by Vital »

You are use vb.net as script language in report?

Thank you.
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

Exporting one pdf for each customer from a serialized report containing all customers movements

Post by Fabio Pagano »

Yes, vb.net.

--edited--

I have tried with c# and works fine. As a workaround i can actually use c# as script language.

Thanks.
Post Reply