procedure TfrmDataset.printDataset(DataSet: TDataSet;
colLen: array of Integer;
coltitle, coldata: array of string);var tmpfn: string;
begin
tmpfn := GetTempPathFileName();
TADODataSet(DataSet).SaveToFile(tmpfn);
ADODataSet.LoadFromFile(tmpfn);
makereport_byarray(frReport2, self.Font, colLen, coltitle, coldata);
frReport2.ShowReport;
end;
procedure makereport_byarray(frRpt: TfrReport;
font: TFont;
colLen: array of Integer;
coltitle, coldata: array of string);var i: integer;
strlen: array of integer;
titleview: TfrMemoView;
memoview: TfrMemoView;
MasterBand: TfrBandView;
ColumnHeader: TfrBandView;
x, y1, y2, w, sum_len, sum_i, x_i, x_i_old: integer;
s: string;
begin
do
cMode := dmDesigning;
SetLength(strlen, length(coltitle));
if length(colLen) = length(coltitle) then
begin
for i := 0 to high(strlen)do
strlen := colLen;
end else
begin
for i := 0 to high(strlen)do
strlen := 0;
for i := 0 to high(strlen)do
begin
s := '';
s := coltitle;
strlen := length(s);
if strlen = 0 then
strlen := 1;
end;
end;
titleview := TfrMemoView(frRpt.Pages[0].FindObject('Memo1'));
MasterBand := TfrBandView(frRpt.Pages[0].FindObject('MasterData1'));
ColumnHeader := TfrBandView(frRpt.Pages[0].FindObject('ColumnHeader1'));
x := titleview.Prop['Left'];
w := titleview.Prop['width'];
sum_len := 0;
for i := 0 to high(strlen)do
inc(sum_len, strlen);
sum_i := 0;
for i := 0 to high(strlen)do
begin
inc(sum_i, strlen);
x_i := round(sum_i * w / sum_len);
if i = 0 then
strlen := x_i else
strlen := x_i - x_i_old;
x_i_old := x_i;
end;
x := titleview.Prop['Left'];
y1 := ColumnHeader.Prop['top'];
y2 := y1 + ColumnHeader.Prop['height'];
y1 := y2 - MasterBand.Prop['height'];
for i := 0 to high(strlen)do
begin
memoview := TfrMemoView.Create;
memoview.Prop['top'] := y1;
memoview.Prop['height'] := y2 - y1;
memoview.Prop['Left'] := x;
memoview.Prop['width'] := strlen;
memoview.Prop['textonly'] := true;
memoview.Prop['ALIGNMENT'] := 10;
memoview.FrameTyp := 15;
s := '';
s := coltitle;
memoview.Memo.Text := s;
memoview.Font.Assign(font);
frRpt.Pages[0].Objects.Add(memoview);
inc(x, strlen);
end;
x := titleview.Prop['Left'];
y1 := MasterBand.Prop['top'];
y2 := y1 + MasterBand.Prop['height'];
for i := 0 to high(strlen)do
begin
memoview := TfrMemoView.Create;
memoview.Prop['top'] := y1;
memoview.Prop['height'] := y2 - y1;
memoview.Prop['Left'] := x;
memoview.Prop['width'] := strlen;
memoview.Prop['ALIGNMENT'] := 10;
memoview.FrameTyp := 15;
memoview.Memo.Text := coldata;
memoview.Font.Assign(font);
frRpt.Pages[0].Objects.Add(memoview);
inc(x, strlen);
end;
setlength(strlen, 0);
end;