Is it still true that the AutoCAD NET API does not give access to embedded Excel

Is it still true that the AutoCAD NET API does not give access to embedded Excel

oransen
Collaborator Collaborator
910 Views
3 Replies
Message 1 of 4

Is it still true that the AutoCAD NET API does not give access to embedded Excel

oransen
Collaborator
Collaborator

Is it still true that the AutoCAD NET API does not give access to embedded Excel worksheets?

 

I've looked and looked and there is some complicated MFC stuff for a linked Excel file but I can find no real help for embedded Excel files.

 

In code I've got as far as this:

                            foreach (ObjectId id in btr)
                            {
                                if (id.ObjectClass.Name == "AcDbOle2Frame")
                                try
                                {
                                    Ole2Frame oleFrame = tr.GetObject(id, OpenMode.ForRead) as Ole2Frame;

                                    //object excel = oleFrame.OleObject;
                                    // Excel.Workbook EmbeddedExcel = (Excel.Workbook)oleFrame.OleObject.GetType();
                                    Type eType = oleFrame.OleObject.GetType();
                                    string sMsg = "found OLE object  = " + eType.ToString() ;
                                    LogWriter.LogWrite(sMsg);
                                }
                                catch (System.Exception e)
                                {
                                    string sMsg = string.Format("Exception ExcelChanger: {0}", e.Message);
                                    System.Windows.Forms.MessageBox.Show(sMsg);
                                    LogWriter.LogWrite(sMsg);
                                }
                            }

...but any attempt to do anything useful results in a COM HRESULT error.

 

 

0 Likes
Accepted solutions (1)
911 Views
3 Replies
Replies (3)
Message 2 of 4

antonio.leonardo
Advocate
Advocate
Accepted solution

Hi @oransen,

 

If you decide to throw consume Excel/Access files as OleDb, you need as a prerequisite to install the connector/driver, it's regardless of the AutoCAD .NET API.

 

Also, Adam Nagy explains about approch as similar as your shared code.

 

Att,

Antonio Leonardo

exam-483-programming-in-c.png

Message 3 of 4

oransen
Collaborator
Collaborator

@antonio.leonardo  thanks for the pointers...

 

 

0 Likes
Message 4 of 4

antonio.leonardo
Advocate
Advocate

You're welcome!

0 Likes