12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208 |
- unit rptnestedgroups;
- {$mode objfpc}{$H+}
- {$I demos.inc}
- interface
- uses
- Classes,
- SysUtils,
- fpreport,
- udapp;
- type
- { TNestedGroupsDemo }
- TNestedGroupsDemo = class(TReportDemoApp)
- private
- FReportData: TFPReportUserData;
- sl: TStringList;
- rec: TStringList;
- procedure GetReportDataFirst(Sender: TObject);
- procedure GetReportDataValue(Sender: TObject; const AValueName: String; var AValue: Variant);
- procedure GetReportDataEOF(Sender: TObject; var IsEOF: Boolean);
- procedure GetReportFieldNames(Sender: TObject; List: TStrings);
- procedure ReportDataNext(Sender: TObject);
- procedure PrepareRecord;
- Protected
- procedure InitialiseData; override;
- procedure CreateReportDesign;override;
- procedure LoadDesignFromFile(const AFilename: string);
- procedure HookupData(const AComponentName: string; const AData: TFPReportData);
- public
- constructor Create(AOWner :TComponent); override;
- destructor Destroy; override;
- Class function Description : string; override;
- end;
- implementation
- uses
- fpReportStreamer,
- fpTTF,
- fpJSON,
- jsonparser,
- fpexprpars;
- const
- clGroupHeaderFooter2 = TFPReportColor($EFE1C7);
- clGroupHeaderFooter3 = TFPReportColor($DFD1B7);
- { TNestedGroupsDemo }
- procedure TNestedGroupsDemo.GetReportDataFirst(Sender: TObject);
- begin
- {$IFDEF gdebug}
- writeln('GetReportDataFirst');
- {$ENDIF}
- PrepareRecord;
- end;
- procedure TNestedGroupsDemo.GetReportDataValue(Sender: TObject; const AValueName: String; var AValue: Variant);
- begin
- {$IFDEF gdebug}
- writeln(Format('GetReportDataValue - %d', [lReportData.RecNo]));
- {$ENDIF}
- case AValueName of
- 'region': AValue := rec[0];
- 'subregion': AValue := rec[1];
- 'country': AValue := rec[2];
- 'code': AValue := rec[3];
- 'population': AValue := rec[4];
- end;
- end;
- procedure TNestedGroupsDemo.GetReportDataEOF(Sender: TObject; var IsEOF: Boolean);
- begin
- {$IFDEF gdebug}
- writeln(Format('GetReportDataEOF - %d', [lReportData.RecNo]));
- {$ENDIF}
- if FReportData.RecNo > sl.Count then
- IsEOF := True
- else
- IsEOF := False;
- end;
- procedure TNestedGroupsDemo.GetReportFieldNames(Sender: TObject; List: TStrings);
- begin
- {$IFDEF gdebug}
- writeln('********** GetReportFieldNames');
- {$ENDIF}
- List.Add('region');
- List.Add('subregion');
- List.Add('country');
- List.Add('code');
- List.Add('population');
- end;
- procedure TNestedGroupsDemo.ReportDataNext(Sender: TObject);
- begin
- PrepareRecord;
- end;
- procedure TNestedGroupsDemo.PrepareRecord;
- begin
- if FReportData.RecNo > sl.Count then
- exit;
- rec.DelimitedText := sl[FReportData.RecNo-1];
- end;
- procedure TNestedGroupsDemo.InitialiseData;
- begin
- sl := TStringList.Create;
- {$I countries2.inc}
- rec := TStringList.Create;
- rec.Delimiter := ';';
- rec.StrictDelimiter := true;
- rec.DelimitedText := sl[0]; // RecNo is 0
- end;
- procedure TNestedGroupsDemo.CreateReportDesign;
- var
- Page: TFPReportPage;
- TitleBand: TFPReportTitleBand;
- DataBand: TFPReportDataBand;
- GroupHeader1Region, GroupHeader2Subregion, GroupHeader3Initial: TFPReportGroupHeaderBand;
- Memo: TFPReportMemo;
- PageFooter: TFPReportPageFooterBand;
- GroupFooter3Initial, GroupFooter2SubRegion, GroupFooter1Region: TFPReportGroupFooterBand;
- ChildBand: TFPReportChildBand;
- Shape: TFPReportShape;
- begin
- Inherited;
- rpt.Author := 'Pascal Riekenberg';
- rpt.Title := 'FPReport Demo 13 - Nested Grouping';
- {****************}
- {*** page ***}
- {****************}
- Page := TFPReportPage.Create(rpt);
- Page.Orientation := poPortrait;
- Page.PageSize.PaperName := 'A4';
- { page margins }
- Page.Margins.Left := 25;
- Page.Margins.Top := 20;
- Page.Margins.Right := 10;
- Page.Margins.Bottom := 20;
- Page.Data := FReportData;
- Page.Font.Name := 'LiberationSans';
- {*****************}
- {*** title ***}
- {*****************}
- TitleBand := TFPReportTitleBand.Create(Page);
- TitleBand.Layout.Height := 40;
- TitleBand.Frame.Shape := fsRectangle;
- TitleBand.Frame.BackgroundColor := clReportTitleSummary;
- Memo := TFPReportMemo.Create(TitleBand);
- Memo.Layout.Left := 0;
- Memo.Layout.Top := 10;
- Memo.Layout.Width := Page.PageSize.Width - Page.Margins.Left - Page.Margins.Right;
- Memo.Layout.Height := 16;
- Memo.TextAlignment.Horizontal := taCentered;
- Memo.UseParentFont := False;
- Memo.Text := 'COUNTRY AND POPULATION AS OF 2016';
- Memo.Font.Size := 16;
- Memo := TFPReportMemo.Create(TitleBand);
- Memo.Layout.Left := 0;
- Memo.Layout.Top := 18;
- Memo.Layout.Width := Page.PageSize.Width - Page.Margins.Left - Page.Margins.Right;
- Memo.Layout.Height := 10;
- Memo.TextAlignment.Horizontal := taCentered;
- Memo.UseParentFont := False;
- Memo.Text := '(Total [formatfloat(''#,##0.0'',total_sum_population_in_M / 1000)] B)';
- Memo.Font.Size := 10;
- {**********************}
- {*** group header ***}
- {**********************}
- {*** group header 1 region ***}
- {--- group header 1 region - band 1 ---}
- GroupHeader1Region := TFPReportGroupHeaderBand.Create(Page);
- GroupHeader1Region.Layout.Height := 15;
- GroupHeader1Region.GroupCondition := 'data.region';
- GroupHeader1Region.Frame.Shape := fsRectangle;
- GroupHeader1Region.Frame.BackgroundColor := clGroupHeaderFooter;
- //GroupHeader1Region.StartOnNewPage := True;
- GroupHeader1Region.ReprintedHeader := [rsPage];
- GroupHeader1Region.IntermediateFooter := [rsPage];
- //GroupHeader1Region.FooterPosition := fpStackAtBottom;
- GroupHeader1Region.VisibleExpr := 'not InRepeatedGroupHeader';
- Memo := TFPReportMemo.Create(GroupHeader1Region);
- Memo.Layout.Left := 3;
- Memo.Layout.Top := 1;
- Memo.Layout.Width := 170;
- Memo.Layout.Height := 6;
- Memo.UseParentFont := False;
- Memo.Font.Size := 16;
- Memo.TextAlignment.Vertical := tlBottom;
- Memo.Text := 'Region: [data.region] ([formatfloat(''#,##0.0'', grp1region_sum_population_in_M)] M)';
- Memo := TFPReportMemo.Create(GroupHeader1Region);
- Memo.Layout.Left := 25;
- Memo.Layout.Top := 1;
- Memo.Layout.Width := 145;
- Memo.Layout.Height := 6;
- Memo.UseParentFont := False;
- Memo.Font.Size := 10;
- Memo.TextAlignment.Vertical := tlBottom;
- Memo.TextAlignment.Horizontal := taRightJustified;
- Memo.Text := '[formatfloat(''#0.0'', grp1region_sum_population / total_sum_population * 100)] % in World';
- ChildBand := TFPReportChildBand.Create(Page);
- ChildBand.Layout.Height := 7;
- ChildBand.VisibleExpr := 'InRepeatedGroupHeader';
- ChildBand.Frame.Shape := fsRectangle;
- ChildBand.Frame.BackgroundColor := clGroupHeaderFooter;
- GroupHeader1Region.ChildBand := ChildBand;
- Memo := TFPReportMemo.Create(ChildBand);
- Memo.Layout.Left := 3;
- Memo.Layout.Top := 1;
- Memo.Layout.Width := 170;
- Memo.Layout.Height := 4;
- Memo.Text := 'Region: [data.region]';
- {*** group header 2 subregion ***}
- {--- group header 2 subregion - band 1 ---}
- GroupHeader2Subregion := TFPReportGroupHeaderBand.Create(Page);
- GroupHeader2Subregion.Layout.Height := 2;
- GroupHeader2Subregion.GroupCondition := 'data.subregion';
- GroupHeader2Subregion.ParentGroupHeader := GroupHeader1Region;
- //GroupHeader2Subregion.StartOnNewPage := True;
- GroupHeader2Subregion.ReprintedHeader := [rsPage];
- GroupHeader2Subregion.IntermediateFooter := [rsPage];
- //GroupHeader2Subregion.FooterPosition := fpStackAtBottom;
- Shape := TFPReportShape.Create(GroupHeader2Subregion);
- Shape.Color := clGroupHeaderFooter;
- Shape.Layout.Left := 0;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := GroupHeader2Subregion.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter;
- {--- group header 2 subregion - band 2 ---}
- ChildBand := TFPReportChildBand.Create(Page);
- ChildBand.Layout.Height := 15;
- ChildBand.Frame.Shape := fsRectangle;
- ChildBand.Frame.BackgroundColor := clGroupHeaderFooter2;
- ChildBand.VisibleExpr := 'not InRepeatedGroupHeader';
- GroupHeader2Subregion.ChildBand := ChildBand;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter;
- Shape.Layout.Left := 0;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clNone;
- Shape.Layout.Left := 3;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 2;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clWhite;
- Memo := TFPReportMemo.Create(ChildBand);
- Memo.Layout.Left := 7;
- Memo.Layout.Top := 1;
- Memo.Layout.Width := 170;
- Memo.Layout.Height := 6;
- Memo.UseParentFont := False;
- Memo.Font.Size := 14;
- Memo.TextAlignment.Vertical := tlBottom;
- Memo.Text := 'Subregion: [data.subregion] ([formatfloat(''#,##0.0'', grp2subregion_sum_population_in_M)] M)';
- Memo := TFPReportMemo.Create(ChildBand);
- Memo.Layout.Left := 25;
- Memo.Layout.Top := 1;
- Memo.Layout.Width := 145;
- Memo.Layout.Height := 6;
- Memo.UseParentFont := False;
- Memo.Font.Size := 10;
- Memo.TextAlignment.Vertical := tlBottom;
- Memo.TextAlignment.Horizontal := taRightJustified;
- Memo.Text := '[formatfloat(''#0.0'', grp2subregion_sum_population / grp1region_sum_population * 100)] % in [data.region] - [formatfloat(''#0.0'', grp2subregion_sum_population / total_sum_population * 100)] % in World';
- {--- group header 2 subregion - band 3 ---}
- ChildBand := TFPReportChildBand.Create(Page);
- ChildBand.Layout.Height := 7;
- ChildBand.VisibleExpr := 'InRepeatedGroupHeader';
- ChildBand.Frame.Shape := fsRectangle;
- ChildBand.Frame.BackgroundColor := clGroupHeaderFooter2;
- GroupHeader2Subregion.ChildBand.ChildBand := ChildBand;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter;
- Shape.Layout.Left := 0;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clNone;
- Shape.Layout.Left := 3;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 2;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clWhite;
- Memo := TFPReportMemo.Create(ChildBand);
- Memo.Layout.Left := 7;
- Memo.Layout.Top := 1;
- Memo.Layout.Width := 170;
- Memo.Layout.Height := 4;
- Memo.Text := 'Subregion: [data.subregion]';
- {*** group header 3 initial ***}
- {--- group header 3 initial - band 1 ---}
- GroupHeader3Initial := TFPReportGroupHeaderBand.Create(Page);
- GroupHeader3Initial.Layout.Height := 2;
- GroupHeader3Initial.GroupCondition := 'copy(data.country,1,1)';
- GroupHeader3Initial.ParentGroupHeader := GroupHeader2Subregion;
- GroupHeader3Initial.ReprintedHeader := [rsPage];
- GroupHeader3Initial.IntermediateFooter := [rsPage];
- //GroupHeader3Initial.OverflowedFooterNeedsReprintedHeader := True;
- Shape := TFPReportShape.Create(GroupHeader3Initial);
- Shape.Color := clGroupHeaderFooter;
- Shape.Layout.Left := 0;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := GroupHeader3Initial.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter;
- Shape := TFPReportShape.Create(GroupHeader3Initial);
- Shape.Color := clGroupHeaderFooter2;
- Shape.Layout.Left := 5;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := GroupHeader3Initial.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter2;
- {--- group header 3 initial - band 2 ---}
- ChildBand := TFPReportChildBand.Create(Page);
- ChildBand.Layout.Height := 15;
- ChildBand.Frame.Shape := fsRectangle;
- ChildBand.Frame.BackgroundColor := clGroupHeaderFooter3;
- ChildBand.VisibleExpr := 'not InRepeatedGroupHeader';
- GroupHeader3Initial.ChildBand := ChildBand;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter;
- Shape.Layout.Left := 0;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clNone;
- Shape.Layout.Left := 3;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 2;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clWhite;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter2;
- Shape.Layout.Left := 5;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter2;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clNone;
- Shape.Layout.Left := 8;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 2;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clWhite;
- Memo := TFPReportMemo.Create(ChildBand);
- Memo.Layout.Left := 12;
- Memo.Layout.Top := 1;
- Memo.Layout.Width := 170;
- Memo.Layout.Height := 6;
- Memo.UseParentFont := False;
- Memo.Font.Size := 12;
- Memo.TextAlignment.Vertical := tlBottom;
- Memo.Text := '[copy(data.country,1,1)] ([formatfloat(''#,##0.0'', grp3initial_sum_population_in_M)] M)';
- Memo := TFPReportMemo.Create(ChildBand);
- Memo.Layout.Left := 25;
- Memo.Layout.Top := 1;
- Memo.Layout.Width := 145;
- Memo.Layout.Height := 6;
- Memo.UseParentFont := False;
- Memo.Font.Size := 10;
- Memo.TextAlignment.Vertical := tlBottom;
- Memo.TextAlignment.Horizontal := taRightJustified;
- Memo.Text := '[formatfloat(''#0.0'', grp3initial_sum_population / grp2subregion_sum_population * 100)] % in [data.subregion] - [formatfloat(''#0.0'', grp3initial_sum_population / grp1region_sum_population * 100)] % in [data.region] - [formatfloat(''#0.0'', grp3initial_sum_population / total_sum_population * 100)] % in World';
- Memo := TFPReportMemo.Create(ChildBand);
- Memo.Layout.Left := 90;
- Memo.Layout.Top := 10.5;
- Memo.Layout.Width := 20;
- Memo.Layout.Height := 4;
- Memo.TextAlignment.Horizontal := taRightJustified;
- Memo.Text := 'Initial %';
- Memo := TFPReportMemo.Create(ChildBand);
- Memo.Layout.Left := 110;
- Memo.Layout.Top := 10.5;
- Memo.Layout.Width := 20;
- Memo.Layout.Height := 4;
- Memo.TextAlignment.Horizontal := taRightJustified;
- Memo.Text := 'Subreg. %';
- Memo := TFPReportMemo.Create(ChildBand);
- Memo.Layout.Left := 130;
- Memo.Layout.Top := 10.5;
- Memo.Layout.Width := 20;
- Memo.Layout.Height := 4;
- Memo.TextAlignment.Horizontal := taRightJustified;
- Memo.Text := 'Region %';
- Memo := TFPReportMemo.Create(ChildBand);
- Memo.Layout.Left := 150;
- Memo.Layout.Top := 10.5;
- Memo.Layout.Width := 20;
- Memo.Layout.Height := 4;
- Memo.TextAlignment.Horizontal := taRightJustified;
- Memo.Text := 'World %';
- {--- group header 3 initial - band 3 ---}
- ChildBand := TFPReportChildBand.Create(Page);
- ChildBand.Layout.Height := 7;
- ChildBand.VisibleExpr := 'InRepeatedGroupHeader';
- ChildBand.Frame.Shape := fsRectangle;
- ChildBand.Frame.BackgroundColor := clGroupHeaderFooter3;
- GroupHeader3Initial.ChildBand.ChildBand := ChildBand;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter;
- Shape.Layout.Left := 0;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clNone;
- Shape.Layout.Left := 3;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 2;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clWhite;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter2;
- Shape.Layout.Left := 5;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter2;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clNone;
- Shape.Layout.Left := 8;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 2;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clWhite;
- Memo := TFPReportMemo.Create(ChildBand);
- Memo.Layout.Left := 12;
- Memo.Layout.Top := 1;
- Memo.Layout.Width := 170;
- Memo.Layout.Height := 4;
- Memo.Text := '[copy(data.country,1,1)]';
- {--- group header 3 initial - band 4 ---}
- ChildBand := TFPReportChildBand.Create(Page);
- ChildBand.Layout.Height := 2;
- GroupHeader3Initial.ChildBand.ChildBand.ChildBand := ChildBand;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter;
- Shape.Layout.Left := 0;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter2;
- Shape.Layout.Left := 5;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter2;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter3;
- Shape.Layout.Left := 10;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter3;
- {*** variables ***}
- rpt.Variables.AddExprVariable('population_in_M', 'StrToFloat(data.population) / 1000000', rtFloat, rtNone, '');
- rpt.Variables.AddExprVariable('grp1region_sum_population_in_M', 'sum(StrToFloat(data.population) / 1000000)', rtFloat, GroupHeader1Region);
- rpt.Variables.AddExprVariable('grp1region_sum_population', 'sum(StrToFloat(data.population))', rtFloat, GroupHeader1Region);
- rpt.Variables.AddExprVariable('grp2subregion_sum_population_in_M', 'sum(StrToFloat(data.population) / 1000000)', rtFloat, GroupHeader2Subregion);
- rpt.Variables.AddExprVariable('grp2subregion_sum_population', 'sum(StrToFloat(data.population))', rtFloat, GroupHeader2Subregion);
- rpt.Variables.AddExprVariable('grp3initial_sum_population_in_M', 'sum(StrToFloat(data.population) / 1000000)', rtFloat, GroupHeader3Initial);
- rpt.Variables.AddExprVariable('grp3initial_sum_population', 'sum(StrToFloat(data.population))', rtFloat, GroupHeader3Initial);
- rpt.Variables.AddExprVariable('total_sum_population_in_M', 'sum(StrToFloat(data.population) / 1000000)', rtFloat);
- rpt.Variables.AddExprVariable('total_sum_population', 'sum(StrToFloat(data.population))', rtFloat);
- {****************}
- {*** detail ***}
- {****************}
- DataBand := TFPReportDataBand.Create(Page);
- DataBand.Layout.Height := 8;
- DataBand.Frame.Shape := fsRectangle;
- DataBand.Frame.BackgroundColor := clDataBand;
- //DataBand.VisibleExpr := 'StrToFloat(''[population]'') > 50000000';
- Shape := TFPReportShape.Create(DataBand);
- Shape.Color := clGroupHeaderFooter;
- Shape.Layout.Left := 0;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := DataBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter;
- Shape := TFPReportShape.Create(DataBand);
- Shape.Color := clNone;
- Shape.Layout.Left := 3;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 2;
- Shape.Layout.Height := DataBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clWhite;
- Shape := TFPReportShape.Create(DataBand);
- Shape.Color := clGroupHeaderFooter2;
- Shape.Layout.Left := 5;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := DataBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter2;
- Shape := TFPReportShape.Create(DataBand);
- Shape.Color := clNone;
- Shape.Layout.Left := 8;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 2;
- Shape.Layout.Height := DataBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clWhite;
- Shape := TFPReportShape.Create(DataBand);
- Shape.Color := clGroupHeaderFooter3;
- Shape.Layout.Left := 10;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := DataBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter3;
- Shape := TFPReportShape.Create(DataBand);
- Shape.Color := clNone;
- Shape.Layout.Left := 13;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 2;
- Shape.Layout.Height := DataBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clWhite;
- Memo := TFPReportMemo.Create(DataBand);
- Memo.Layout.Left := 17;
- Memo.Layout.Top := 2;
- Memo.Layout.Width := 45;
- Memo.Layout.Height := 5;
- Memo.Text := '[data.country]';
- Memo.Options := memo.Options + [moDisableWordWrap];
- Memo := TFPReportMemo.Create(DataBand);
- Memo.Layout.Left := 55;
- Memo.Layout.Top := 2;
- Memo.Layout.Width := 25;
- Memo.Layout.Height := 5;
- Memo.TextAlignment.Horizontal := taRightJustified;
- Memo.Text := '[formatfloat(''#,##0'', StrToFloat(data.population))]';
- Memo := TFPReportMemo.Create(DataBand);
- Memo.Layout.Left := 80;
- Memo.Layout.Top := 2;
- Memo.Layout.Width := 20;
- Memo.Layout.Height := 5;
- Memo.Text := '> DEU';
- Memo.UseParentFont := false;
- Memo.Font.Color := clGreen;
- Memo.VisibleExpr := 'StrToFloat(data.population) > 82667685';
- Memo := TFPReportMemo.Create(DataBand);
- Memo.Layout.Left := 80;
- Memo.Layout.Top := 2;
- Memo.Layout.Width := 20;
- Memo.Layout.Height := 5;
- Memo.Text := '< DEU';
- Memo.UseParentFont := false;
- Memo.Font.Color := clRed;
- Memo.VisibleExpr := 'StrToFloat(data.population) < 82667685';
- Memo := TFPReportMemo.Create(DataBand);
- Memo.Layout.Left := 95;
- Memo.Layout.Top := 2;
- Memo.Layout.Width := 15;
- Memo.Layout.Height := 5;
- Memo.TextAlignment.Horizontal := taRightJustified;
- Memo.Text := '[formatfloat(''#,##0.0'',StrToFloat(data.population)/grp3initial_sum_population*100)] %';
- Memo := TFPReportMemo.Create(DataBand);
- Memo.Layout.Left := 115;
- Memo.Layout.Top := 2;
- Memo.Layout.Width := 15;
- Memo.Layout.Height := 5;
- Memo.TextAlignment.Horizontal := taRightJustified;
- Memo.Text := '[formatfloat(''#,##0.0'',StrToFloat(data.population)/grp2subregion_sum_population*100)] %';
- Memo := TFPReportMemo.Create(DataBand);
- Memo.Layout.Left := 135;
- Memo.Layout.Top := 2;
- Memo.Layout.Width := 15;
- Memo.Layout.Height := 5;
- Memo.TextAlignment.Horizontal := taRightJustified;
- Memo.Text := '[formatfloat(''#,##0.0'',StrToFloat(data.population)/grp1region_sum_population*100)] %';
- Memo := TFPReportMemo.Create(DataBand);
- Memo.Layout.Left := 155;
- Memo.Layout.Top := 2;
- Memo.Layout.Width := 15;
- Memo.Layout.Height := 5;
- Memo.TextAlignment.Horizontal := taRightJustified;
- Memo.Text := '[formatfloat(''#,##0.0'',StrToFloat(data.population)/total_sum_population*100)] %';
- {**********************}
- {*** group footer ***}
- {**********************}
- {*** group footer 3 initial ***}
- {--- group footer 3 initial - band 1 ---}
- GroupFooter3Initial := TFPReportGroupFooterBand.Create(Page);
- GroupFooter3Initial.Layout.Height := 2;
- GroupFooter3Initial.GroupHeader := GroupHeader3Initial;
- GroupFooter3Initial.VisibleExpr := 'not IsOverflowed';
- Shape := TFPReportShape.Create(GroupFooter3Initial);
- Shape.Color := clGroupHeaderFooter;
- Shape.Layout.Left := 0;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := GroupFooter3Initial.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter;
- Shape := TFPReportShape.Create(GroupFooter3Initial);
- Shape.Color := clGroupHeaderFooter2;
- Shape.Layout.Left := 5;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := GroupFooter3Initial.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter2;
- Shape := TFPReportShape.Create(GroupFooter3Initial);
- Shape.Color := clGroupHeaderFooter3;
- Shape.Layout.Left := 10;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := GroupFooter3Initial.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter3;
- {--- group footer 3 initial - band 2 ---}
- ChildBand := TFPReportChildBand.Create(Page);
- ChildBand.Layout.Height := 2;
- ChildBand.VisibleExpr := 'IsOverflowed';
- GroupFooter3Initial.ChildBand := ChildBand;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter;
- Shape.Layout.Left := 0;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter2;
- Shape.Layout.Left := 5;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter2;
- {--- group footer 3 initial - band 3 ---}
- ChildBand := TFPReportChildBand.Create(Page);
- ChildBand.Layout.Height := 15;
- ChildBand.Frame.Shape := fsRectangle;
- ChildBand.Frame.BackgroundColor := clGroupHeaderFooter3;
- ChildBand.VisibleExpr := 'not InIntermediateGroupFooter';
- GroupFooter3Initial.ChildBand.ChildBand := ChildBand;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter;
- Shape.Layout.Left := 0;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clNone;
- Shape.Layout.Left := 3;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 2;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clWhite;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter2;
- Shape.Layout.Left := 5;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter2;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clNone;
- Shape.Layout.Left := 8;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 2;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clWhite;
- Memo := TFPReportMemo.Create(ChildBand);
- Memo.Layout.Left := 12;
- Memo.Layout.Top := 3;
- Memo.Layout.Width := 170;
- Memo.Layout.Height := 6;
- Memo.UseParentFont := False;
- Memo.Font.Size := 12;
- Memo.TextAlignment.Vertical := tlBottom;
- Memo.Text := 'Population [copy(data.country,1,1)]: [formatfloat(''#,##0'', grp3initial_sum_population)]';
- {--- group footer 3 initial - band 4 ---}
- ChildBand := TFPReportChildBand.Create(Page);
- ChildBand.Layout.Height := 3;
- ChildBand.Frame.Shape := fsRectangle;
- ChildBand.Frame.BackgroundColor := clGroupHeaderFooter3;
- ChildBand.VisibleExpr := 'InIntermediateGroupFooter';
- GroupFooter3Initial.ChildBand.ChildBand.ChildBand := ChildBand;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter;
- Shape.Layout.Left := 0;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clNone;
- Shape.Layout.Left := 3;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 2;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clWhite;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter2;
- Shape.Layout.Left := 5;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter2;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clNone;
- Shape.Layout.Left := 8;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 2;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clWhite;
- {*** group footer 2 subregion ***}
- {--- group footer 2 subregion - band 1 ---}
- GroupFooter2SubRegion := TFPReportGroupFooterBand.Create(Page);
- GroupFooter2SubRegion.Layout.Height := 2;
- GroupFooter2SubRegion.GroupHeader := GroupHeader2Subregion;
- GroupFooter2SubRegion.VisibleExpr := '(not IsOverflowed) and (not InIntermediateGroupFooter)';
- Shape := TFPReportShape.Create(GroupFooter2SubRegion);
- Shape.Color := clGroupHeaderFooter;
- Shape.Layout.Left := 0;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := GroupFooter2SubRegion.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter;
- Shape := TFPReportShape.Create(GroupFooter2SubRegion);
- Shape.Color := clGroupHeaderFooter2;
- Shape.Layout.Left := 5;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := GroupFooter2SubRegion.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter2;
- {--- group footer 2 subregion - band 2 ---}
- ChildBand := TFPReportChildBand.Create(Page);
- ChildBand.Layout.Height := 2;
- ChildBand.VisibleExpr := 'IsOverflowed';
- GroupFooter2SubRegion.ChildBand := ChildBand;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter;
- Shape.Layout.Left := 0;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter;
- {--- group footer 2 subregion - band 3 ---}
- ChildBand := TFPReportChildBand.Create(Page);
- ChildBand.Layout.Height := 15;
- ChildBand.Frame.Shape := fsRectangle;
- ChildBand.Frame.BackgroundColor := clGroupHeaderFooter2;
- ChildBand.VisibleExpr := 'not InIntermediateGroupFooter';
- GroupFooter2SubRegion.ChildBand.ChildBand := ChildBand;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter;
- Shape.Layout.Left := 0;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clNone;
- Shape.Layout.Left := 3;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 2;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clWhite;
- Memo := TFPReportMemo.Create(ChildBand);
- Memo.Layout.Left := 7;
- Memo.Layout.Top := 3;
- Memo.Layout.Width := 170;
- Memo.Layout.Height := 6;
- Memo.UseParentFont := False;
- Memo.Font.Size := 14;
- Memo.TextAlignment.Vertical := tlBottom;
- Memo.Text := 'Population [data.subregion]: [formatfloat(''#,##0'', grp2subregion_sum_population)]';
- {--- group footer 2 subregion - band 4 ---}
- ChildBand := TFPReportChildBand.Create(Page);
- ChildBand.Layout.Height := 2;
- ChildBand.VisibleExpr := 'InIntermediateGroupFooter';
- GroupFooter2SubRegion.ChildBand.ChildBand.ChildBand := ChildBand;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter;
- Shape.Layout.Left := 0;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clNone;
- Shape.Layout.Left := 5;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter2;
- {--- group footer 2 subregion - band 5 ---}
- ChildBand := TFPReportChildBand.Create(Page);
- ChildBand.Layout.Height := 3;
- ChildBand.VisibleExpr := 'InIntermediateGroupFooter';
- ChildBand.Frame.Shape := fsRectangle;
- ChildBand.Frame.BackgroundColor := clGroupHeaderFooter2;
- GroupFooter2SubRegion.ChildBand.ChildBand.ChildBand.ChildBand := ChildBand;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter;
- Shape.Layout.Left := 0;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clNone;
- Shape.Layout.Left := 3;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 2;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clWhite;
- {*** group footer 1 region ***}
- {--- group footer 1 region - band 1 ---}
- GroupFooter1Region := TFPReportGroupFooterBand.Create(Page);
- GroupFooter1Region.Layout.Height := 2;
- GroupFooter1Region.GroupHeader := GroupHeader1Region;
- GroupFooter1Region.VisibleExpr := '(not IsOverflowed) and (not InIntermediateGroupFooter)';
- Shape := TFPReportShape.Create(GroupFooter1Region);
- Shape.Color := clGroupHeaderFooter;
- Shape.Layout.Left := 0;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := GroupFooter1Region.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter;
- {--- group footer 1 region - band 2 ---}
- ChildBand := TFPReportChildBand.Create(Page);
- ChildBand.Layout.Height := 15;
- ChildBand.VisibleExpr := 'not InIntermediateGroupFooter';
- ChildBand.Frame.Shape := fsRectangle;
- ChildBand.Frame.BackgroundColor := clGroupHeaderFooter;
- GroupFooter1Region.ChildBand := ChildBand;
- Memo := TFPReportMemo.Create(ChildBand);
- Memo.Layout.Left := 3;
- Memo.Layout.Top := 3;
- Memo.Layout.Width := 170;
- Memo.Layout.Height := 6;
- Memo.UseParentFont := False;
- Memo.Font.Size := 16;
- Memo.TextAlignment.Vertical := tlBottom;
- Memo.Text := 'Population [data.region]: [formatfloat(''#,##0'', grp1region_sum_population)]';
- {--- group footer 1 region - band 3 ---}
- ChildBand := TFPReportChildBand.Create(Page);
- ChildBand.Layout.Height := 2;
- ChildBand.VisibleExpr := 'not InIntermediateGroupFooter';
- GroupFooter1Region.ChildBand.ChildBand := ChildBand;
- {--- group footer 1 region - band 4 ---}
- ChildBand := TFPReportChildBand.Create(Page);
- ChildBand.Layout.Height := 2;
- ChildBand.VisibleExpr := 'InIntermediateGroupFooter';
- GroupFooter1Region.ChildBand.ChildBand.ChildBand := ChildBand;
- Shape := TFPReportShape.Create(ChildBand);
- Shape.Color := clGroupHeaderFooter;
- Shape.Layout.Left := 0;
- Shape.Layout.Top := 0;
- Shape.Layout.Width := 3;
- Shape.Layout.Height := ChildBand.Layout.Height;
- Shape.Frame.Shape := fsRectangle;
- Shape.Frame.BackgroundColor := clGroupHeaderFooter;
- {--- group footer 1 region - band 5 ---}
- ChildBand := TFPReportChildBand.Create(Page);
- ChildBand.Layout.Height := 3;
- ChildBand.VisibleExpr := 'InIntermediateGroupFooter';
- ChildBand.Frame.Shape := fsRectangle;
- ChildBand.Frame.BackgroundColor := clGroupHeaderFooter;
- GroupFooter1Region.ChildBand.ChildBand.ChildBand.ChildBand := ChildBand;
- {*******************}
- {*** page footer ***}
- {*******************}
- {--- page footer - band 1 ---}
- PageFooter := TFPReportPageFooterBand.Create(Page);
- PageFooter.Layout.Height := 20;
- PageFooter.Frame.Shape := fsRectangle;
- PageFooter.Frame.BackgroundColor := clPageHeaderFooter;
- Memo := TFPReportMemo.Create(PageFooter);
- Memo.Layout.Left := 123;
- Memo.Layout.Top := 13;
- Memo.Layout.Width := 50;
- Memo.Layout.Height := 5;
- Memo.Text := 'Page [PageNo] of [PageCount]';
- Memo.TextAlignment.Vertical := tlCenter;
- Memo.TextAlignment.Horizontal := taRightJustified;
- Memo := TFPReportMemo.Create(PageFooter);
- Memo.Layout.Left := 0;
- Memo.Layout.Top := 5;
- Memo.Layout.Width := Page.PageSize.Width - Page.Margins.Left - Page.Margins.Right;
- Memo.Layout.Height := 8;
- Memo.UseParentFont := False;
- Memo.TextAlignment.Horizontal := taCentered;
- Memo.Text := 'Population World: [formatfloat(''#,##0'', total_sum_population)]';
- Memo.Font.Size := 16;
- {--- page footer - band 2 ---}
- ChildBand := TFPReportChildBand.Create(Page);
- ChildBand.Layout.Height := 10;
- ChildBand.VisibleExpr := 'PageNo mod 2 = 0';
- ChildBand.Frame.Shape := fsRectangle;
- ChildBand.Frame.BackgroundColor := clChildBand;
- PageFooter.ChildBand := ChildBand;
- Memo := TFPReportMemo.Create(ChildBand);
- Memo.Layout.Left := 0;
- Memo.Layout.Top := 0;
- Memo.Layout.Width := Page.PageSize.Width - Page.Margins.Left - Page.Margins.Right;
- Memo.Layout.Height := 10;
- Memo.Text := 'even page: [pageno]';
- Memo.TextAlignment.Vertical := tlCenter;
- Memo.TextAlignment.Horizontal := taCentered;
- {--- page footer - band 3 ---}
- ChildBand := TFPReportChildBand.Create(Page);
- ChildBand.Layout.Height := 20;
- ChildBand.VisibleExpr := 'PageNo mod 5 = 0';
- ChildBand.Frame.Shape := fsRectangle;
- ChildBand.Frame.BackgroundColor := clReportTitleSummary;
- PageFooter.ChildBand.ChildBand := ChildBand;
- Memo := TFPReportMemo.Create(ChildBand);
- Memo.Layout.Left := 0;
- Memo.Layout.Top := 0;
- Memo.Layout.Width := Page.PageSize.Width - Page.Margins.Left - Page.Margins.Right;
- Memo.Layout.Height := 20;
- Memo.Text := 'multiple of 5: [pageno]';
- Memo.TextAlignment.Vertical := tlCenter;
- Memo.TextAlignment.Horizontal := taCentered;
- end;
- procedure TNestedGroupsDemo.LoadDesignFromFile(const AFilename: string);
- var
- rs: TFPReportJSONStreamer;
- fs: TFileStream;
- lJSON: TJSONObject;
- begin
- if AFilename = '' then
- Exit;
- if not FileExists(AFilename) then
- raise Exception.CreateFmt('The file "%s" can not be found', [AFilename]);
- fs := TFileStream.Create(AFilename, fmOpenRead or fmShareDenyNone);
- try
- lJSON := TJSONObject(GetJSON(fs));
- finally
- fs.Free;
- end;
- rs := TFPReportJSONStreamer.Create(nil);
- rs.JSON := lJSON; // rs takes ownership of lJSON
- try
- rpt.ReadElement(rs);
- finally
- rs.Free;
- end;
- end;
- procedure TNestedGroupsDemo.HookupData(const AComponentName: string; const AData: TFPReportData);
- var
- b: TFPReportCustomBandWithData;
- begin
- b := TFPReportCustomBandWithData(rpt.FindRecursive(AComponentName));
- if Assigned(b) then
- b.Data := AData;
- end;
- constructor TNestedGroupsDemo.Create(AOWner: TComponent);
- begin
- inherited;
- FReportData := TFPReportUserData.Create(nil);
- FReportData.Name := 'Data';
- FReportData.OnGetValue := @GetReportDataValue;
- FReportData.OnGetEOF := @GetReportDataEOF;
- FReportData.OnFirst := @GetReportDataFirst;
- FReportData.OnGetNames := @GetReportFieldNames;
- FReportData.OnNext := @ReportDataNext;
- end;
- destructor TNestedGroupsDemo.Destroy;
- begin
- FreeAndNil(FReportData);
- rec.DelimitedText := '';
- FreeAndNil(rec);
- FreeAndNil(sl);
- inherited Destroy;
- end;
- class function TNestedGroupsDemo.Description: string;
- begin
- Result:='Demo showing grouping';
- end;
- end.
|