XLSX: Work with cell rows on XLSX page
In This Topic
SpreadsheetEditorControl and
WpfSpreadsheetEditorControl controls allow to work (add, delete, copy, cut, paste, clear, resize, hide/show) with cell rows of XLSX worksheet in desktop (WinForms, WPF) application.
Cell rows can be changed visually using mouse/keyboard or programmatically.
Add the new cell row to an XLSX worksheet
Here is C#/VB.NET code that demonstrates how to add the cell row to an XLSX worksheet:
public void AddCellRowToXlsxWorksheet(Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl)
{
// get visual editor for spreadsheet document
Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor spreadsheetVisualEditor = editorControl.VisualEditor;
// select the entire cell row "2"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("2:2");
// insert new cell row before row "2"
spreadsheetVisualEditor.InsertEmptyRows();
}
Public Sub AddCellRowToXlsxWorksheet(editorControl As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl)
' get visual editor for spreadsheet document
Dim spreadsheetVisualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor = editorControl.VisualEditor
' select the entire cell row "2"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("2:2")
' insert new cell row before row "2"
spreadsheetVisualEditor.InsertEmptyRows()
End Sub
Delete cell row of XLSX worksheet
Here is C#/VB.NET code that demonstrates how to delete the cell row of XLSX worksheet:
public void DeleteCellRowOnXlsxWorksheet(Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl)
{
// get visual editor for spreadsheet document
Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor spreadsheetVisualEditor = editorControl.VisualEditor;
// select the entire cell row "2"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("2:2");
// delete the selected rows
spreadsheetVisualEditor.RemoveRows();
}
Public Sub DeleteCellRowOnXlsxWorksheet(editorControl As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl)
' get visual editor for spreadsheet document
Dim spreadsheetVisualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor = editorControl.VisualEditor
' select the entire cell row "2"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("2:2")
' delete the selected rows
spreadsheetVisualEditor.RemoveRows()
End Sub
Copy and paste the cell row of XLSX worksheet
If you want to copy and paste the cell row of XLSX worksheet using mouse, you should do the following steps:
- Click the left mouse button on the header of the row, which you want to copy.
- Press "Ctrl+C" key.
- Click the left mouse button on the header of the row, where you want to paste copied row.
- Press "Ctrl+V" key.
Here is C#/VB.NET code that demonstrates how to copy and paste the cell row of XLSX worksheet:
public void CopyAndPasteCellRowOnXlsxWorksheet(Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl)
{
// get visual editor for spreadsheet document
Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor spreadsheetVisualEditor = editorControl.VisualEditor;
// select the entire cell row "2"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("2:2");
// copy the selected cell row
spreadsheetVisualEditor.CopyCells();
// select the entire cell row "4"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("4:4");
// paste the content of row "2" into row "4"
spreadsheetVisualEditor.PasteCells();
}
Public Sub CopyAndPasteCellRowOnXlsxWorksheet(editorControl As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl)
' get visual editor for spreadsheet document
Dim spreadsheetVisualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor = editorControl.VisualEditor
' select the entire cell row "2"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("2:2")
' copy the selected cell row
spreadsheetVisualEditor.CopyCells()
' select the entire cell row "4"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("4:4")
' paste the content of row "2" into row "4"
spreadsheetVisualEditor.PasteCells()
End Sub
Cut and paste the cell row of XLSX worksheet
If you want to cut and paste the cell row of XLSX worksheet using mouse, you should do the following steps:
- Click the left mouse button on the header of the row, which you want to cut.
- Press "Ctrl+X" key.
- Click the left mouse button on the header of the row, where you want to paste cutted row.
- Press "Ctrl+V" key.
Here is C#/VB.NET code that demonstrates how to cut and paste the cell row of XLSX worksheet:
public void CutAndPasteCellRowOnXlsxWorksheet(Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl)
{
// get visual editor for spreadsheet document
Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor spreadsheetVisualEditor = editorControl.VisualEditor;
// select the entire cell row "2"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("2:2");
// cut the selected cell row
spreadsheetVisualEditor.CutCells();
// select the entire cell row "4"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("4:4");
// paste the content of row "2" into row "4"
spreadsheetVisualEditor.PasteCells();
}
Public Sub CutAndPasteCellRowOnXlsxWorksheet(editorControl As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl)
' get visual editor for spreadsheet document
Dim spreadsheetVisualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor = editorControl.VisualEditor
' select the entire cell row "2"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("2:2")
' cut the selected cell row
spreadsheetVisualEditor.CutCells()
' select the entire cell row "4"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("4:4")
' paste the content of row "2" into row "4"
spreadsheetVisualEditor.PasteCells()
End Sub
Clear the content of cell row of XLSX worksheet
If you want to clear the content of the cell row of XLSX worksheet using mouse, you should do the following steps:
- Click the left mouse button on the header of the row, where you want to clear the contents.
- Press "Del" key.
Here is C#/VB.NET code that demonstrates how to clear the content of cell row of XLSX worksheet:
public void ClearCellRowOnXlsxWorksheet(Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl)
{
// get visual editor for spreadsheet document
Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor spreadsheetVisualEditor = editorControl.VisualEditor;
// select the entire cell row "2"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("2:2");
// clear the content of selected row
spreadsheetVisualEditor.ClearCellsContents();
}
Public Sub ClearCellRowOnXlsxWorksheet(editorControl As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl)
' get visual editor for spreadsheet document
Dim spreadsheetVisualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor = editorControl.VisualEditor
' select the entire cell row "2"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("2:2")
' clear the content of selected row
spreadsheetVisualEditor.ClearCellsContents()
End Sub
Auto fit the height of cell row of XLSX worksheet
Here is C#/VB.NET code that demonstrates how to auto fit the height of cell row of XLSX worksheet:
public void AutoFitRowHeightOfXlsxCell(Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl)
{
// get visual editor for spreadsheet document
Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor spreadsheetVisualEditor = editorControl.VisualEditor;
// select the entire cell row "2"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("2:2");
// autofit height of cell row
spreadsheetVisualEditor.AutoFitRowHeight();
}
Public Sub AutoFitRowHeightOfXlsxCell(editorControl As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl)
' get visual editor for spreadsheet document
Dim spreadsheetVisualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor = editorControl.VisualEditor
' select the entire cell row "2"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("2:2")
' autofit height of cell row
spreadsheetVisualEditor.AutoFitRowHeight()
End Sub
Hide/show the cell row of XLSX worksheet
Here is C#/VB.NET code that demonstrates how to hide and show the cell row of XLSX worksheet:
public void HideAndShowCellOnXlsxWorksheet(Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl)
{
// get visual editor for spreadsheet document
Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor spreadsheetVisualEditor = editorControl.VisualEditor;
// select the entire cell rows "2", "3", "4", "5" and "6"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("2:6");
// hide the selected cell rows
spreadsheetVisualEditor.HideRows();
// select the entire cell rows "3" and "4"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("3:4");
// show the selected cell rows
spreadsheetVisualEditor.ShowRows();
}
Public Sub HideAndShowCellOnXlsxWorksheet(editorControl As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl)
' get visual editor for spreadsheet document
Dim spreadsheetVisualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor = editorControl.VisualEditor
' select the entire cell rows "2", "3", "4", "5" and "6"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("2:6")
' hide the selected cell rows
spreadsheetVisualEditor.HideRows()
' select the entire cell rows "3" and "4"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("3:4")
' show the selected cell rows
spreadsheetVisualEditor.ShowRows()
End Sub