procedure TForm1.BntPreviewClick(Sender: TObject);
var
v: TfrView;
b: TfrBandView;
Page: TfrPage;
begin
try
ADOQuery1.Active := False;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Text :='select * from Data';
ADOQuery1.Active := True;
try
FN1 := ComboBox1.Text;
FN2 := ComboBox2.Text;
FN3 := ComboBox3.Text;
FN4 := ComboBox4.Text;
FN5 := ComboBox5.Text;
FN6 := ComboBox6.Text;
except
ShowMessage('字段名有错,请修改后再预览');
end;
try
FW1 := round(StrToInt(Edit1.Text) * 3.6);
FW2 := round(StrToInt(Edit1.Text) * 3.6);
FW3 := round(StrToInt(Edit1.Text) * 3.6);
FW4 := round(StrToInt(Edit1.Text) * 3.6);
FW5 := round(StrToInt(Edit1.Text) * 3.6);
FW6 := round(StrToInt(Edit1.Text) * 3.6);
if FW1+FW2+FW3+FW4+FW5+FW6 > 756 then
begin
ShowMessage('字段宽度值之和太大,请修改后再预览');
exit;
end;
except
ShowMessage('字段宽度输入数据有错,请修改后再预览');
end;
except
end;
frReport1.Pages.Clear;
frReport1.Pages.Add;
// create page
frReport1.Pages[0].pgSize := 9;
Page := frReport1.Pages[0];
b:= TfrBandView.Create;
// create Title band
b.SetBounds(0, 20, 0, 20);
// position and size in pixels
b.BandType := btReportTitle;
// (only Top and Height are significant
Page.Objects.Add(b);
v := TfrMemoView.Create;
// create memo
v.SetBounds(20, 20, 758, 40);
v.BandAlign := baWidth;
v.Prop['Alignment'] := frtaCenter;
v.Prop['Font.Style'] := 4;
v.Prop['Font.Size'] := 20;
v.Prop['Font.Color'] := clRed;
v.Memo.Add('车辆登记月汇总报表');
Page.Objects.Add(v);
b := TfrBandView.Create;
b.SetBounds(0,80,758,20);
b.BandType := btMasterHeader;
Page.Objects.Add(b);
b := TfrBandView.Create;
b.SetBounds(0,100,758,20);
b.BandType := btMasterHeader;
b.DataSet := 'frDBDataSet1';
Page.Objects.Add(b);
if FN1 <> '' then
begin
v := TfrMemoView.Create;
// create memo
v.SetBounds(20, 81, FW1, 19);
v.Prop['Alignment'] := frtaCenter;
v.Prop['Font.Style'] := 2;
//v.Prop['Font.Size'] := 10;
//v.Prop['Font.Color'] := clRed;
v.Memo.Add(FN1);
Page.Objects.Add(v);
v := TfrMemoView.Create;
// create memo
v.SetBounds(20, 101, FW1, 19);
v.Prop['Alignment'] := frtaCenter;
v.Prop['Font.Style'] := 2;
//v.Prop['Font.Size'] := 10;
//v.Prop['Font.Color'] := clRed;
v.Memo.Add('[ADOQuery1."ID"]');
Page.Objects.Add(v);
end;
if FN2 <> '' then
begin
end;
if FN3 <> '' then
begin
end;
if FN4 <> '' then
begin
end;
if FN5 <> '' then
begin
end;
if FN6 <> '' then
begin
end;
frReport1.ShowReport;
end;
end.