Microsoft Excel Technology Sample
This sample demonstrates using Microsoft Excel, the spreadsheet component of Microsoft Office, from a managed application. The programmatic functionality of Microsoft Excel is exposed through .NET Programmability Support. Excel is used as a COM server in this sample to illustrate the possibilities for interaction between managed code and the Microsoft Office System.
This sample requires Microsoft Office 2003 with .NET Programmability Support and Microsoft Office Primary Interop Assemblies.
For information about using the samples, see the following topics:
To install .NET Programmability Support
Open the Control Panel and select Add or Remove Programs.
Select Microsoft Office 2003 or Microsoft Excel 2003, and click Change. In the dialog, ensure the Add or Remove Features option button is selected, and click Next.
Select the Choose Advanced Customization of Applications checkbox, and then click Next.
Expand the node for Excel and click the downward-facing arrow adjacent to .NET Programmability Support. Select Run from My Computer.
To install the Microsoft Office Primary Interop Assemblies
Install the Microsoft Office Primary Interop Assemblies (PIAs) from the Web.
A PIA contains type definitions for a native COM object. Once installed, specifying a type library when building an interop application is unnecessary.
To build the sample using the Command Prompt
Open a Command Prompt window and navigate to one of the language-specific subdirectories under the Excel directory.
Enter the following command, using the correct solution file for your programming language.
To build the sample using Visual Studio
Open Windows Explorer and navigate to one of the language-specific subdirectories under the Excel directory.
Double-click the icon for AutoExcelCP.sln, AutoExcelCS.sln or AutoExcelVB.sln, depending on your choice of programming language, to open the file in Visual Studio.
In the Build menu, choose Build Solution.
The sample will be built in the default \bin or \bin\Debug directory.
To run the sample
In the Command Prompt window, navigate to the directory that contains the new executable file.
Type AutoExcel.exe at the command line.
When you have finished, switch to the Command Prompt window and press Enter to close Excel and exit the application.
This sample builds a console application. You must launch it using the command prompt in order to view its output. At the end of execution the sample leaves the Excel window open to show the results.
Microsoft Office 2003
Primary Interop Assemblies for Microsoft Office
.NET Framework Version: 2.0, 1.1, 1.0
Review comments in the source code for more information about Microsoft Office interoperability.