Italian community of Lazarus and Free Pascal
Programmazione => Generale => Topic aperto da: sergio - Marzo 19, 2016, 07:29:01 pm
-
Ragazzi . scusate , ho un problema con lazreport . Creo un report , tutto ok , lo uso , ok , poi vado a riaprirlo con lazreport , faccio una aggiunta , e mi da l'anteprima del report Pagina bianca , solo con l'aggiunta che ho fatto. Qualcuno sa perche ?? Grazie in anticipo
-
non conoscolazreport ma prova ad inserire - 'nomereport'.CloseSurface;-
alla fine dell'istruzione che lo lancia.
-
Adesso non ricordo bene, ma mi pare che il problema dipenda da come si salva il report; da qualche parte c'è la proprieta' "storeinform" che se settata su true dovrebbe prevenire quanto riportato.
Dato che le leggi di Murphy si applicano anche alla programmazione ("Ogni programma si espandera' fino ad occupare tutta la memoria disponibile"), visto che i report in un' applicazione possono essere diversi, io mi salvo i vari report in una cartella e li richiamo a runtime.
Esempio:
procedure TForm1.MenuItem80Click(Sender: TObject);
var
FromPage, ToPage, NumberCopies: Integer;
ind: Integer;
Collap: Boolean;
aText: TfrObject;
begin
// Load report definition from application directory
//AppDirectory:=ExtractFilePath(ParamStr(0));
frReport1.LoadFromFile('..\report\md31memo.lrf');
//copia il memo nel report
aText := frReport1.FindObject('Memo4');
aText.Memo.Text := memo1.Text;
// Need to keep track of which printer was originally selected to check for user changes
ind:= Printer.PrinterIndex;
// Prepare the report and just stop if we hit an error as continuing makes no sense
if not frReport1.PrepareReport then Exit;
// Set up dialog with some sensible defaults which user can change
with PrintDialog1 do
begin
Options:=[poPageNums ]; // allows selecting pages/page numbers
Copies:=1;
Collate:=true; // ordened copies
FromPage:=1; // start page
ToPage:=frReport1.EMFPages.Count; // last page
MaxPage:=frReport1.EMFPages.Count; // maximum allowed number of pages
if Execute then // show dialog; if succesful, process user feedback
begin
if (Printer.PrinterIndex <> ind ) // verify if selected printer has changed
or frReport1.CanRebuild // ... only makes sense if we can reformat the report
or frReport1.ChangePrinter(ind, Printer.PrinterIndex) //... then change printer
then
frReport1.PrepareReport //... and reformat for new printer
else
exit; // we couldn't honour the printer change
if PrintDialog1.PrintRange = prPageNums then // user made page range selection
begin
FromPage:=PrintDialog1.FromPage; // first page
ToPage:=PrintDialog1.ToPage; // last page
end;
NumberCopies:=PrintDialog1.Copies; // number of copies
// Print the report using the supplied pages & copies
frReport1.PrintPreparedReport(inttostr(FromPage)+'-'+inttostr(ToPage), NumberCopies);
end;
end;
...
Questo modus operandi mi pare sia documento da qualche parte sulla pagina di lazarus wiki