officefileapi-devexpress-dot-spreadsheet-7e45c042.md
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
public interface Row :
CellRange,
Formatting,
IEnumerable<Cell>,
IEnumerable
Public Interface Row
Inherits CellRange,
Formatting,
IEnumerable(Of Cell),
IEnumerable
The following members return Row objects:
A worksheet is divided into 1,048,576 rows and 16,384 columns. Use the Worksheet.Rows property to access the collection of worksheet rows.
Use the RowCollection.Item property to access an individual row in a worksheet.
using DevExpress.Spreadsheet;
// ...
// Access the row collection.
RowCollection rows = workbook.Worksheets[0].Rows;
// Access the first row in the collection.
Row firstRow = rows[0];
Imports DevExpress.Spreadsheet
' ...
' Access the row collection.
Dim rows As RowCollection = workbook.Worksheets(0).Rows
' Access the first row in the collection.
Dim firstRow As Row = rows(0)
A row index is zero-based. It specifies the row position in the collection.
using DevExpress.Spreadsheet;
// ...
// Access the row collection.
RowCollection rows = workbook.Worksheets[0].Rows;
// Access the first row by its heading.
Row firstRow = rows["1"];
Imports DevExpress.Spreadsheet
' ...
' Access the row collection.
Dim rows As RowCollection = workbook.Worksheets(0).Rows
' Access the first row by its heading.
Dim firstRow As Row = rows("1")
Row headings help users identify each row in a worksheet.
Use the following methods to insert rows into a worksheet:
Row.InsertInserts a row above the current row.RowCollection.InsertInserts rows at the specified position.
Note
The number of rows in a worksheet does not change - 1,048,576. When you add new rows, the rows below are shifted down and an equivalent number of rows at the end of the worksheet is removed.
// Insert the third row.
worksheet.Rows["3"].Insert();
// Insert the fifth row.
worksheet.Rows.Insert(4);
' Insert the third row.
worksheet.Rows("3").Insert()
' Insert the fifth row.
worksheet.Rows.Insert(4)
// Insert three rows (from row 3 to row 5).
worksheet.Rows.Insert(2, 3);
' Insert three rows (from row 3 to row 5).
worksheet.Rows.Insert(2, 3)
Use the Worksheet.InsertCells method to insert empty rows above the specified cells. The method inserts the same number of rows as the specified cell range.
// Insert two rows above the "B3:E4" cell range.
worksheet.InsertCells(worksheet.Range["B3:E4"], InsertCellsMode.EntireRow);
' Insert two rows above the "B3:E4" cell range.
worksheet.InsertCells(worksheet.Range("B3:E4"), InsertCellsMode.EntireRow)
Pass a RowFormatMode enumeration member to the RowCollection.Insert method to specify format options for inserted rows.
// Insert two rows with the same formatting as the first row.
worksheet.Rows.Insert(1, 2, RowFormatMode.FormatAsPrevious);
' Insert two rows with the same formatting as the first row.
worksheet.Rows.Insert(1, 2, RowFormatMode.FormatAsPrevious)
Use the following methods to delete rows from a worksheet:
Row.DeleteRemoves the current row.RowCollection.RemoveRemoves rows at the specified position.
Note
The number of rows in a worksheet does not change - 1,048,576. When you delete rows, the rows below are shifted up and an equivalent number of new rows is added to the end of the worksheet.
// Delete the second row.
worksheet.Rows[1].Delete();
// Delete the third row.
worksheet.Rows.Remove(2);
' Delete the second row.
worksheet.Rows(1).Delete()
' Delete the third row.
worksheet.Rows.Remove(2)
// Delete three rows (from row 2 to row 4).
worksheet.Rows.Remove(1, 3);
' Delete three rows (from row 2 to row 4).
worksheet.Rows.Remove(1, 3)
// Specify the condition to remove worksheet rows.
// If a value in the "D" column is greater than 30, remove the corresponding row.
Func<int, bool> rowRemovalCondition = x => worksheet.Cells[x, 3].Value.NumericValue > 30.0;
// Delete rows that meet the specified condition.
// Check rows 2 through 7.
worksheet.Rows.Remove(1, 6, rowRemovalCondition);
' Specify the condition to remove worksheet rows.
' If a value in the "D" column is greater than 30, remove the corresponding row.
Dim rowRemovalCondition As Func(Of Integer, Boolean) = Function(x) worksheet.Cells(x, 3).Value.NumericValue > 30.0
' Delete rows that meet the specified condition.
' Check rows 2 through 7.
worksheet.Rows.Remove(1, 6, rowRemovalCondition)
Use the Worksheet.DeleteCells method to delete rows that contain the specified cell range.
// Delete a row that contains the "B2" cell.
worksheet.DeleteCells(worksheet.Cells["B2"], DeleteMode.EntireRow);
' Delete a row that contains the "B2" cell.
worksheet.DeleteCells(worksheet.Cells("B2"), DeleteMode.EntireRow)
Use the RowCollection.Group method to group rows.
// Group rows 3 through 6 and collapse the group.
worksheet.Rows.Group(2, 5, true);
// Group rows 9 through 12 and expand the group.
worksheet.Rows.Group(8, 11, false);
// Group rows 2 through 13 to create the outer group.
worksheet.Rows.Group(1, 12, false);
' Group rows 3 through 6 and collapse the group.
worksheet.Rows.Group(2, 5, True)
' Group rows 9 through 12 and expand the group.
worksheet.Rows.Group(8, 11, False)
' Group rows 2 through 13 to create the outer group.
worksheet.Rows.Group(1, 12, False)
Use the RowCollection.UnGroup method to ungroup rows.
// Ungroup rows 3 through 6 and display collapsed data.
worksheet.Rows.UnGroup(2, 5, true);
// Ungroup rows 9 through 12.
worksheet.Rows.UnGroup(8, 11, false);
// Remove the outer row group.
worksheet.Rows.UnGroup(1, 12, false);
' Ungroup rows 3 through 6 and display collapsed data.
worksheet.Rows.UnGroup(2, 5, True)
' Ungroup rows 9 through 12.
worksheet.Rows.UnGroup(8, 11, False)
' Remove the outer row group.
worksheet.Rows.UnGroup(1, 12, False)
Use the following methods to collapse or expand row groups in a worksheet:
RowCollection.CollapseAllGroupsCollapses all row groups.RowCollection.CollapseGroupsCollapses row groups starting with the specified group level.RowCollection.ExpandAllGroupsExpands all row groups.
// Collapse all row groups except the first level group.
worksheet.Rows.CollapseGroups(2);
' Collapse all row groups except the first level group.
worksheet.Rows.CollapseGroups(2)
Use the Row.Visible property or the RowCollection.Hide method to hide rows in a worksheet.
// Hide rows 2 through 6.
worksheet.Rows.Hide(1, 5);
// Hide row 8.
worksheet.Rows[7].Visible = false;
' Hide rows 2 through 6.
worksheet.Rows.Hide(1, 5)
' Hide row 8.
worksheet.Rows(7).Visible = False
Set the Row.Visible property to true to display a row. Use the RowCollection.Unhide method to show multiple hidden rows.
// Show rows 2 through 6.
worksheet.Rows.Unhide(1, 5);
// Show row 8.
worksheet.Rows[7].Visible = true;
' Show rows 2 through 6.
worksheet.Rows.Unhide(1, 5)
' Show row 8.
worksheet.Rows(7).Visible = True
Use the Row.AutoFit or RowCollection.AutoFit method to automatically change the row height to fit the contents.
// Adjust the height of row 2.
worksheet.Rows[1].AutoFit();
// Adjust the height of rows 3 through 5.
worksheet.Rows.AutoFit(2, 4);
' Adjust the height of row 2.
worksheet.Rows(1).AutoFit()
' Adjust the height of rows 3 through 5.
worksheet.Rows.AutoFit(2, 4)
Use the Row.Height property to specify the row height in measurement units defined by the Workbook.Unit property.
// Set the height of row 2 to 50 points.
workbook.Unit = DevExpress.Office.DocumentUnit.Point;
worksheet.Rows[1].Height = 50;
// Set the height of row 5 to the height of row 2.
worksheet.Rows["5"].Height = worksheet.Rows["2"].Height;
' Set the height of row 2 to 50 points.
workbook.Unit = DevExpress.Office.DocumentUnit.Point
worksheet.Rows(1).Height = 50
' Set the height of row 5 to the height of row 2.
worksheet.Rows("5").Height = worksheet.Rows("2").Height
Note
If the row height is set to 0, the row is hidden. You can also use the Row.Visible property to hide a row or display the hidden row again.
Use the Worksheet.DefaultRowHeight property to set the default height for worksheet rows.
Note
The Worksheet.DefaultRowHeight property does not affect rows with explicitly specified heights.
// Set the default row height to 30 points.
workbook.Unit = DevExpress.Office.DocumentUnit.Point;
worksheet.DefaultRowHeight = 30;
' Set the default row height to 30 points.
workbook.Unit = DevExpress.Office.DocumentUnit.Point
worksheet.DefaultRowHeight = 30
Use the CellRange.RowHeight property to set the height of rows that contain the specified cell range.
// Specify the height of the row that contains the "C5" cell.
workbook.Unit = DevExpress.Office.DocumentUnit.Inch;
worksheet.Cells["C5"].RowHeight = 0.5;
' Specify the height of the row that contains the "C5" cell.
workbook.Unit = DevExpress.Office.DocumentUnit.Inch
worksheet.Cells("C5").RowHeight = 0.5
Use the Column.RowHeight property to specify the height of all rows in a worksheet.
// Set the height of all rows to 40 points.
workbook.Unit = DevExpress.Office.DocumentUnit.Point;
worksheet.Columns[0].RowHeight = 40;
' Set the height of all rows to 40 points.
workbook.Unit = DevExpress.Office.DocumentUnit.Point
worksheet.Columns(0).RowHeight = 40
Use the Row.CopyFrom method to copy a row in a worksheet.
// Copy data from row 3 to row 2.
worksheet.Rows[1].CopyFrom(worksheet.Rows[2]);
' Copy data from row 3 to row 2.
worksheet.Rows(1).CopyFrom(worksheet.Rows(2))
Pass a PasteSpecial enumeration member to the Row.CopyFrom method to specify which part of the copied data should be pasted into destination cells.
// Copy number formats from row 3 to row 2.
worksheet.Rows[1].CopyFrom(worksheet.Rows[2], PasteSpecial.NumberFormats);
' Copy number formats from row 3 to row 2.
worksheet.Rows(1).CopyFrom(worksheet.Rows(2), PasteSpecial.NumberFormats)
Use the Row.MoveTo method to move a row to a different position in a worksheet.
Note
When you move rows, existing destination cell content is replaced.
// Move row 3 up one row.
worksheet.Rows[2].MoveTo(worksheet.Rows[1]);
' Move row 3 up one row.
worksheet.Rows(2).MoveTo(worksheet.Rows(1))
Show 35 items
ExportToImage(RangeImageOptions)
ExportToImage(String, ImageFileFormat)
ExportToImage(String, ImageFileFormat, RangeImageOptions)
ExportToImage(Stream, ImageFileFormat)
ExportToImage(Stream, ImageFileFormat, RangeImageOptions)
ClearOutline(Boolean, Boolean)
Subtotal(Int32, List<Int32>, Int32, String)
NumericalCount(Boolean, Boolean)
See Also