使用临时文件把OLE调用编辑的AutoCAD图形存储到了数据库的BLOB字段,但是采用fastReport制作打印报表的时候,显示不出来,或者在QReport也不能显示。
我现在想采用把数据库字段中的数据读取出来,再转化成AutoCAD文件,用OLE调用,请问该怎么实现?
是否还有其他的实现方法?
很急,分不够可以再加!
Mail:[email protected]
我现在想采用把数据库字段中的数据读取出来,再转化成AutoCAD文件,用OLE调用,请问该怎么实现?
是否还有其他的实现方法?
很急,分不够可以再加!
Mail:[email protected]
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————
你能不能给我一个完整的例子给我看看?我的源代码如下:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtnrs, DB, DBTables;type
TForm1 = class(TForm)
Table1: TTable;
OleContainer1: TOleContainer;
Button1: TButton;
Button2: TButton;
OleContainer2: TOleContainer;
Table1serial: TIntegerField;
Table1procdraw: TBlobField;
Table1partdraw: TBlobField;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
OleContainer1.SaveToFile('tmp');
Table1.Append;
Table1procdraw.LoadFromFile('tmp');
Table1.Post;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
if not Table1procdraw.IsNull then begin
Table1procdraw.SaveToFile('tmp');
OleContainer2.LoadFromFile('tmp');
end;
end;
end.
现在可以读取出来,但在报表里面不能显示,我要求县还原成dwg文件,再用FastReport显示。还有就是用我上面的代码每次读取出来的是第一条记录,或者是刚刚保存的那条记录,怎样指定读取相应的记录?
如果要实现在报表中打印,最好的方法是把CAD图装到OLE中,再通过OLE保存为流的形式放到数据库中,打印时FastReport中也有一个OLE,这其中的数据就用你保存的流就可以了
if not AdoQryJS.FieldByName('js_CADPrint').isNull then
try
tmp:=TMemoryStream.Create;
TBlobField(AdoQryJS.FieldByName('js_CADPrint')).SaveToStream(tmp);
tmp.Position:=0;
(View as TfrOLEView).Flags := flStretched;
(View as TfrOLEView).OleContainer.LoadFromStream(untmp);
(View As TfrOLEView).Visible := True;
finally
tmp.Free;
end
else
(View As TfrOLEView).Visible := False;
end;如果觉得这样在数据库中站用了很大的空间,可以对保存的流进行压缩,压缩后再保存到数据库中,关于如何压缩,呵呵......