3. Skript reportu |
Top Previous Next |
const SerNames = ['fakturace','příjem peněz','výdej peněz','jednic. mat.','objednávky','zakázky']; ExcelPalette = [$00bd814f,$004d50c0,$0059bb9b,$00a26480,$00c6ac4b,$004F81BD,$00C0504D,$009BBB59,$008064A2,$004BACC6,$00F79646,$00AABAD7,$00CCFFFF];
procedure FillGraph( Sender : TObject ); var i : integer; Chart : TDbChart; ser : TChartSeries; begin // graph Chart:=TDbChart(Sheet['B18'].CellComponent); Chart.FreeAllSeries; for i:=0 to length(serNames)-1 do if TCheckBox(Sheet[[(i+2)*2,4]].CellComponent).Checked then begin case TComboBoxEx(Sheet['F2'].CellComponent).ItemIndex of 0 : ser:=Chart.AddSeries( TBarSeries.Create(Chart) ); 1 : ser:=Chart.AddSeries( TFastLineSeries.Create(Chart) ); 2 : ser:=Chart.AddSeries( TPointSeries.Create(Chart) ); 3 : ser:=Chart.AddSeries( TAreaSeries.Create(Chart) ); end;
with TCustomBarSeries(ser) do begin Title:=serNames[i]; Marks.Visible := False; If TComboBoxEx(Sheet['F2'].CellComponent).ItemIndex=0 then begin TCustomBarSeries(ser).MultiBar:=1; TCustomBarSeries(ser).BarPen.Visible:=False; end; SeriesColor:=ExcelPalette[i]; DataSource:=Query1.Query; XLabelsSource:=Query1.Query.Fields[1].FieldName; YValues.ValueSource:=Query1.Query.Fields[i+2].FieldName; end; end; end;
procedure FillData; var r : integer;
procedure CreateKumulace(chCol : char; rr : integer); begin if rr=5 then Sheet[[chCol,rr]].formulas:='='+Chr(ord(chCol)-1)+inttostr(rr) else Sheet[[chCol,rr]].formulas:='='+Chr(ord(chCol))+inttostr(rr-1)+'+'+Chr(ord(chCol)-1)+inttostr(rr) end;
begin r:=5; Sheet.BeginUpdate; Query1.Query.Close; Query1.Query.Open; while not Query1.Query.Eof do begin Sheet[['B',r]].Cells:=<Query1."rok">; Sheet[['C',r]].Cells:=<Query1."mesic">; Sheet[['D',r]].Cells:=<Query1."fakturace">; CreateKumulace('E',r); Sheet[['F',r]].Cells:=<Query1."prijempenez">; CreateKumulace('G',r); Sheet[['H',r]].Cells:=<Query1."vydejpenez">; CreateKumulace('I',r); Sheet[['J',r]].Cells:=<Query1."jednicmat">; CreateKumulace('K',r); Sheet[['L',r]].Cells:=<Query1."objednavky">; CreateKumulace('M',r); Sheet[['N',r]].Cells:=<Query1."zakazky">; CreateKumulace('O',r);
inc(r); Query1.Query.Next; end; Sheet.Eval(False); Sheet.EndUpdate;
FillGraph( nil ); end;
procedure List1_C2ComboBoxExOnChange( Sender : TObject ); begin FillData; end;
procedure OnBeforeReport( Sender : TReportProperty ); begin TComboBoxEx(Sheet['F2'].CellComponent).ItemIndex:=0; FillData; end;
procedure OnPrepareScript( Sender : TReportProperty ); begin TComboBoxEx(Sheet['C2'].CellComponent).OnClick:=@List1_C2ComboBoxExOnChange; TCheckBox(Sheet['D4'].CellComponent).OnClick:=@FillGraph; TCheckBox(Sheet['F4'].CellComponent).OnClick:=@FillGraph; TCheckBox(Sheet['H4'].CellComponent).OnClick:=@FillGraph; TCheckBox(Sheet['J4'].CellComponent).OnClick:=@FillGraph; TCheckBox(Sheet['L4'].CellComponent).OnClick:=@FillGraph; TCheckBox(Sheet['N4'].CellComponent).OnClick:=@FillGraph; TComboBoxEx(Sheet['F2'].CellComponent).OnChange:=@FillGraph; end;
begin
end. |