RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Build a Custom Research Pane for Excel with VSTO : Page 3

Action Panes provide a convenient way for developers to inject custom UI into Office applications, saving users the time and effort of launching and copying information between separate applications.

Adding the Action Pane to the Spreadsheet
Now that you have a working action pane, you need to add it to your spreadsheet, and trigger it to activate when you use your spreadsheet.

Within Sheet1.cs, you need to declare the action pane by making it a member variable of the class and activating it on startup as shown below:

   public partial class Sheet1
     StockResearch sr = new StockResearch();
     private void Sheet1_Startup(object sender, System.EventArgs e)
Now, you can trigger an update to the action pane whenever the user changes an item on the sheet by calling the update method from the Sheet1_Change event. It's very simple, you just pull the value of the Target argument passed to that event-handler, which is the selected range in Excel. You then pass this Range to the StockResearch research pane's GetUpdatedData function which gets the data and updates the Excel pane. You will then see the results from Figure 2.

     private void Sheet1_Change(   
        Microsoft.Office.Interop.Excel.Range Target)
       string strTicker = Target.Text.ToString();
As with Outlook, you can use Excel as a terrific vehicle for delivering your applications. In a situation where you have to deliver research data to your users, they may already be using Excel, and as such by using it, not only will you gain the benefits of a desktop runtime environment that you can deliver your app to, but you'll also be able to enhance their user experience by keeping your application and data inline with theirs. This article presented an example scenario where financial users might be using spreadsheets to manage their portfolios. Using VSTO, you can deliver your data enhancements directly into their spreadsheets by capitalizing on the Action Pane concept. And the best part is that doing so is both straightforward and uses your existing .NET coding skills—developing user controls. In other words, you don't even need to learn a new API to build Action Panes within Office apps.

Laurence Moroney is a freelance enterprise architect who specializes in designing and implementing service-oriented applications and environments using .NET, J2EE, or (preferably) both. He has authored books on .NET and Web services security, and more than 30 professional articles. A former Wall Street architect, and security analyst, he also dabbles in journalism, reporting for professional sports. You can find his blog at http://www.philotic.com/blog.
Email AuthorEmail Author
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date