Recent

Author Topic: [SOLVED] single report, each page diferent  (Read 3288 times)

mirce.vladimirov

  • Full Member
  • ***
  • Posts: 220
[SOLVED] single report, each page diferent
« on: March 30, 2012, 11:46:32 am »
Hi everybody,
How can i create a report that would be able to send many pages as one printing task. For example, I have data for 10 phone users, all of them with different information about the call timing and SMS-ing, and I want to print a separate Invoice for each of them, but I need the 10 diferent invoices to be included into only one printing task,
I need this for two reasons :
1)  when the preview-box pops-up and asks me to choose a printer I could send the whole task to a PDF pseudo printer and create one single PDF file that contains all of the Invoices. (i dont know another way of creating PDF files with lazreport)
2) because i dont want the preview-box to stop and wait for confirmation (it waits you to choose printer, number of copies etc etc etc), for each one of my 10 diferent (or imagine a 100 diferent) invoices, so I must click the "OK" button all day
« Last Edit: April 07, 2012, 10:13:36 pm by mirce.vladimirov »

mirce.vladimirov

  • Full Member
  • ***
  • Posts: 220
Re: single report, each page diferent
« Reply #1 on: March 30, 2012, 03:51:49 pm »
... Or, how could I atleast bypasss the preview-box ? When the report is done, to go straight to my default printer and start printing immediately instead of see the preview ?

This is solved, it's simple :
Code: [Select]
frReport1.PrepareReport;
frReport1.PrintPreparedReport('1',1);
//frreport1.ShowReport;
The enclosed ('1',1) means, ("page number one", one copy).
First parameter (page number) is expected string and it can also be set to a range of pages like '3-5'
the second parameter is integer, number of copies.
The line with "showreport" is to exactly show the report. To show the preview.
« Last Edit: March 30, 2012, 05:05:23 pm by mirce.vladimirov »

mirce.vladimirov

  • Full Member
  • ***
  • Posts: 220
Re: SOLVED [single report, each page diferent]
« Reply #2 on: April 04, 2012, 09:12:11 pm »
So, the issue was How to send many documents (let's say ten thousend Invoices) to a printer as one printing task.
It's so simple I hated myself, here it is:
First of all you need a query like "select customer_id, invoice_number, invoice_date, detail_id, quantity, price, vat, total from my_invoices". The result is expected to be:
-----------------------------------------------------------------------------------------------------------
customer_id | invoice_number | invoice_date | detail_id  | quantity | price | vat  | total
------------------------------------------------------------------------------------------------------------
1                  | 000001              | 27.12.2012 | Coca-Cola | 10.00     | 1.00  | 18%|   1.18
1                  | 000001              | 27.12.2012 | Pepsi-Cola|   5.00     | 0.80  | 18%|   0.94
1                  | 000001              | 27.12.2012 | Fanta        |   3.00     | 0.90  | 18%|   1.06
13                | 000002              | 28.12.2012 | Coca-Cola | 100.00   | 1.00  | 18%|   1.18
13                | 000002              | 28.12.2012 | Cigarets    | 120.00   | 10.00| 18%| 11.80
and so on...
Start creating a new report. When you try to add a band, make that band "Group Header". Lazreport asks about what is the grouping condition, you should name your query and the field "invoice_number". And after you place the band on the empty page, right-click on it and choose "Force New Page". Now you have a "Group Header", and naturally that could require a "group footer" if you need calculated sums or similar. Enjoy.