var
DataPage:TfrxDatapage;
page:TfrxReportpage;
band:TfrxBand;
pageheader:TfrxHeader;
groupheader:TfrxgroupHeader;
DataBand:TfrxMasterData;
Memo:TfrxMemoView;
i:integer;
x,y,z,width:extended;
begin
x := 0;
y := 0;
z := 0;
frxReport1.Clear;
frxDBDataset1.DataSet := qry_medicalorderdetail;
frxReport1.DataSets.Add(frxDBDataSet1);
DataPage := TfrxDataPage.Create(frxReport1);
Page := TfrxReportPage.Create(frxReport1);
Page.CreateUniqueName;
Page.SetDefaults;
page.PaperSize:=DMPAPER_A4;
width:=page.Width/11;
//Page.Orientation := poLandscape;
page.PrintOnPreviousPage:=true;
Band := TfrxReportTitle.Create(Page);
Band.CreateUniqueName;
Band.Top := 0;
Band.Height := 40;
band.AllowSplit:=true;
Memo := TfrxMemoView.Create(Band);
Memo.CreateUniqueName;
Memo.Text := '病人医嘱';
Memo.Height := 40;
memo.Font.Size := 25;
memo.Font.Name := '黑体';
Memo.Align := baWidth;
memo.VAlign := vatop;
memo.AutoWidth:= true;
memo.Align := bacenter;
/////////////////////////////////////////////////////////////////////////////
pageheader := Tfrxheader.Create(Page);
pageheader.CreateUniqueName;
pageheader.Top := 40;
pageheader.Height := 40;
pageheader.Left := 0;
Memo := TfrxMemoView.Create(Band);
Memo.CreateUniqueName;
Memo.Text := DateTimeToStr(now());
Memo.Height := 36;
memo.Font.Size := 8;
memo.Font.Name := '宋体';
memo.Align := baleft;
memo.VAlign := vabottom;
memo.SetBounds(0,40,180,36);
groupheader := TfrxGroupHeader.Create(Page);
groupheader.CreateUniqueName;
groupheader.Top := 80;
groupheader.Height := 30;
groupheader.Left := 0;
for i:= 0 to qry_medicalorderdetail.FieldCount-1 do
begin
if (i > 4) and (i < 14) then
begin
Memo := TfrxMemoView.Create(groupheader);
Memo.CreateUniqueName;
Memo.DataSet := frxDBDataSet1;
Memo.text := qry_medicalorderdetail.Fields[i].FieldName;
memo.WordBreak:=true;
memo.Frame.Typ := [ftleft,ftright,fttop,ftbottom];
memo.Frame.LeftLine.Style := fssolid;
memo.Frame.TopLine.Style := fssolid;
memo.Frame.RightLine.Style := fssolid;
memo.Frame.BottomLine.Style := fssolid;
memo.hAlign := hacenter;
memo.WordWrap := true;
Memo.SetBounds(x, 0, width*2, 30);
if i = 6 then
z := x;
if i > 5 then
begin
z := z+width;
Memo.SetBounds(z,0,width,30);
end;
memo.Font.Size := 10;
memo.Font.Name := '宋体';
x:=x+width;
end;
end;
z := 0;
DataBand := TfrxMasterData.Create(Page);
DataBand.CreateUniqueName;
DataBand.DataSet := frxDBDataSet1;
DataBand.AllowSplit:=true;
DataBand.Top := 100;
DataBand.Height := 30;
DataBand.Left := 0;
for i:= 0 to qry_medicalorderdetail.FieldCount-1 do
begin
if (i > 4) and (i < 14) then
begin
Memo := TfrxMemoView.Create(DataBand);
Memo.CreateUniqueName;
Memo.DataSet := frxDBDataSet1;
memo.WordBreak:=true;
Memo.DataField := qry_medicalorderdetail.Fields[i].FieldName;
memo.Frame.Typ := [ftleft,ftright,fttop,ftbottom];
memo.WordWrap := true;
memo.Font.Size := 10;
memo.Font.Name := '宋体';
memo.hAlign := hacenter;
Memo.SetBounds(y, 0, width*2, 30);
if i = 6 then
z := y;
if i > 5 then
begin
z := z+width;
Memo.SetBounds(z,0,width,30);
end;
y:=y+width;
end;
end;
///////////////////////////////////////////////////////////////////
frxReport1.PrepareReport;
frxReport1.PrintOptions.ShowDialog := false;
//预览
frxReport1.ShowPreparedReport;
//打印
frxReport1.print;
本文转自鹅倌51CTO博客,原文链接:http://blog.51cto.com/kaixinbuliao/1104948,如需转载请自行联系原作者