锐浪报表 Grid++Report 打印数据表时,特别是需要在Cell中打印图像时。例如:
二、图像的保存方式
1、图像以文件形式。保存在指定目录中。
2、数据表中,图像字段,仅保存图像的完整文件名(指定目录)。
3、打印表时,打印该行时,读取图像数据,并打印。
三、设计GIF
1、在图像Cell中,放入图像框:
四、打印浏览
1、执行打印
GridppReport2.PrintPreview( False );
2、初始化
procedure TYHZG_Frm.GridppReport2Initialize(Sender: TObject);
begin
GridppReport2.LoadFromFile( ReportPath+'安全_隐患整改记录_期限.grf' );
G[0]:=GridppReport2.FieldByName('日期');
G[1]:=GridppReport2.FieldByName('闭环');
G[2]:=GridppReport2.FieldByName('检查人员');
G[3]:=GridppReport2.FieldByName('检查情况');
G[4]:=GridppReport2.FieldByName('图像1');
G[5]:=GridppReport2.FieldByName('图像2');
G[6]:=GridppReport2.FieldByName('整改情况');
G[7]:=GridppReport2.FieldByName('记录');
FFilePictureBox1 := GridppReport2.ControlByName('FilePictureBox1').AsPictureBox;
FFilePictureBox2 := GridppReport2.ControlByName('FilePictureBox2').AsPictureBox;
end;
3、数据读取
procedure TYHZG_Frm.GridppReport2FetchRecord(Sender: TObject);
var S:string;
L:integer;
begin
// 参数
GR1:=GridppReport2.AddParameter('Title',grptString);
GridppReport2.ParameterByName('Title').AsString:='安全整改情况表';
GR2:=GridppReport2.AddParameter('UsesN',grptString);
GridppReport2.ParameterByName('UsesN').AsString:=UsesName;
GR3:=GridppReport2.AddParameter('DateS',grptString);
S:=FormatdateTime('yyyy-MM-dd',sDateEdit1.Date)+' 至 '+
FormatdateTime('yyyy-MM-dd',sDateEdit2.Date);
GridppReport2.ParameterByName('DateS').AsString:=S;
with ClientDataSet1 do
begin
DisableControls;
First;
while Not Eof do
begin
if FieldByName('选择').AsBoolean then
begin
GridppReport2.DetailGrid.Recordset.Append();
S:=DateTimeToHanStr(FieldByName('日期').AsString,'',7);
G[0].Value:=S;
if FieldByName('闭环').AsBoolean then S:='√'
else S:='×';
G[1].Value:=S;
G[2].Value:=Trim(FieldByName('检查人员').AsString);
G[3].Value:=Trim(FieldByName('检查情况').AsString);
G[4].Value:=Trim(FieldByName('照片1').AsString);
G[5].Value:=Trim(FieldByName('照片2').AsString);
G[6].Value:=Trim(FieldByName('整改情况').AsString);
if sCheckBox1.Checked then
G[7].Value:=Trim(FieldByName('记录').AsString);
GridppReport2.DetailGrid.Recordset.Post();
end;
Next;
end;
First;
EnableControls;
end;
end;
4、打印图像(数据行)
procedure TYHZG_Frm.GridppReport2ProcessRecord(Sender: TObject);
var PathFile1,PathFile2: string;
begin
PathFile1 := G[4].Value;
if PathFile1<>'' then
begin
FFilePictureBox1.LoadFromFile(PathFile1);
end;
PathFile2 := G[5].Value;
if PathFile2<>'' then
begin
FFilePictureBox2.LoadFromFile(PathFile2);
end;
end;