Worksheet.Rows Property (2007 System)
Gets a Range object that represents one or more rows on the worksheet.
Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)
Syntax
'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property Rows As Range
'Usage
Dim instance As Worksheet
Dim value As Range
value = instance.Rows
[BrowsableAttribute(false)]
public Range Rows { get; }
[BrowsableAttribute(false)]
public:
property Range^ Rows {
Range^ get ();
}
public function get Rows () : Range
Property Value
Type: Range
A Range object that represents one or more rows on the worksheet.
Remarks
When used without parameters, this property returns a Range object that contains all the rows on the worksheet.
This property can be used with the following optional parameters to get specific rows on the worksheet. If you use this property with parameters, the return value is an object that must be cast to a Range.
Parameter |
Description |
---|---|
RowIndex |
The index of one or more rows to get. To get a single row, pass an integer that specifies the index of the row you want to get. The row indexes begin at 1. To get multiple contiguous rows, pass a string with the format "first row:last row". For example, to get rows 1 through 5, pass "1:5". |
ColumnIndex |
Do not use this parameter. This property will throw a COMException if you try to pass a value to this parameter. |
Examples
The following code example uses the Rows property to set the color, name, size, and boldness of the font of all the cells in the first five rows on the worksheet.
This example is for a document-level customization. To run this code, copy it into one of the worksheet classes in your project.
Private Sub SetRowsFont()
Dim fillRows As Excel.Range = TryCast(Me.Rows("1:5"), Excel.Range)
With fillRows.Font
' Set the font color to blue (RGB value 00 00 FF), and set other font properties.
.Color = &HFF0000
.Name = "Arial"
.Size = 14
.Bold = False
End With
' Test the changes by writing a value to all the row cells.
fillRows.Value2 = "This is a test"
End Sub
private void SetRowsFont()
{
Excel.Range fillRows = (Excel.Range)this.Rows["1:5", missing];
Excel.Font rowsFont = fillRows.Font;
// Set the font color to blue (RGB value 00 00 FF), and set other font properties.
rowsFont.Color = 0xFF0000;
rowsFont.Name = "Arial";
rowsFont.Size = 14;
rowsFont.Bold = false;
// Test the changes by writing a value to all the row cells.
fillRows.Value2 = "This is a test";
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
Microsoft.Office.Tools.Excel Namespace
Change History
Date |
History |
Reason |
---|---|---|
February 2009 |
Added information and code example about accessing specific rows. |
Customer feedback. |