Exercise 1: Creating a Collection of Business Entities and Inserting their Values into an Excel Worksheet
Business entities are a commonly used pattern to carry data through an application or system. Business entities might reflect a bank account, with a balance and account holder, or they might reflect a shopping cart with a number of items in it, each of those items being its own business entity.
In this exercise, you will learn how to create a collection of business entities and write the values from those entities to an Excel worksheet. Along the way, you will be introduced to new language features in C# 4.0 and Visual Basic 10 that greatly speed the creation of business entities.
To verify that each step is correctly performed, it is recommended to build the solution at the end of each task.
Task 1 – Creating a New Console Application and Reference the Microsoft Office Interop Assemblies
In this task, you will create a new console application and add in the assemblies needed to begin Office development.
Task 2 – Creating a Collection of Business Entities
In this task, you will create a collection of business entities that will be pre-populated with data. Pre-populating simulates loading the entities with data from a separate source. We are shortcutting here to focus on things other than data access.
You will start by creating an individual entity.
Task 3 – Creating an Excel Workbook and Populate it with Data from the Business Entities
In this task, you will create a new Excel workbook. You will then loop through the collection of business objects and insert the data into the Excel workbook. Finally, you will format the worksheet.