Excel Secondary Development Series
Previously we talked about the Excel programming model and common Excel operations. In this section, I will explain how to create an Excel application-level secondary development program.
Many useful materials can be found on Microsoft's basic website. Here we mainly talk about the secondary development of Office projects: http://msdn.microsoft.com/zh-cn/library/cc668205.aspx.
1. Create an Excel Project, for example:
2. The solution is as follows:
3. to better develop an Excel project, you can directly add a functional area to the project as an example of our development:
4. As shown in the following figure:
In this case, you can use the toolbar to add the desired control to group1. At this time, an application-level Excel Add-in (plug-in) has been created.
5. Generally, usercontrol is used in the secondary development process ). Add a user control (Usercontrol1) to the project, and then you can present it when loading the plug-in or calling it. The Code is as follows:
Private void button#click (object sender, RibbonControlEventArgs e)
{
Usercontrol = new UserControl1 ();
MyCustomTaskPane = Globals. ThisAddIn. CustomTaskPanes. Add (usercontrol, "table information"); // add a Pane for this usercontrol
MyCustomTaskPane. Visible = true;
MyCustomTaskPane. DockPosition = Office. MsoCTPDockPosition. msoCTPDockPositionFloating; // set the position for this pane.
MyCustomTaskPane. Height = 220; // set the size for this pane.
MyCustomTaskPane. Width = 480;
// Window excel = e. Control. Context as Window;
// Worksheet sheet = excel. ActiveSheet as Worksheet;
}
6. The following is the same as normal Windows development. Add the corresponding controls on usercontrol to register the events you want to complete. Everything is OK. I will explain how to operate Excel later.
7. Here I will explain that this series is based on office 2007 (Secondary Development of Excel ). So in the web or windows mentioned above, I will share it with you later.