3. Kompletní skript bez komentářů |
Top Previous Next |
procedure OnBeforeReport(Sender : TReportProperty); var Query : TQuery; r : integer; begin Sheet.BeginUpdate; Sheet.RowCount:=3; Sheet.ColCount:=6; Sheet.FixedRows:=2; Sheet.ClearMergeCells;
Query:=TQuery.Create(nil); with Query do try DatabaseName :=DefaultDatabaseName; SQL.Text:='select mena_id,(select nazev from dba.gstaty where id_stat=(select stat_id from dba.gmeny where mena_id=id_mena)) as nazev '+ 'from dba.gkurzy group by mena_id'; Open;
r:=3; while not Query.Eof do begin while Sheet.RowCount-1<r do Sheet.AddRow;
Sheet.CellProperty[2,r].Tag:=1; Sheet.Cells[2,r]:=Query.FieldByName('mena_id').AsString; Sheet.MergeCells(3,r,4,r); Sheet.Cells[3,r]:=Query.FieldByName('nazev').AsString;
Sheet.CellProperty[2,r].Background:=$00bd814f;Sheet.CellProperty[2,r].Font.Color:=clWhite; Sheet.CellProperty[3,r].Background:=$00bd814f;Sheet.CellProperty[3,r].Font.Color:=clWhite;
Sheet.CellProperty[2,r].OnDblClick:=@MenaDblClick;
inc(r); Query.Next; end; finally Free; end;
Sheet.EndUpdate; end;
procedure DrillMe( mena : string; aRow : integer ); var Query : TQuery; r : integer; flgCollapse : boolean; begin Sheet.BeginUpdate;
//Collapse flgCollapse:=false; r:=aRow+1;
while (Sheet.CellProperty[2,r].Tag=0) and (r<Sheet.RowCount) do begin flgCollapse:=True; Sheet.DeleteRow(r); end; if flgCollapse then begin Sheet.EndUpdate; Exit; end;
// expand Query:=TQuery.Create(nil); with Query do try DatabaseName :=DefaultDatabaseName; SQL.Text:='select top 5 dne,koef from dba.gkurzy where mena_id=:mena order by dne desc'; Params.ParamByName('mena').AsString:=mena; Open;
r:=aRow+1; while Sheet.ColCount-1<3 do Sheet.InsertCol(Sheet.ColCount-1);
while not Query.Eof do begin Sheet.InsertRow(r);
Sheet.Cells[3,r]:=Query.FieldByName('dne').AsString; Sheet.Cells[4,r]:=Query.FieldByName('koef').AsString;
Sheet.CellProperty[3,r].Background:=$00EAEAEA; Sheet.CellProperty[4,r].Background:=$00EAEAEA;
//inc(r); Query.Next; end;
finally Free; end; Sheet.EndUpdate; end;
procedure MenaDblClick(Sender : TCellProperty); begin DrillMe(Value,Sheet.Row); end;
begin
end. |