to llfirst:
谢谢您的答复,准备最少出100分感谢您。以上代码 前三次转换正确,到后面转换出的文件都成一样的内容了(存入前可是新编辑的OleWrod),不知为何。
请看我的代码:
//存入数据库---------------------
procedure Tmainfrm.oleSave;
var
oleStream: TMemoryStream;
begin
oleStream := TMemoryStream.create;
try
OleWrod.SaveToStream(oleStream);
oleStream.Position := 0;
DataSet.Edit;
Tblobfield(DataSet.FieldByName('nr')).LoadFromStream(oleStream);
finally
oleStream.Free;
end;
end;
//读出-----------------------------
procedure Tmainfrm.oleLoad;
var
oleStream, outstream: TMemoryStream;
begin
if not DataSet.FieldByName('nr').IsNull then
begin
oleStream := TMemoryStream.create;
outstream := TMemoryStream.create;
try
Tblobfield(DataSet.FieldByName('nr')).SaveToStream(oleStream);
oleStream.Position := 12;
outstream.CopyFrom(oleStream,oleStream.Size-12);
outstream.SaveToFile('c:/tmp1.doc');
//这个文件前几次还正确,但有时导出的文件内容都是一样的,重新编辑OLEWord内容后再保存到库中,再在这导出的文件还是上次不对的(内容都是一样的)那个,不知为何?
finally
oleStream.Free;
outstream.Free;
end;
end;
end;