fastreport 报表打印(150分)

  • 主题发起人 主题发起人 zlibo
  • 开始时间 开始时间
Z

zlibo

Unregistered / Unconfirmed
GUEST, unregistred user!
要求:报表文件存入数据库中,类型为image,程序从数据库中取出报表文件显示出来,用户可自定义修改,然后再保存到数据库中<br>最好能发个实例
 
fastreport支持流文件操作<br><br>procedure a;<br>var<br>&nbsp; ms:TMemoryStream;<br>begin<br>&nbsp; fr.savetostream(ms)<br>&nbsp; if ms.Size &gt; 0 then<br>&nbsp; begin<br>&nbsp; &nbsp; ms.posion &nbsp;:= 0;<br>&nbsp; &nbsp; //数据库操作保存流<br>&nbsp; &nbsp;//如:TBlobField(adoq.fieldbyname('fr')).loadfromstream(ms);<br>&nbsp; end;<br>end;<br>//反过来读数据库中的报表设置也是一样的.<br>TBlobField(adoq.fieldbyname('fr')).savetostream(ms);<br>fr.loadfromstream(ms);
 
以下代码请参考:<br>procedure Tfrm.btnSaveClick(Sender: TObject);//存入<br>var<br>&nbsp; mstream:TMemoryStream;<br>begin<br>&nbsp; mstream:=TMemoryStream.Create;<br>&nbsp; try<br>&nbsp; &nbsp; &nbsp;mstream.Position:=0;<br>&nbsp; &nbsp; &nbsp;object1.savetostream(mStream); &nbsp;//对象存入流<br>&nbsp; &nbsp; &nbsp;query1.append;<br>&nbsp; &nbsp; &nbsp;TBlobField(qryDoc.FieldByName('content')).LoadFromStream(mstream);<br>&nbsp; &nbsp; &nbsp;query1.Post;<br>&nbsp; &nbsp; &nbsp;showmessage('saved');<br>&nbsp; except<br>&nbsp; end;<br>&nbsp; mstream.Free;<br>end;<br><br>procedure Tfrm.LoadData(); &nbsp;//读取<br>var<br>&nbsp; mstream:TmemoryStream;<br>begin<br>&nbsp; mstream:=TmemoryStream.Create;<br>&nbsp; with query1 do begin<br>&nbsp; &nbsp; sql.Text:=sqltext;<br>&nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; open;<br>&nbsp; &nbsp; &nbsp; mstream.Position:=0;<br>&nbsp; &nbsp; &nbsp; TblobField(FieldbyName('content')).SaveToStream(mstream); //读取流到字段<br>&nbsp; &nbsp; &nbsp; mstream.Position:=0;<br>&nbsp; &nbsp; &nbsp; object1.LoadFromStream(mstream);<br>&nbsp; &nbsp; &nbsp;except<br>&nbsp; &nbsp; &nbsp;end;<br>&nbsp; end;<br>&nbsp; mstream.Free;<br>end;
 
多人接受答案了。
 
后退
顶部