Olecontainer manipulating Excel to read and write databases in binary mode

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.