Source of demand:
Olecontainer Excel, want to store excel in binary mode and read it in binary mode
Deposit Stream:
Procedure Savetostream (adotable1:tadotable)
Var
Vstream:tmemorystream;
Begin
Try
Try
Vstream: = tmemorystream.create;
Vstream.clear;
Olecontainer1.savetostream (Vstream);
Vstream.position: = 0;
Adotable1.append;
Tblobfield (Adotable1.fieldbyname ("Blobfield")). Loadfromstream (Vstream);
Adotable1.post;
Finally
Freeandnil (Vstream);
End
Except
Exit
End
End
Read stream:
Procedure Loadfromstream (adotable1:tadotable)
Var
Note: The Tadoblobstream is used here, and if you use a stream class such as Tmemorystream, an error will occur
Olecontainer binary stream format differs from Access binary stream format
Tadoblobstream is dedicated to the flow conversion of access, Tadoblobstream inherits from Tmemorystream
Vstream:tadoblobstream;
Begin
Try
Vstream: = Tadoblobstream.create (Tblobfield (Adotable1.fieldbyname ("Blobfield")), Bmread);
if (olecontainer1.state = Osopen) or (olecontainer1.state = osuiactive) Then
Begin
Olecontainer1.destroyobject;
End
Vstream.position: = 0;
Olecontainer1.loadfromstream (Vstream);
Except
End
End
Summary of issues:
Note the problem with the stream format.
Note: There is a gadget in my attachment that helps me to normally manipulate the reading of Excel in Access. http://www.delphibbs.com/keylife/iblog_show.asp?xid=21941
http://blog.csdn.net/shuaihj/article/details/725534
Olecontainer manipulating Excel to read and write databases in binary mode