Question

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 from 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.

Was it helpful?

Solution

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

OTHER TIPS

You can add OnChanged in your range changed event.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top