안녕하세요?
도움을 구하고자 이렇게 글을 올립니다.. 요지는 다음과 같습니다.
==========================================================================
procedure TfmBooklist.pbRetrieve1Click(Sender: TObject);
var
nSUM: array[0..102, 0..12] of Integer;
I,J: byte;
begin
// 100 - 총계, 101 - 기타
for I := 0 to 101 do
// 10 - 계, 11 - 기타
for J := 0 to 11 do
nSUM[I,J] := 0;
pbRetrieve1Click_sSQL := '';
pbRetrieve1Click_sSQL := pbRetrieve1Click_sSQL + 'select bookgibon.kdcno, mid(bookgibon.kdcno,1,2) as A1, mid(bookgibon.kdcno,3,1) as A2';
pbRetrieve1Click_sSQL := pbRetrieve1Click_sSQL + ' from book,bookgibon where book.bookno = bookgibon.bookno';
pbRetrieve1Click_sSQL := pbRetrieve1Click_sSQL + ' and bookgibon.kdcno >= ' + Format('%d',[strtoint(Efrom.text)]);
pbRetrieve1Click_sSQL := pbRetrieve1Click_sSQL + ' and bookgibon.kdcno <= ' + Format('%d',[strtoint(Eto.text)]);
pbRetrieve1Click_sSQL := pbRetrieve1Click_sSQL + ' order by mid(bookgibon.kdcno,1,2),mid(bookgibon.kdcno,3,1)';
qrBooklist.SQL.Clear;
qrBooklist.SQL.Add(pbRetrieve1Click_sSQL);
qrBooklist.open;
while not qrBooklist.Eof do
begin
// I:=qrBooklist.FieldByName('kdcno').Asinteger;
if qrBooklist.FieldByName('A1').AsString = '00' then
I := 0
else
if strtoint(qrBooklist.FieldByName('A1').AsString) <> 0 then
I := strtoint(qrBooklist.FieldByName('A1').AsString)
else
I := 101;
if qrBooklist.FieldByName('A2').AsString = '0' then
J := 0
else
if qrBooklist.FieldByName('A2').AsString = '' then
J := 11
else
J := strtoint(qrBooklist.FieldByName('A2').AsString);
nSUM[I,J] := nSUM[I,J] + 1;
nSUM[I,10] := nSUM[I,10] + 1;
nSUM[100,J] := nSUM[100,J] + 1;
nSUM[100,10] := nSUM[100,10] + 1;
qrBooklist.Next;
end;
J := 0;
for I := 0 to 99 do
if nSUM[I,10] > 0 then
J := J + 1;
ESGbook.RowCount := 2;
if J = 0 then
for I := 2 to 11 do
ESGbook.Cells[1, I] := '0';
if nSUM[101,10] = 0 then
ESGbook.RowCount := J + 3
else
ESGbook.RowCount := J + 5;
J:=3;
for I := 0 to 99 do
if nSUM[I,10] > 0 then
begin
ESGbook.Cells[0,J] := FormatFloat('00',I);
ESGbook.Cells[1,J] := inttostr(nSUM[I,10]);
ESGbook.Cells[2,J] := inttostr(nSUM[I,0]);
ESGbook.Cells[3,J] := inttostr(nSUM[I,1]);
ESGbook.Cells[4,J] := inttostr(nSUM[I,2]);
ESGbook.Cells[5,J] := inttostr(nSUM[I,3]);
ESGbook.Cells[6,J] := inttostr(nSUM[I,4]);
ESGbook.Cells[7,J] := inttostr(nSUM[I,5]);
ESGbook.Cells[8,J] := inttostr(nSUM[I,6]);
ESGbook.Cells[9,J] := inttostr(nSUM[I,7]);
ESGbook.Cells[10,J] := inttostr(nSUM[I,8]);
ESGbook.Cells[11,J] := inttostr(nSUM[I,9]);
ESGbook.Cells[12,J] := inttostr(nSUM[I,11]);
J:=J+1;
end;
if nSUM[101,10] > 0 then
begin
I:=ESGbook.RowCount-2;
ESGbook.Cells[0,I] := '소계';
ESGbook.Cells[1,I] := inttostr(nSUM[101,10]);
ESGbook.Cells[2,I] := inttostr(nSUM[101,0]);
ESGbook.Cells[3,I] := inttostr(nSUM[101,1]);
ESGbook.Cells[4,I] := inttostr(nSUM[101,2]);
ESGbook.Cells[5,I] := inttostr(nSUM[101,3]);
ESGbook.Cells[6,I] := inttostr(nSUM[101,4]);
ESGbook.Cells[7,I] := inttostr(nSUM[101,5]);
ESGbook.Cells[8,I] := inttostr(nSUM[101,6]);
ESGbook.Cells[9,I] := inttostr(nSUM[101,7]);
ESGbook.Cells[10,I] := inttostr(nSUM[101,8]);
ESGbook.Cells[11,I] := inttostr(nSUM[101,9]);
ESGbook.Cells[12,I] := inttostr(nSUM[101,11]);
I:=ESGbook.RowCount-1;
ESGbook.Cells[0,I] := '기타';
ESGbook.Cells[1,I] := inttostr(nSUM[101,10]);
ESGbook.Cells[2,I] := inttostr(nSUM[101,0]);
ESGbook.Cells[3,I] := inttostr(nSUM[101,1]);
ESGbook.Cells[4,I] := inttostr(nSUM[101,2]);
ESGbook.Cells[5,I] := inttostr(nSUM[101,3]);
ESGbook.Cells[6,I] := inttostr(nSUM[101,4]);
ESGbook.Cells[7,I] := inttostr(nSUM[101,5]);
ESGbook.Cells[8,I] := inttostr(nSUM[101,6]);
ESGbook.Cells[9,I] := inttostr(nSUM[101,7]);
ESGbook.Cells[10,I] := inttostr(nSUM[101,8]);
ESGbook.Cells[11,I] := inttostr(nSUM[101,9]);
ESGbook.Cells[12,I] := inttostr(nSUM[101,11]);
end;
ESGbook.Cells[0,1] := '계';
ESGbook.Cells[1,1] := inttostr(nSUM[100,10]);
ESGbook.Cells[2,1] := inttostr(nSUM[100,0]);
ESGbook.Cells[3,1] := inttostr(nSUM[100,1]);
ESGbook.Cells[4,1] := inttostr(nSUM[100,2]);
ESGbook.Cells[5,1] := inttostr(nSUM[100,3]);
ESGbook.Cells[6,1] := inttostr(nSUM[100,4]);
ESGbook.Cells[7,1] := inttostr(nSUM[100,5]);
ESGbook.Cells[8,1] := inttostr(nSUM[100,6]);
ESGbook.Cells[9,1] := inttostr(nSUM[100,7]);
ESGbook.Cells[10,1] := inttostr(nSUM[100,8]);
ESGbook.Cells[11,1] := inttostr(nSUM[100,9]);
ESGbook.Cells[12,1] := inttostr(nSUM[100,11]);
ESGbook.Cells[0,2] := '소계';
ESGbook.Cells[1,2] := inttostr(nSUM[100,10] - nSUM[101,10]);
ESGbook.Cells[2,2] := inttostr(nSUM[100,0] - nSUM[101,0]);
ESGbook.Cells[3,2] := inttostr(nSUM[100,1] - nSUM[101,1]);
ESGbook.Cells[4,2] := inttostr(nSUM[100,2] - nSUM[101,2]);
ESGbook.Cells[5,2] := inttostr(nSUM[100,3] - nSUM[101,3]);
ESGbook.Cells[6,2] := inttostr(nSUM[100,4] - nSUM[101,4]);
ESGbook.Cells[7,2] := inttostr(nSUM[100,5] - nSUM[101,5]);
ESGbook.Cells[8,2] := inttostr(nSUM[100,6] - nSUM[101,6]);
ESGbook.Cells[9,2] := inttostr(nSUM[100,7] - nSUM[101,7]);
ESGbook.Cells[10,2] := inttostr(nSUM[100,8] - nSUM[101,8]);
ESGbook.Cells[11,2] := inttostr(nSUM[100,9] - nSUM[101,9]);
ESGbook.Cells[12,2] := inttostr(nSUM[100,11] - nSUM[101,11]);
for I:=1 to ESGbook.RowCount-1 do
for J:=1 to 12 do
if ESGbook.Cells[J,I]='0' then
ESGbook.Cells[J,I]:='';
end;
이렇게 그리드에 동적으로 올라온 데이타를 QuickRep에 넣고 싶은데...
rocedure TfmPrBooklist.QuickRep3NeedData(Sender: TObject; var MoreData: Boolean);
begin
sSql := fmBooklist.pbRetrieve1Click_sSQL ;
end;
procedure TfmPrBooklist.QuickRep3BeforePrint(Sender: TQuickRep; var PrintReport: Boolean);
var
//FName : String ;
PrblmNumLbl : array[1..1003,1..12] of TQRLabel ;
PrblmNumShap : array[1..1003,1..12] of TQRShape ;
PrblmNum,PrblmNum2 : integer;
begin
for PrblmNum:=1 to fmBooklist.ESGbook.RowCount - 1 do
for PrblmNum2:=1 to 12 do begin
PrblmNumLbl[PrblmNum,PrblmNum2] := TQRLabel.Create(self) ;
PrblmNumLbl[PrblmNum,PrblmNum2].Parent := QuickRep1 ;
//PrblmNumLbl[PrblmNum,PrblmNum2].TransParent := True ;
PrblmNumLbl[PrblmNum,PrblmNum2].Font.Name := '굴림체' ;
PrblmNumLbl[PrblmNum,PrblmNum2].Font.Size := 10 ;
PrblmNumLbl[PrblmNum,PrblmNum2].Caption := fmBooklist.ESGbook.Cells[PrblmNum2,PrblmNum] ;
PrblmNumLbl[PrblmNum,PrblmNum2].width := 65 ;
PrblmNumShap[PrblmNum,PrblmNum2] := TQRShape.Create(self) ;
PrblmNumShap[PrblmNum,PrblmNum2].Parent := QuickRep1 ;
PrblmNumShap[PrblmNum,PrblmNum2].Height := 25 ;
PrblmNumShap[PrblmNum,PrblmNum2].Width := 2;
PrblmNumShap[PrblmNum,PrblmNum2].Left := QuickRep1.Bands.DetailBand.Left ;
PrblmNumShap[PrblmNum,PrblmNum2].Top := QuickRep1.Bands.DetailBand.Top +1 ;
if PrblmNum2 = 1 then
Begin
PrblmNumLbl[PrblmNum,PrblmNum2].left :=
QuickRep1.Bands.DetailBand.Left + 72 ;
PrblmNumShap[PrblmNum,PrblmNum2].Top :=
QuickRep1.Bands.DetailBand.Top + 21 ;
end
else
Begin
PrblmNumLbl[PrblmNum,PrblmNum2].left :=
PrblmNumLbl[PrblmNum,PrblmNum2-1].left + PrblmNumLbl
[PrblmNum,PrblmNum2].width -2; // + 3
prblmNumShap[PrblmNum,PrblmNum2].left :=
prblmNumShap[PrblmNum,PrblmNum2-1].left + 60 ;
end ;
if PrblmNum = 1 then
begin
PrblmNumLbl[PrblmNum,PrblmNum2].Top := QuickRep1.Bands.DetailBand.Top + 25 ;// 10
prblmNumShap[PrblmNum,PrblmNum2].left := prblmNumShap[PrblmNum,PrblmNum2-1].left + 60 ;
end
else
begin
PrblmNumLbl[PrblmNum,PrblmNum2].Top := PrblmNumLbl[PrblmNum-1,PrblmNum2].Top + 20;
prblmNumShap[PrblmNum,PrblmNum2].left := prblmNumShap[PrblmNum,PrblmNum2-1].left + 60 ;
end;
end;
뭐 이런식으로 구현할려고 했으나 ... 영 잘 안되고... 탐탁치가 않네요.....
이런방법말고 제가 모르는 좋은 방법이 있는지.. 고수님들의 조언을 듣고자 합니다...
그럼... 수고하시구요... 좋은 해결책을 찾았으면 합니다...
옛 통합 게시판 Q&A의 5037을 보면
스트링그리드의 내용을 QuickReport로 출력하는
방법이 있습니다...