I added the line doc.position := 0;
Still I cannot open a saved xls file.
It does work with word (.doc) and pdf files
csv and exe files wont work
Main Topics
Browse All TopicsHello,
I want to save files to an sql database en from the datbase to file.
It works with pdf, and word files, but XLS files give me troubles.
If i save a file form f.i. 96k to my sql database, and then save it to file again, the file is only 86 k and I can not open it then.
Below the code, on the bitbutton1 click i save the file to database and on the bitbutton2 click I save it back to disk (giving it a different name).
I tried lots of things but nothing seemed to work.
Thanks Rob Nowee
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Just kind of curios, why are you using an OLEContainer to load the Excel file to the stream?
Instead of this:
OleContainer := TOleContainer.Create(nil);
Try
OleContainer.Parent := Form1;// Assuming there is a form
OleContainer.visible := False;
OleContainer.CreateObjectF
MStream := TMemoryStream.Create;
Try
OleContainer.SaveToStream(
adsArchief.Append;
adsArchiefFileName.Value := OpenDialog1.FileName;
(adsArchief.FieldbyName('F
adsArchiefExtension.Value := ExtractFileExt(OpenDialog1
adsArchief.Post;
Finally
MStream.Free;
end;
Finally
OleContainer.Free;
end;
Can't you just use this:
MStream := TMemoryStream.Create;
try
MStream.LoadFromFile(OpenD
adsArchief.Append;
adsArchiefFileName.Value := OpenDialog1.FileName;
(adsArchief.FieldbyName('F
adsArchiefExtension.Value := ExtractFileExt(OpenDialog1
adsArchief.Post;
finally
MStream.Free;
end;
I had no problems storing an Excel 97/2003 or Excel 2007 file.
The Doc.Size report 0 but the file is always saved correctly.
Business Accounts
Answer for Membership
by: EddieShipmanPosted on 2009-06-18 at 09:57:21ID: 24659362
I don't see where you are ever resetting the BlobStream before you do your copy to the FileStream.