你试一下,我试了一下,应该没有问题。 var Bitmap1: TRaveBitMap; begin RvProject1.Close; RvProject1.Open; With RvProject1.ProjMan do begin Bitmap1 := FindRaveComponent('Bitmap1',MyPage) as TRaveBitMap; Bitmap1.CleanupInstance; Bitmap1.Image.LoadFromFile('D:\图片\bit_bmp\152.bmp');// 此处你可以取你的数据库字段 end; try RvProject1.Execute; except MessageBox(handle,'打印出错,请确认打印机是否可用!','提示',MB_ICONINFORMATION); Exit; end; end;
var
Bitmap1: TRaveBitMap;
begin
RvProject1.Close;
RvProject1.Open;
With RvProject1.ProjMan do
begin
Bitmap1 := FindRaveComponent('Bitmap1',MyPage) as TRaveBitMap;
Bitmap1.CleanupInstance;
Bitmap1.Image.LoadFromFile('D:\图片\bit_bmp\152.bmp');// 此处你可以取你的数据库字段
end;
try
RvProject1.Execute;
except
MessageBox(handle,'打印出错,请确认打印机是否可用!','提示',MB_ICONINFORMATION);
Exit;
end;
end;
还有哦 这句 FindRaveComponent('Bitmap1',MyPage) 里面的 Bitmap1 是报表文件中 对应的RAVE图片控件的NAME么? 还有 CleanupInstance 这个方法是干什么用的呢? 先给分了。
cleanupinstance这句是清除句柄,我在试的过程中发现,调用一次后如果不清除一下,直接load会报地址的错误.
你试试吧.
并且如果要使用 TRaveBitMap 那么必须引用 RvCSstd单元
然后发现2楼的 FindRaveComponent('Bitmap1',MyPage) 中的 MYPAGE没有定义 所以搜索了下 得到了答案
var
MyPage:TRavePage;
又因为需要使用 TRavePage 所以必须引用 RvClass 单元
MyPage:= FindRaveComponent('Report1.MyPage', nil) as TRavePage; 其中 'Report1.MyPage'为报表中想关联的页面的名称.例子:
uses RvCSstd,RvClass;
procedure TMainForm.PrintButClick(Sender: TObject);
var
Bitmap1:TRaveBitmap;
MyPage:TRavePage;
//s:string;
begin
//准备打开数据库 并搜索当前页
FunctionDS.Active:=false;
FunctionDS.CommandText:='select * from product where productid='''+trim(LB_CP_ID.Caption)+'''';
FunctionDS.Active:=true;
if FunctionDS.Eof and FunctionDS.Bof then exit; //如果数据库为空 则退出
FunctionDS.First;
//准备准备显示预定的图片
RvProject1.Close;
RvProject1.Open;
With RvProject1.ProjMan do
begin
MyPage:= FindRaveComponent('Report1.MyPage', nil) as TRavePage; //关联页面
Bitmap1:=FindRaveComponent('Bitmap1',MyPage) as TRaveBitmap; //关联 报表文件中的 BitMap1
Bitmap1.CleanupInstance; //清除句柄
Bitmap1.Image:=DefImage.Picture.Graphic; //如果想显示的图片是JPG格式的话,先创建一个TIMAGE控件 然后把图片载入这个TImage 然后再使用 Bitmap1.Image:=DefImage.Picture.Graphic;来让报表文件中的BITMAP1控件来显示这张图片
//Bitmap1.Image.LoadFromFile('D:\图片\bit_bmp\152.bmp');//如果显示的图片是BMP图片的话,直接用这个.
end;
try
RvProject1.Execute;
except
SMB.MessageDlg('打印出错,请确认打印机是否可用!',mtError,mbOKCancel,0);
Exit;
end;
end;结帖.