|
Programmer's Reference >
ExcelApplication API >
Range
The Range Object
A Range object represents a range in a workbook. A range is a collection of areas. An area is a rectangular collection of cells. The areas in a range may be non-adjacent, and a range can include areas in different worksheets. To create a Range (without a name), call one of the following methods:
Workbook.CreateRange(rangeFormula)
Worksheet.CreateRange(rangeFormula)
Worksheet.CreateRangeOfColumns(firstCol, numCols)
Worksheet.CreateRangeOfRows(int firstRow, int numRows)
If a range is named, it will be accessible when the workbook is opened in
Microsoft Excel. To create a named range, call one of the following
methods:
Workbook.CreateNamedRange(rangeFormula, rangeName)
Worksheet.CreateNamedRange(firstRow, firstColumn, numRows, numColumns, rangeName)
Worksheet.CreateNamedRange(rangeFormula, rangeName)
Examples:
[csharp]
ExcelApplication xla = new ExcelApplication();
Workbook wb = xla.Create();
wb.Worksheets.CreateWorksheet("Sheet2");
Range rng = wb.CreateRange("=Sheet1!A1:A3, Sheet2!A2:C5");
[vbnet]
Dim xla As New ExcelApplication()
Dim wb As Workbook = xla.Create()
wb.Worksheets.CreateWorksheet("Sheet2")
Dim rng As Range = wb.CreateRange("=Sheet1!A1:A3, Sheet2!A2:C5")
Range Properties
| Property |
Type |
Access |
Description |
| AreaCount |
int
|
read |
Returns the number of Areas contained in this Range
|
| Areas |
Area[]
|
read |
Returns an array of the rectangular areas contained in the Range
|
| BorderAround |
Border
|
read |
Sets or returns a Border object that represents a border around the range
|
| FirstCellStyle |
Style
|
read |
Returns the style for the first cell in the range
|
| Item |
Area
|
read |
Returns the Area object at the specified 0-based index
|
Range Methods

Copyright 2006 © SoftArtisans, Inc. All Rights Reserved.
|