开发者

monitoring a range of cells inside of excel 2007 with C#/VSTO

开发者 https://www.devze.com 2022-12-12 20:53 出处:网络
I have a row in excel I\'d like to translate into an ObserveableCollection in C# for binding/event purposes, so all accessor classes know they\'re getting the latest data fr开发者_StackOverflow社区om

I have a row in excel I'd like to translate into an ObserveableCollection in C# for binding/event purposes, so all accessor classes know they're getting the latest data fr开发者_StackOverflow社区om the source excel sheet. How would this be done?

Clarification: I'm using an excel add-in project, not a workbook project, so am not sure whether or not XMLMappedRange Controls are an option.


Using VSTO you have a few options:

  1. From the Excel.Worksheet class, you can access the Worksheet.Change event.
  2. From the NamedRange class, you can access the NamedRange.Change event (which uses the Microsoft.Office.Interop.Excel.DocEvents_ChangeEventHandler delegate that you mentioned in another comment).
  3. The NamedRange class also supports simple, one-way databinding via the DataBindings property, an example of which is shown in the discussion How do I bind an array to a NamedRange.
  4. Another possibility is the XmlMappedRange control, which also supports databinding.

A good primer on using the NamedRange and XmlMappedRange can be found here: The VSTO Programming Model. A decent walkthrough using the NamedRange can be found in the Visual Studio Tools for Office (VSTO) 2005 Guided Tour.

I hope this helps...

Mike


You can add OnChanged in your range changed event.

0

精彩评论

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

关注公众号