Open Excel File Stored in Access Database

shaurya.rastogi

New member
Local time
Today, 22:17
Joined
Feb 9, 2007
Messages
3
I need to open an Excel file that has been stored in the Access Database using the insert Object functionality of MS Access manually.

What i am aware of is that i cant just read the field containing the Excel File into a Byte Array and pass it to the Excel object in C#,as the file is wrapped in the OLE Wrapper used by Access while inserting the file in database.

I have tried locating the Header of Excel file from the byte array and read the file from there on but it is not working.

while (true)
{
if (0xE11AB1A1E011CFD0 == BitConverter.ToUInt64(byStream, i))
break;
i++;
}
output.Write(byStream, i, byStream.Length - i-1);

byStream is a byte array into which i have read the Excel file from Database.
I am locating the Excel file header in the byte stream and am writing the byte array to a file from that location.But on opening the written file it dosent work.
Similar approach had worked in case of Images but now in this case.

Can some one please tell me as to how i can open the Excel File.
Can I use Interop.Access object to achieve the goal??
 
The problem starts with the fact that you OLE-embedded the Excel object in Access. You bought yourself a world of hurt ... well, at least a world of very bad aggravation. I won't say there is NEVER a reason to OLE-embed something in Access, but there are a LOT of reasons to merely OLE-link it. If the named .XLS file exists outside of Access, it is easier to just open an Excel Application object and give it the file name.

If you are an Access novice, I would say there is CATEGORICALLY NEVER a reason to OLE-embed ANYTHING into Access. Once you get to be a really comfortable Access programmer, then MAYBE you might find a RARE case where OLE-embedding makes sense. But OLE-linking is still easier to manage.

PLEASE note that I making a distinction between embedding (placing the object inside the space of Access) vs. linking (placing a pointer to the object inside the space of Access but leaving the object itself outside.) OLE or any other thing you might want will work better if you link rather than embed it, and your performance won't suck nearly so bad.
 
The_Doc_Man said:
The problem starts with the fact that you OLE-embedded the Excel object in Access. You bought yourself a world of hurt ... well, at least a world of very bad aggravation. I won't say there is NEVER a reason to OLE-embed something in Access, but there are a LOT of reasons to merely OLE-link it. If the named .XLS file exists outside of Access, it is easier to just open an Excel Application object and give it the file name.

If you are an Access novice, I would say there is CATEGORICALLY NEVER a reason to OLE-embed ANYTHING into Access. Once you get to be a really comfortable Access programmer, then MAYBE you might find a RARE case where OLE-embedding makes sense. But OLE-linking is still easier to manage.

PLEASE note that I making a distinction between embedding (placing the object inside the space of Access) vs. linking (placing a pointer to the object inside the space of Access but leaving the object itself outside.) OLE or any other thing you might want will work better if you link rather than embed it, and your performance won't suck nearly so bad.
Its not for me to decide how to place the data in access.I have a database which i have to use , now that database has the Excel file embedded..... :(
How do i deal with it now.
 
Tell the person who wrote it that they were guilty of bad design. I don't know how to make that work without extracting the file first. There may be a way but it will be terribly convoluted.

I'm serious. If the person who designed that and gave it to you can't tell you how to make it work, tell them they made a bad decision.
 

Users who are viewing this thread

Back
Top Bottom