开发者

Can I use Microsoft.Office.Tools.Excel in Excel DNA project, or is there another way to accomplish databinding a Table?

I have code that worked in the VSTO version of an Excel Addin

Microsoft.Office.Tools.Excel.ListObject lo = Globals.ThisAddIn.VSTOWorksheet.Controls.AddListObject(r, "lo1");
lo.AutoSetDataBoundColumnHeaders = true;
lo.DataSource = dt; //some DataTable

I was using this API because its declarative databinding syntax. And the Excel.Interop API didn't have methods such as AutoSetDataBoundColumnHeaders..

If I can get Microsoft.Office.Tools.Excel.ListObject imported, how will I resolve the Controls collection on which 开发者_Go百科I call AddListObject without the VSTO stuff inside Excel DNA ?

Any solution would be nice, even if it involves scrapping my code, but in general I'd like to understand when to use which API inside of Excel DNA in order to accomplish this databinding stuff.


VSTO adds some extensions on top of the Excel object model. I have no experience with VSTO, and for stuff like the ListObjects I can't tell where Excel's object model ends and the extended VSTO wrapper objects start.

The boundary is basically this: Microsoft.Office.Interop.Excel can be used from Excel-DNA (so this is the ListObject interface you can use: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.listobject_members.aspx). Microsoft.Office.Tools.Excel is part of VSTO.

Also, I really have no idea whether the VSTO libraries can be used together with Excel-DNA. The issue would be getting the VSTO libraries initialized and hooked up - it might be tricky.

It might be worth it for you to try to re-implement those object model extensions yourself, on top of the Excel object model. I don't think VSTO is doing anything you couldn't do yourself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜