Microsoft Office Tutorials and References
In Depth Information
Working with ranges
The following programming tip will help you to avoid seeing the delete warning
message that is displayed to the user when deleting the worksheet.
// To avoid warning messages
this.Application.DisplayAlerts = false;
// The code will delete the second sheet.
Worksheet manipulation helps document users to provide better data processing.
It is advantageous as it has easy access to data, builds better user interfaces, and
optimizes data processing for reports and other business needs.
Working with ranges
Microsoft Office Excel is loaded with a wide variety of objects that can be
programmed for using VSTO 3.0. The Range object is probably the most
frequently-used object in the Excel object model, and helps an Excel developer
to manipulate the cells and their data by using a referenced range. In this section,
we will see how to refer to cells programmatically, and manipulate the ranges of
data in Microsoft Office Excel 2007. The Excel range is a vital part of the Excel
application. A range may correspond to a logical relationship between cells.
The following sample program explains how to read the cells of a worksheet by
using the Range object, and how to format the background color of a range of cells.
Open Visual Studio 2008 and create a new solution, as before. Write the following
code inside the Sheet1.cs file.
private void Sheet1_Startup(object sender, System.EventArgs e)
// Reading Excel using Range object
Excel.Range AuthorRange = Globals.Sheet1.Range["A1", "C5"] as
// Formatting the selected Range with autocolor format
xlRangeAutoFormatColor1, true, false, true, false,
true, true);
Search JabSto ::

Custom Search