SpreadSheet doesn't work with subreport in code
Hello Everybody,
Sorry about so many questions, but the fact is that I'm a beginner that
need to make real complex reports as soon as possible.
I need to make subreports in code in a spreadsheet style. So, I used
the code described at the news about tech tips -"Create subreports in code"
and the code described at
http://www.digital-metaphors.com/tips/spreadsheetstylereport.zip. Separately
they work very well, but when I put them together, the pages aren't
reordered. Does anybody knows what can be wrong?
CODE:
procedure TForm1.ppReport1BeforePrint(Sender: TObject);
var texto: tppDBText;
i:integer;
tam: single;
lLabel,lLabel2: TppLabel;
lDBText: TppDBText;
begin
lSubReport0 := TppSubReport.Create(Self); // lSubReport, lSubReport0,
lReport and lReport0 are declared
//at
private area of the form1
lSubReport0.PrintBehavior := pbSection;
lSubReport0.ParentPrinterSetup := FALSE;
lSubReport0.ResetPageNo := FALSE;
lSubReport0.TraverseAllData := FALSE;
lSubReport0.Band := ppReport1.DetailBand;
lSubReport0.CreateReport(ppReport1);
lSubReport := TppSubReport.Create(Self);
lSubReport.PrintBehavior := pbSection;
lSubReport.ParentPrinterSetup := FALSE;
lSubReport.ResetPageNo := FALSE;
lSubReport.TraverseAllData := FALSE;
lSubReport.Band := ppReport1.detailband;
lSubReport.CreateReport(ppReport1);
lReport0 := TppChildReport(lSubReport0.Report);
lReport0.OnEndFirstPass := lReport0EndFirstPass;
lReport0.AutoStop := FALSE;
lReport0.DataPipeline := ppBDEPipeline1;
lReport0.CreateDefaultBands;
lLabel2 := TppLabel.Create(Self);
lLabel2.Band := lReport0.TitleBand;
lLabel2.Caption := 'Nepomuceno';
tam :=0;
for i := 1 to 9 do
begin
texto := tppDBText.Create(nil);
texto.UserName := 'DBText'+inttostr(i);
texto.DataField := campos[i]; // campos is a constant which has names
of fields
texto.DataPipeline := ppBDEPipeline1;
texto.Left := tam;
texto.Band := lReport0.DetailBand;
texto.AutoSize := true;
texto.Transparent := true;
tam := tam + texto.width + 1.0;
end;
lReport := TppChildReport(lSubReport.Report);
lReport.OnEndFirstPass := lReportEndFirstPass;
lReport.AutoStop := FALSE;
lReport.DataPipeline := ppBDEPipeline1;
lReport.CreateDefaultBands;
lLabel := TppLabel.Create(Self);
lLabel.Band := lReport.TitleBand;
lLabel.Caption := 'Customers';
lLabel.Font.Name := 'Times New Roman';
lLabel.Font.Size := 24;
lDBText := TppDBText.Create(Self);
lDBText.Band := lReport.DetailBand;
lDBText.DataPipeline := ppBDEpipeline1;
lDBText.DataField := 'CustNo';
end;
Sorry about so many questions, but the fact is that I'm a beginner that
need to make real complex reports as soon as possible.
I need to make subreports in code in a spreadsheet style. So, I used
the code described at the news about tech tips -"Create subreports in code"
and the code described at
http://www.digital-metaphors.com/tips/spreadsheetstylereport.zip. Separately
they work very well, but when I put them together, the pages aren't
reordered. Does anybody knows what can be wrong?
CODE:
procedure TForm1.ppReport1BeforePrint(Sender: TObject);
var texto: tppDBText;
i:integer;
tam: single;
lLabel,lLabel2: TppLabel;
lDBText: TppDBText;
begin
lSubReport0 := TppSubReport.Create(Self); // lSubReport, lSubReport0,
lReport and lReport0 are declared
//at
private area of the form1
lSubReport0.PrintBehavior := pbSection;
lSubReport0.ParentPrinterSetup := FALSE;
lSubReport0.ResetPageNo := FALSE;
lSubReport0.TraverseAllData := FALSE;
lSubReport0.Band := ppReport1.DetailBand;
lSubReport0.CreateReport(ppReport1);
lSubReport := TppSubReport.Create(Self);
lSubReport.PrintBehavior := pbSection;
lSubReport.ParentPrinterSetup := FALSE;
lSubReport.ResetPageNo := FALSE;
lSubReport.TraverseAllData := FALSE;
lSubReport.Band := ppReport1.detailband;
lSubReport.CreateReport(ppReport1);
lReport0 := TppChildReport(lSubReport0.Report);
lReport0.OnEndFirstPass := lReport0EndFirstPass;
lReport0.AutoStop := FALSE;
lReport0.DataPipeline := ppBDEPipeline1;
lReport0.CreateDefaultBands;
lLabel2 := TppLabel.Create(Self);
lLabel2.Band := lReport0.TitleBand;
lLabel2.Caption := 'Nepomuceno';
tam :=0;
for i := 1 to 9 do
begin
texto := tppDBText.Create(nil);
texto.UserName := 'DBText'+inttostr(i);
texto.DataField := campos[i]; // campos is a constant which has names
of fields
texto.DataPipeline := ppBDEPipeline1;
texto.Left := tam;
texto.Band := lReport0.DetailBand;
texto.AutoSize := true;
texto.Transparent := true;
tam := tam + texto.width + 1.0;
end;
lReport := TppChildReport(lSubReport.Report);
lReport.OnEndFirstPass := lReportEndFirstPass;
lReport.AutoStop := FALSE;
lReport.DataPipeline := ppBDEPipeline1;
lReport.CreateDefaultBands;
lLabel := TppLabel.Create(Self);
lLabel.Band := lReport.TitleBand;
lLabel.Caption := 'Customers';
lLabel.Font.Name := 'Times New Roman';
lLabel.Font.Size := 24;
lDBText := TppDBText.Create(Self);
lDBText.Band := lReport.DetailBand;
lDBText.DataPipeline := ppBDEpipeline1;
lDBText.DataField := 'CustNo';
end;
This discussion has been closed.
Comments
before the call to PrintToCache.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com