XLSX: Work with cell columns on XLSX page
In This Topic
SpreadsheetEditorControl and
WpfSpreadsheetEditorControl controls allow to work (add, delete, copy, cut, paste, clear, resize, hide/show) with cell columns of XLSX worksheet in desktop (WinForms, WPF) application.
Cell columns can be changed visually using mouse/keyboard or programmatically.
Add the new cell column to XLSX worksheet
Here is C#/VB.NET code that demonstrates how to add a cell column to XLSX worksheet:
public void AddCellColumnToXlsxWorksheet(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 column "D"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("D:D");
// insert new cell column before column "D"
spreadsheetVisualEditor.InsertEmptyColumns();
}
Public Sub AddCellColumnToXlsxWorksheet(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 column "D"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("D:D")
' insert new cell column before column "D"
spreadsheetVisualEditor.InsertEmptyColumns()
End Sub
Delete the cell column from XLSX worksheet
Here is C#/VB.NET code that demonstrates how to delete the cell column from XLSX worksheet:
public void DeleteCellColumnOnXlsxWorksheet(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 column "D"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("D:D");
// delete the selected columns
spreadsheetVisualEditor.RemoveColumns();
}
Public Sub DeleteCellColumnOnXlsxWorksheet(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 column "D"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("D:D")
' delete the selected columns
spreadsheetVisualEditor.RemoveColumns()
End Sub
Copy and paste the cell column of XLSX worksheet
If you want to copy and paste the cell column of XLSX worksheet using mouse, you should do the following steps:
- Click the left mouse button on the header of the column, which you want to copy.
- Press "Ctrl+C" key.
- Click the left mouse button on the header of the column, where you want to paste the copied column.
- Press "Ctrl+V" key.
Here is C#/VB.NET code that demonstrates how to copy and paste the cell column of XLSX worksheet:
public void CopyAndPasteCellColumnOnXlsxWorksheet(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 column "D"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("D:D");
// copy the selected cell column
spreadsheetVisualEditor.CopyCells();
// select the entire cell column "E"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("E:E");
// paste the content of column "D" into column "E"
spreadsheetVisualEditor.PasteCells();
}
Public Sub CopyAndPasteCellColumnOnXlsxWorksheet(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 column "D"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("D:D")
' copy the selected cell column
spreadsheetVisualEditor.CopyCells()
' select the entire cell column "E"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("E:E")
' paste the content of column "D" into column "E"
spreadsheetVisualEditor.PasteCells()
End Sub
Cut and paste the cell column of XLSX worksheet
If you want to cut and paste the cell column of XLSX worksheet using mouse, you should do the following steps:
- Click the left mouse button on the header of the column, which you want to cut.
- Press "Ctrl+X" key.
- Click the left mouse button on the header of the column, where you want to paste cutted column.
- Press "Ctrl+V" key.
Here is C#/VB.NET code that demonstrates how to cut and paste the cell column of XLSX worksheet:
public void CutAndPasteCellColumnOnXlsxWorksheet(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 column "D"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("D:D");
// cut the selected cell column
spreadsheetVisualEditor.CutCells();
// select the entire cell column "E"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("E:E");
// paste the content of column "D" into column "E"
spreadsheetVisualEditor.PasteCells();
}
Public Sub CutAndPasteCellColumnOnXlsxWorksheet(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 column "D"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("D:D")
' cut the selected cell column
spreadsheetVisualEditor.CutCells()
' select the entire cell column "E"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("E:E")
' paste the content of column "D" into column "E"
spreadsheetVisualEditor.PasteCells()
End Sub
Clear the content of cell column of XLSX worksheet
If you want to clear the content of the cell column of XLSX worksheet using mouse, you should do the following steps:
- Click the left mouse button on the header of the column, 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 column of XLSX worksheet:
public void ClearCellColumnOnXlsxWorksheet(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 column "D"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("D:D");
// clear the content of selected column
spreadsheetVisualEditor.ClearCellsContents();
}
Public Sub ClearCellColumnOnXlsxWorksheet(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 column "D"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("D:D")
' clear the content of selected column
spreadsheetVisualEditor.ClearCellsContents()
End Sub
Auto fit the width of cell column of XLSX worksheet
Here is C#/VB.NET code that demonstrates how to auto fit the width of cell column of XLSX worksheet:
public void AutoFitColumnWidthOfXlsxCell(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 column "D"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("D:D");
// autofit height of cell column
spreadsheetVisualEditor.AutoFitColumnWidth();
}
Public Sub AutoFitColumnWidthOfXlsxCell(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 column "D"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("D:D")
' autofit height of cell column
spreadsheetVisualEditor.AutoFitColumnWidth()
End Sub
Hide/show the cell column of XLSX worksheet
Here is C#/VB.NET code that demonstrates how to hide and show the cell column of XLSX worksheet:
public void HideAndShowCellColumnOnXlsxWorksheet(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 columns "D", "E", "F" and "G"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("D:G");
// hide the selected cell columns
spreadsheetVisualEditor.HideColumns();
// select the entire cell columns "E" and "F"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("E:F");
// show the selected cell columns
spreadsheetVisualEditor.ShowColumns();
}
Public Sub HideAndShowCellColumnOnXlsxWorksheet(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 columns "D", "E", "F" and "G"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("D:G")
' hide the selected cell columns
spreadsheetVisualEditor.HideColumns()
' select the entire cell columns "E" and "F"
spreadsheetVisualEditor.SetFocusedAndSelectedCells("E:F")
' show the selected cell columns
spreadsheetVisualEditor.ShowColumns()
End Sub