Forum > LazReport

excluding page from export before PrepareReport

(1/2) > >>

calm_sea:
Hello everybody! I have a multi-page report. How can I exclude a page from export at run time?

Zvoni:
So, basically you're looking for an option like

"Print Pages: 1-10;12-20" --> Exclude Page 11

and the Result is a PDF with 19 Pages, missing page 11?

GetMem:
Hi calm_sea,


--- Quote ---I have a multi-page report. How can I exclude a page from export at run time?
--- End quote ---
You can't, it's much easier to exclude a page when you generate the report by filtering the dataset. However if you still wish to go with your idea, please take a look at ($LazarusDir)\components\lazreport\source\lr_class.pas, line 11215, you will see the following:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TfrReport.ExportBeforeModal(Sender: TObject);var  i: Integer;begin  if IsMainThread then Application.ProcessMessages;  for i := 0 to EMFPages.Count - 1 do  begin    FCurrentFilter.OnBeginPage;    EMFPages.ExportData(i);    InternalOnProgress(i + 1);    if IsMainThread then Application.ProcessMessages;    FCurrentFilter.OnEndPage;  end;  FCurrentFilter.OnEndDoc;  if frProgressForm<>nil then    frProgressForm.ModalResult := mrOk;end;    
The thing is you have to prevent the execution of EMFPages.ExportData(i) for a specific page i. There are many ways to implement this, like a public variable SkipPages. You also have to adjust the page count of the exported document.

Zvoni:

--- Quote from: GetMem on August 31, 2021, 10:19:26 am ---Hi calm_sea,


--- Quote ---I have a multi-page report. How can I exclude a page from export at run time?
--- End quote ---
You can't, it's much easier to exclude a page when you generate the report by filtering the dataset. However if you still wish to go with your idea, please take a look at ($LazarusDir)\components\lazreport\source\lr_class.pas, line 11215, you will see the following:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TfrReport.ExportBeforeModal(Sender: TObject);var  i: Integer;begin  if IsMainThread then Application.ProcessMessages;  for i := 0 to EMFPages.Count - 1 do  begin    FCurrentFilter.OnBeginPage;    EMFPages.ExportData(i);    InternalOnProgress(i + 1);    if IsMainThread then Application.ProcessMessages;    FCurrentFilter.OnEndPage;  end;  FCurrentFilter.OnEndDoc;  if frProgressForm<>nil then    frProgressForm.ModalResult := mrOk;end;    
The thing is you have to prevent the execution of EMFPages.ExportData(i) for a specific page i. There are many ways to implement this, like a public variable SkipPages. You also have to adjust the page count of the exported document.

--- End quote ---
Could he use a Class-Helper overriding that Procedure?
In that way he could use "for..In...Do" with a set (see also Wiki about Defensive Programming)

calm_sea:
I'm sorry, I didn't explain well. I have a lrf with 3 pages, the first two contain general data and are contained in a sheet for each, the third is a dataset that can occupy many pages in the export. I would like to allow the user to exclude the insertion of one or both of the first two pages of the lrf with checkboxes.

Navigation

[0] Message Index

[#] Next page

Go to full version