The previous article introduced the menu system in Excel, after creating the menu and toolbars, it is necessary to proceed with the development of the function. Regardless of how you develop your Excel application, it is particularly important to understand the Excel object model, which is the cornerstone of your interaction with Excel. According to incomplete statistics, the object model of Excel has more than 270 objects and more than 5,000 properties and methods. With these objects and methods, you can make the most of Excel to customize your plug-in.
All of the objects, events, methods, and properties of Excel are not covered here. This article briefly introduces the overall document object model of Excel, as well as some more important, common development needs frequent contact of objects, attributes, events and methods, such as Application,range objects, so that you have a simple understanding of the entire structure of Excel. After you have a problem with programming, you can quickly locate which object you want to set up or call and how to do it, and then click on the keyword to Google or MSDN for easy lookup. For the most part of this article, refer to this article on MSDN Understanding the Excel Object Model from a. NET Developer ' s perspective if you have no problem with English, we suggest you go to MSDN to see the original text directly.
Introduction to an Excel object model
Before interacting with Excel, it is important to understand the overall structure of the Excel object model, which gives us a more holistic understanding of Excel. The following figure is the entire hierarchy of the object model for Excel.
According to this diagram, we open an Excel, can have a very intuitive image of the understanding.
As you can see in the diagram, the Excel object model basically simulates the UI interface:
An Excel application is a application, a global object such as a menu, and a toolbar that belongs to a Application object.
Related articles:
On the development of Excel (1) Excel Development Overview: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/net/201312/39219.htm
A application can contain many workbook (workbooks). Specifically, we can open many workbooks at the same time (workbooks), but at some point only one workbook (workbook) is edited, and the workbook is called the active workbook (ActiveWorkbook);
A workbook can contain many worksheet (worksheets). Specifically, a workbook can contain many worksheets (worksheets), and at some point only one worksheet (worksheet) is edited, which is called the active worksheet (Activeworksheet).
A workbook can also contain many shapes objects. The worksheet can also contain charts, markers, notes, controls, and so on, which are floating on sheet pages, collectively the shapes, where the most we touch is the chart (charts).
A worksheet can contain many Range objects. Specifically, a worksheet has many cells, a range of cells in range, and a range to make one cell or multiple cells. The cells are embedded in the sheet page.