9
EXE RANK
Z1rT
Fexe Kullanıcısı
Puanları
0
Çözümler
0
- Katılım
- 26 Kas 2009
- Mesajlar
- 9,190
- Tepkime puanı
- 0
- Puanları
- 0
- Yaş
- 33
- Web sitesi
- www.netbilgini.net
[h=2]Grid Alt Toplam Almak[/h]
procedure AltToplam; var i: Integer; FormulaResult: Double; procedure ColumnSum(Index: Integer; var Sum: Double); var i: Integer; begin for i := 1 to Pred(RowCount) do if not VisibleOnly or RowVisible then Sum := Sum + Cell[Index, i].AsFloat; end; function CalculateColumn(Index: Integer; FormulaKind: TFormulaKind): Double; var i: Integer; FormulaSum: Double; s: WideString; sl: TStringList; begin FormulaSum := 0; if (not VisibleOnly or RowVisible[0]) and (FormulaKind <> fkCount) then FormulaSum := Cell[Index, 0].AsFloat; case FormulaKind of fkAverage: begin ColumnSum(Index, FormulaSum); FormulaSum := FormulaSum / RowCount; end; fkCount: FormulaSum := RowCount; fkCustom: DoColumnFooterValue(Index, FormulaSum); fkDistinct: begin sl := TStringList.Create; for i := 0 to RowCount - 1 do if not VisibleOnly or RowVisible then { visible only } begin s := Cells[Index, i]; if sl.IndexOf(s)= - 1 then sl.Add(s); end; FormulaSum := sl.Count; FreeAndNil(sl); end; fkMaximum: for i := 1 to Pred(RowCount) do if (not VisibleOnly or RowVisible) and (Cell[Index, i].AsFloat > FormulaSum) then FormulaSum := Cell[Index, i].AsFloat; fkMinimum: for i := 1 to Pred(RowCount) do if (not VisibleOnly or RowVisible) and (Cell[Index, i].AsFloat < FormulaSum) then FormulaSum := Cell[Index, i].AsFloat; fkSum: ColumnSum(Index, FormulaSum); end; DoFooterCalculate(Index, FormulaSum); { event } Result := FormulaSum; end; begin for i := 0 to Pred(Columns.Count) do begin if Columns.Footer.FormulaKind <> fkNone then if RowCount = 0 then Columns.Footer.Caption := '0' else begin FormulaResult := CalculateColumn(i, Columns.Footer.FormulaKind); Columns.Footer.Caption := FloatToStr(FormulaResult); end; end; end;
procedure AltToplam; var i: Integer; FormulaResult: Double; procedure ColumnSum(Index: Integer; var Sum: Double); var i: Integer; begin for i := 1 to Pred(RowCount) do if not VisibleOnly or RowVisible then Sum := Sum + Cell[Index, i].AsFloat; end; function CalculateColumn(Index: Integer; FormulaKind: TFormulaKind): Double; var i: Integer; FormulaSum: Double; s: WideString; sl: TStringList; begin FormulaSum := 0; if (not VisibleOnly or RowVisible[0]) and (FormulaKind <> fkCount) then FormulaSum := Cell[Index, 0].AsFloat; case FormulaKind of fkAverage: begin ColumnSum(Index, FormulaSum); FormulaSum := FormulaSum / RowCount; end; fkCount: FormulaSum := RowCount; fkCustom: DoColumnFooterValue(Index, FormulaSum); fkDistinct: begin sl := TStringList.Create; for i := 0 to RowCount - 1 do if not VisibleOnly or RowVisible then { visible only } begin s := Cells[Index, i]; if sl.IndexOf(s)= - 1 then sl.Add(s); end; FormulaSum := sl.Count; FreeAndNil(sl); end; fkMaximum: for i := 1 to Pred(RowCount) do if (not VisibleOnly or RowVisible) and (Cell[Index, i].AsFloat > FormulaSum) then FormulaSum := Cell[Index, i].AsFloat; fkMinimum: for i := 1 to Pred(RowCount) do if (not VisibleOnly or RowVisible) and (Cell[Index, i].AsFloat < FormulaSum) then FormulaSum := Cell[Index, i].AsFloat; fkSum: ColumnSum(Index, FormulaSum); end; DoFooterCalculate(Index, FormulaSum); { event } Result := FormulaSum; end; begin for i := 0 to Pred(Columns.Count) do begin if Columns.Footer.FormulaKind <> fkNone then if RowCount = 0 then Columns.Footer.Caption := '0' else begin FormulaResult := CalculateColumn(i, Columns.Footer.FormulaKind); Columns.Footer.Caption := FloatToStr(FormulaResult); end; end; end;