.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Read Embedded Excel sheet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hello,
I have a drawing with an embedded Excel sheet. I want to read the contents of the excel sheet. How can this be done? Maybe in combination with Microsoft.Office.Interop.Excel?
Ty.
Re: Read Embedded Excel sheet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Does this help
http://adndevblog.typepad.com/autocad/2012/04/upda
Fenton Webb
Developer Technical Services
Autodesk Developer Network
Re: Read Embedded Excel sheet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
I already saw some articles about linked OLE objects, but not about embedded OLE objects. But maybe it will help me, I'll look it at.
Thank you.
Re: Read Embedded Excel sheet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
How do you embed an Excel spreadsheet into a DWG?
Linking means the .xls(x) is somewhere else but we hold a reference to the spreadsheet.
Embedding would mean the Excel object, the spreadsheet and its information is actually inside the DWG. I Haven't tinkered with that possibility yet, how did you manage to achieve it?
Besides from that.
Whether you have the Excel file inside the DWG or just a link to it, just open the Excel object like you would any Excel file, either early or latebound.
Some say "Write in early bound, compile, debug and then translate into late bound", for performance and compability reasons of course.
If you're looking into writing something quick, just do early bound and don't waste time translating.
If you have the time, early bound and then late bound. Creating a custom class can do wonders.
Re: Read Embedded Excel sheet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
I open Excel, add data, copy the cells, and paste it in Autocad. I close Excel without saving it.
I right-click the Excel table in AutoCAD and pick OLE->OPEN to open it again in Exel to edit it.
Since I dont save the Excel file, I assume it is saved in the dwg.
Ty for your reply.
Re: Read Embedded Excel sheet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
For the life of meeeee!
God damned OLE objects!
I'm stuck here:
[CommandMethod("test1")]
public void test1()
{
Database newD = Application.DocumentManager.MdiActiveDocument.Data base;
Editor newE = Application.DocumentManager.MdiActiveDocument.Edit or;
PromptEntityResult per = newE.GetEntity("Pick a OLE object: ");
Object id = per.ObjectId;
using (Transaction newT = newD.TransactionManager.StartTransaction())
{
Ole2Frame myOle = newT.GetObject(per.ObjectId, OpenMode.ForRead) as Ole2Frame;
object excel = myOle.OleObject;
}
}I don't know what to do with that object or how to find how what to do with it.
I've tried everything I could think of (which wasn't much). Online search would not help.
It's an interesting topic, I guess I would need to read about OLE objects.
These guys were on to something, or solved it, I dont even know now:
http://forums.autodesk.com/t5/Autodesk-Inventor-Cu
but it's for Inventor, I dont know if the AutoCAD API has a ReferencedOLEFileDescriptor type.
Keep me updated.
Re: Read Embedded Excel sheet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
OleObject returns an unmanaged COleClientItem object. I don't believe that is exposed by via our .NET API so you are totally on your own there. Your best (perhaps only) option is to use C++
Fenton Webb
Developer Technical Services
Autodesk Developer Network
Re: Read Embedded Excel sheet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Looks like it is possible in .NET but with P/Invoke:
Update linked OLE object from .NET
Re: Read Embedded Excel sheet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I believe that allows you to update the link, not gain access to the OleClientItem itself. But maybe that's all that's needed here?
Fenton Webb
Developer Technical Services
Autodesk Developer Network
Re: Read Embedded Excel sheet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi, Fenton!
I do not think this is all that is necessary to the author. But I point out a direction that may lead him to the solution of its problems.
Description of COleClientItem class: http://msdn.microsoft.com/en-us/library/et2y5cd7%2
IMHO it is possible call P/Invoke any methods of COleClientItem for any purpose. For example, to run associated application (Word/Excel/etc.) hi can P/Invoke method COleClientItem::Run





