Drive Microsoft Excel

Problem

You want to interact with Microsoft Excel, either to automate a business task or to read and write Excel documents.

Solution

Use the Excel Automation objects included with Microsoft Office.

Discussion

Microsoft provides a rich object model you can use to interact with Excel, allowing you to read and write spreadsheets and manipulate charts and other advanced Excel features. To use Automation with Microsoft Excel, you must first add a reference to the necessary COM library. Right-click your project in the Solution Explorer, select Add Reference, and choose the COM tab. Find the Microsoft Excel Object Library item in the list, and add it. The exact name of the Automation objects depends on the version of Excel you have installed. ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.