Introduction to C# and Excel Integration
20.1 INTRODUCTION AND OBJECTIVES
This is the introductory chapter in a set of four chapters on Excel programming with C#. We give a global overview of the Excel Object Model and how to access its objects using C#. We also discuss a number of concepts that will help our understanding of the material in later chapters. We also give an overview of the different kinds of Excel add-ins that can be created using languages such as C#, VB.NET and VBA. In later chapters we discuss Automation and COM (Component Object Model) add-ins in more detail. We also discuss the Datasim Excel Visualisation Package that we created in order to display information in Excel.
20.2 EXCEL OBJECT MODEL
In this section we discuss the object model in Excel. We can view the Excel application as a hierarchy of objects and these can be programmatically accessed in languages such as C#, VBA, VB.NET, unmanaged C++ and C++/CLI. A simplified version of the Excel object hierarchy is shown in Figure 20.1. In general, an object at a given level contains zero or more objects one level below it. For example, Excel application contains several workbooks and a workbook contains several worksheets. Other objects not shown in Figure 20.1 are:
Our interest lies in accessing the object model from C#. Most of the documentation ...