VintaSoft Imaging .NET SDK 15.2: Документация для .NET разработчика
В этом разделе
XLSX: Работа с столбцами ячеек на странице XLSX
В этом разделе
UI-контролы SpreadsheetEditorControl и WpfSpreadsheetEditorControl позволяют работать (добавлять, удалять, копировать, вырезать, вставлять, очищать, изменять размер, скрывать/показывать) с столбцами ячеек рабочего листа XLSX в настольном приложении (WinForms, WPF).
Столбцы ячеек можно изменять визуально с помощью мыши/клавиатуры или программно.


Добавление нового столбца ячеек на лист XLSX.

Вот C#/VB.NET код, который демонстрирует, как добавить столбец ячеек на лист XLSX:
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


Удаление столбца ячеек из листа XLSX

Вот C#/VB.NET код, который демонстрирует, как удалить столбец ячеек из листа XLSX:
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


Копирование и вставка столбца ячеек рабочего листа XLSX

Если вы хотите скопировать и вставить столбец ячеек рабочего листа XLSX с помощью мыши, вам следует выполнить следующие шаги:
Вот C#/VB.NET код, который демонстрирует, как скопировать и вставить столбец ячеек листа XLSX:
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


Вырезание и вставка столбца ячеек рабочего листа XLSX

Если вы хотите вырезать и вставить столбец ячеек рабочего листа XLSX с помощью мыши, вам следует выполнить следующие шаги:
Вот C#/VB.NET код, который демонстрирует, как вырезать и вставить столбец ячеек рабочего листа XLSX:
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


Очистка содержимого столбца ячеек рабочего листа XLSX

Если вы хотите очистить содержимое столбца ячейки листа XLSX с помощью мыши, вам следует выполнить следующие шаги:
Вот C#/VB.NET код, который демонстрирует, как очистить содержимое столбца ячеек рабочего листа XLSX:
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


Автоматический подгон ширины столбца ячеек рабочего листа XLSX

Вот C#/VB.NET код, который демонстрирует, как автоматически подогнать ширину столбца ячеек рабочего листа XLSX:
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


Скрытие/показ столба ячеек рабочего листа XLSX

Вот код C# и VB.NET, который демонстрирует как скрыть и показать столбец ячейки листа XLSX:
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