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


Список поддерживаемых стандартных типов диаграмм

Вот список стандартных типов диаграмм, которые поддерживаются SDK:

Добавление новой диаграммы на лист XLSX

Если вы хотите добавить новую диаграмму, вам необходимо предоставить существующую диаграмму в качестве шаблона для новой диаграммы.

Вот C#/VB.NET код, который демонстрирует, как добавить столбчатую диаграмму на сфокусированный рабочий лист XLSX:
/// <summary>
/// Adds the chart to a worksheet.
/// </summary>
/// <param name="editorControl">The spreadsheet editor control.</param>
/// <param name="templateFilePath">A name of file that contains templates of charts.</param>
/// <param name="worksheetIndex">A zero-based index of the worksheet that contains the chart.</param>
/// <param name="chartIndex">A zero-based index of the chart that should be added.</param>
public void AddChartToXlsxWorksheet(
    Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl,
    string chartTemplateFileName,
    int worksheetIndex,
    int chartIndex)
{
    // get visual editor for spreadsheet document
    Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor spreadsheetVisualEditor = editorControl.VisualEditor;

    // open XLSX file that contains template chart
    using (Vintasoft.Imaging.Office.Spreadsheet.SpreadsheetEditorSource templateSource =
        new Vintasoft.Imaging.Office.Spreadsheet.SpreadsheetEditorSource(chartTemplateFileName))
    {
        // create the editor for template XLSX file
        using (Vintasoft.Imaging.Office.Spreadsheet.SpreadsheetEditor templateSourceEditor =
            new Vintasoft.Imaging.Office.Spreadsheet.SpreadsheetEditor(templateSource, false))
        {
            // initialize the editor
            templateSourceEditor.Initialize(new Vintasoft.Imaging.Office.Spreadsheet.SpreadsheetEditorSettings());
            // get worksheet by worksheet index
            Vintasoft.Imaging.Office.Spreadsheet.Document.Worksheet worksheet = templateSourceEditor.Document.Worksheets[worksheetIndex];
            // get the template chart by chart index
            Vintasoft.Imaging.Office.Spreadsheet.Document.SheetDrawing templateChart = worksheet.Drawings[chartIndex];

            // add new chart that is based on template chart
            spreadsheetVisualEditor.AddChart(worksheet, templateChart);
        }
    }
}
''' <summary>
''' Adds the chart to a worksheet.
''' </summary>
''' <param name="editorControl">The spreadsheet editor control.</param>
''' <param name="templateFilePath">A name of file that contains templates of charts.</param>
''' <param name="worksheetIndex">A zero-based index of the worksheet that contains the chart.</param>
''' <param name="chartIndex">A zero-based index of the chart that should be added.</param>
Public Sub AddChartToXlsxWorksheet(editorControl As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl, chartTemplateFileName As String, worksheetIndex As Integer, chartIndex As Integer)
    ' get visual editor for spreadsheet document
    Dim spreadsheetVisualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor = editorControl.VisualEditor

    ' open XLSX file that contains template chart
    Using templateSource As New Vintasoft.Imaging.Office.Spreadsheet.SpreadsheetEditorSource(chartTemplateFileName)
        ' create the editor for template XLSX file
        Using templateSourceEditor As New Vintasoft.Imaging.Office.Spreadsheet.SpreadsheetEditor(templateSource, False)
            ' initialize the editor
            templateSourceEditor.Initialize(New Vintasoft.Imaging.Office.Spreadsheet.SpreadsheetEditorSettings())
            ' get worksheet by worksheet index
            Dim worksheet As Vintasoft.Imaging.Office.Spreadsheet.Document.Worksheet = templateSourceEditor.Document.Worksheets(worksheetIndex)
            ' get the template chart by chart index
            Dim templateChart As Vintasoft.Imaging.Office.Spreadsheet.Document.SheetDrawing = worksheet.Drawings(chartIndex)

            ' add new chart that is based on template chart
            spreadsheetVisualEditor.AddChart(worksheet, templateChart)
        End Using
    End Using
End Sub


Данные диаграммы: Установите данные серии диаграммы

Если вы хотите установить данные серии для диаграммы с помощью мыши, вам следует выполнить следующие шаги:

Данные диаграммы: Установка данных категории для диаграммы

Если вы хотите установить данные категории для диаграммы с помощью мыши, вам следует выполнить следующие шаги:

Вид диаграммы: Установка меток осей для диаграммы

Если вы хотите установить метки осей для диаграммы с помощью мыши, вам следует выполнить следующие шаги:

Данные диаграммы: Установка данных диаграммы (серии, категории, метки осей) для диаграммы.

Вот C#/VB.NET код, который демонстрирует, как изменить данные диаграммы для диаграммы на листе XLSX:
/// <summary>
/// Changes the chart data (categories name, series name and series values) for chart in SalesReport.xlsx file.
/// </summary>
/// <param name="editorControl">The spreadsheet editor control.</param>
public void SetDataOfXlsxChart(Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl)
{
    // get visual editor for spreadsheet document
    Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor spreadsheetVisualEditor = editorControl.VisualEditor;

    // create worksheet editor
    Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.WorksheetEditor worksheetEditor =
        spreadsheetVisualEditor.Editor.StartEditing(spreadsheetVisualEditor.FocusedWorksheet);
    try
    {
        // create editor for focused chart
        Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.SheetDrawingEditor chartEditor =
            worksheetEditor.CreateDrawingEditor(spreadsheetVisualEditor.FocusedDrawing);
        // create editor for chart properties
        Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.ChartPropertiesEditor chartPropertiesEditor =
            chartEditor.CreateChartPropertiesEditor();

        // create the cell references, which reference cells region "D6:F6" as cells for data of chart categories
        Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences categoriesReferences =
            Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences.CreateFixedReferences(
            Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences.Parse("D6:F6"),
            spreadsheetVisualEditor.FocusedWorksheet.Name,
            true, true);

        // create the cell references, which reference cells region "C7:C10" as cells for data of chart series
        Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences seriesReferences =
            Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences.CreateFixedReferences(
            Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences.Parse("C7:C10"),
            spreadsheetVisualEditor.FocusedWorksheet.Name,
            true, true);

        // create the cell references, which reference cells region "D7:F10" as cells for data of chart series data
        Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences seriesDataReferences =
            Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences.CreateFixedReferences(
            Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences.Parse("D7:F10"),
            spreadsheetVisualEditor.FocusedWorksheet.Name,
            true, true);

        // union all references
        Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences references =
            Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences.Union(categoriesReferences,
            Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences.Union(seriesReferences, seriesDataReferences));

        // set data references for chart
        chartPropertiesEditor.SetDataReferences(references);
    }
    finally
    {
        spreadsheetVisualEditor.Editor.FinishEditing();
    }
}
''' <summary>
''' Changes the chart data (categories name, series name and series values) for chart in SalesReport.xlsx file.
''' </summary>
''' <param name="editorControl">The spreadsheet editor control.</param>
Public Sub SetDataOfXlsxChart(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

    ' create worksheet editor
    Dim worksheetEditor As Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.WorksheetEditor = spreadsheetVisualEditor.Editor.StartEditing(spreadsheetVisualEditor.FocusedWorksheet)
    Try
        ' create editor for focused chart
        Dim chartEditor As Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.SheetDrawingEditor = worksheetEditor.CreateDrawingEditor(spreadsheetVisualEditor.FocusedDrawing)
        ' create editor for chart properties
        Dim chartPropertiesEditor As Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.ChartPropertiesEditor = chartEditor.CreateChartPropertiesEditor()

        ' create the cell references, which reference cells region "D6:F6" as cells for data of chart categories
        Dim categoriesReferences As Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences = Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences.CreateFixedReferences(Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences.Parse("D6:F6"), spreadsheetVisualEditor.FocusedWorksheet.Name, True, True)

        ' create the cell references, which reference cells region "C7:C10" as cells for data of chart series
        Dim seriesReferences As Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences = Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences.CreateFixedReferences(Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences.Parse("C7:C10"), spreadsheetVisualEditor.FocusedWorksheet.Name, True, True)

        ' create the cell references, which reference cells region "D7:F10" as cells for data of chart series data
        Dim seriesDataReferences As Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences = Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences.CreateFixedReferences(Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences.Parse("D7:F10"), spreadsheetVisualEditor.FocusedWorksheet.Name, True, True)

        ' union all references
        Dim references As Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences = Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences.Union(categoriesReferences, Vintasoft.Imaging.Office.Spreadsheet.Document.CellReferences.Union(seriesReferences, seriesDataReferences))

        ' set data references for chart
        chartPropertiesEditor.SetDataReferences(references)
    Finally
        spreadsheetVisualEditor.Editor.FinishEditing()
    End Try
End Sub


Вид диаграммы: Установка заголовка диаграммы

Вот C#/VB.NET код, который демонстрирует, как установить текст и шрифт заголовок диаграммы:
/// <summary>
/// Sets the chart title and font properties.
/// </summary>
/// <param name="editorControl">The spreadsheet editor control.</param>
/// <param name="fontProperties">The title font properties.</param>
/// <param name="title">The title text.</param>
public void SetTitleOfXlsxChart(
    Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl, 
    Vintasoft.Imaging.Office.Spreadsheet.Document.FontProperties fontProperties,
    string title)
{
    // get visual editor for spreadsheet document
    Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor spreadsheetVisualEditor = editorControl.VisualEditor;

    // create worksheet editor
    Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.WorksheetEditor worksheetEditor =
        spreadsheetVisualEditor.Editor.StartEditing(spreadsheetVisualEditor.FocusedWorksheet);
    try
    {
        // create editor for focused chart
        Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.SheetDrawingEditor chartEditor =
            worksheetEditor.CreateDrawingEditor(spreadsheetVisualEditor.FocusedDrawing);
        // create editor for chart properties
        Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.ChartPropertiesEditor chartPropertiesEditor =
            chartEditor.CreateChartPropertiesEditor();

        // set title of the chart
        chartPropertiesEditor.SetTitle(title);

        // create the text appearance
        Vintasoft.Imaging.Office.Spreadsheet.Document.TextAppearance textAppearance = new Vintasoft.Imaging.Office.Spreadsheet.Document.TextAppearance(
                fontProperties,
                new Vintasoft.Imaging.Office.Spreadsheet.Document.TextProperties());

        // create the text and shape appearance
        Vintasoft.Imaging.Office.Spreadsheet.Document.TextShapeAppearance appearance = new Vintasoft.Imaging.Office.Spreadsheet.Document.TextShapeAppearance(
            textAppearance,
            chartPropertiesEditor.ChartProperties.TitleAppearance.ShapeAppearance);

        chartPropertiesEditor.SetTitleAppearance(appearance);
    }
    finally
    {
        spreadsheetVisualEditor.Editor.FinishEditing();
    }
}
''' <summary>
''' Sets the chart title and font properties.
''' </summary>
''' <param name="editorControl">The spreadsheet editor control.</param>
''' <param name="fontProperties">The title font properties.</param>
''' <param name="title">The title text.</param>
Public Sub SetTitleOfXlsxChart(editorControl As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl, fontProperties As Vintasoft.Imaging.Office.Spreadsheet.Document.FontProperties, title As String)
    ' get visual editor for spreadsheet document
    Dim spreadsheetVisualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor = editorControl.VisualEditor

    ' create worksheet editor
    Dim worksheetEditor As Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.WorksheetEditor = spreadsheetVisualEditor.Editor.StartEditing(spreadsheetVisualEditor.FocusedWorksheet)
    Try
        ' create editor for focused chart
        Dim chartEditor As Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.SheetDrawingEditor = worksheetEditor.CreateDrawingEditor(spreadsheetVisualEditor.FocusedDrawing)
        ' create editor for chart properties
        Dim chartPropertiesEditor As Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.ChartPropertiesEditor = chartEditor.CreateChartPropertiesEditor()

        ' set title of the chart
        chartPropertiesEditor.SetTitle(title)

        ' create the text appearance
        Dim textAppearance As New Vintasoft.Imaging.Office.Spreadsheet.Document.TextAppearance(fontProperties, New Vintasoft.Imaging.Office.Spreadsheet.Document.TextProperties())

        ' create the text and shape appearance
        Dim appearance As New Vintasoft.Imaging.Office.Spreadsheet.Document.TextShapeAppearance(textAppearance, chartPropertiesEditor.ChartProperties.TitleAppearance.ShapeAppearance)

        chartPropertiesEditor.SetTitleAppearance(appearance)
    Finally
        spreadsheetVisualEditor.Editor.FinishEditing()
    End Try
End Sub


Вид диаграммы: Установка цвета области графика и области диаграммы

Вот C#/VB.NET код, который демонстрирует, как установить цвет области графика и области диаграммы:
/// <summary>
/// Sets the chart background color and the plot area background color.
/// </summary>
/// <param name="editorControl">The spreadsheet editor control.</param>
/// <param name="chartBackgroundColor">The chart background color.</param>
/// <param name="plotAreaBackgroundColor">The plot area background color.</param>
public void SetColorForPlotAndChartAreaOfXlsxChart(
    Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl,
    Vintasoft.Primitives.VintasoftColor chartBackgroundColor,
    Vintasoft.Primitives.VintasoftColor plotAreaBackgroundColor)
{
    // get visual editor for spreadsheet document
    Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor spreadsheetVisualEditor = editorControl.VisualEditor;

    // create worksheet editor
    Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.WorksheetEditor worksheetEditor =
        spreadsheetVisualEditor.Editor.StartEditing(spreadsheetVisualEditor.FocusedWorksheet);
    try
    {
        // create editor for focused chart
        Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.SheetDrawingEditor chartEditor =
            worksheetEditor.CreateDrawingEditor(spreadsheetVisualEditor.FocusedDrawing);
        // create editor for chart properties
        Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.ChartPropertiesEditor chartPropertiesEditor =
            chartEditor.CreateChartPropertiesEditor();

        // set the chart appearance
        chartPropertiesEditor.SetChartAreaAppearance(new Vintasoft.Imaging.Office.Spreadsheet.Document.ShapeAppearance(
            chartBackgroundColor,
            chartPropertiesEditor.ChartProperties.ChartAreaAppearance.OutlineColor,
            chartPropertiesEditor.ChartProperties.ChartAreaAppearance.OutlineWidth));
        // set the plot area appearance
        chartPropertiesEditor.SetPlotAreaAppearance(new Vintasoft.Imaging.Office.Spreadsheet.Document.ShapeAppearance(
            plotAreaBackgroundColor,
            chartPropertiesEditor.ChartProperties.PlotAreaAppearance.OutlineColor,
            chartPropertiesEditor.ChartProperties.PlotAreaAppearance.OutlineWidth));
    }
    finally
    {
        spreadsheetVisualEditor.Editor.FinishEditing();
    }
}
''' <summary>
''' Sets the chart background color and the plot area background color.
''' </summary>
''' <param name="editorControl">The spreadsheet editor control.</param>
''' <param name="chartBackgroundColor">The chart background color.</param>
''' <param name="plotAreaBackgroundColor">The plot area background color.</param>
Public Sub SetColorForPlotAndChartAreaOfXlsxChart(editorControl As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl, chartBackgroundColor As Vintasoft.Primitives.VintasoftColor, plotAreaBackgroundColor As Vintasoft.Primitives.VintasoftColor)
    ' get visual editor for spreadsheet document
    Dim spreadsheetVisualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor = editorControl.VisualEditor

    ' create worksheet editor
    Dim worksheetEditor As Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.WorksheetEditor = spreadsheetVisualEditor.Editor.StartEditing(spreadsheetVisualEditor.FocusedWorksheet)
    Try
        ' create editor for focused chart
        Dim chartEditor As Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.SheetDrawingEditor = worksheetEditor.CreateDrawingEditor(spreadsheetVisualEditor.FocusedDrawing)
        ' create editor for chart properties
        Dim chartPropertiesEditor As Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.ChartPropertiesEditor = chartEditor.CreateChartPropertiesEditor()

        ' set the chart appearance
        chartPropertiesEditor.SetChartAreaAppearance(New Vintasoft.Imaging.Office.Spreadsheet.Document.ShapeAppearance(chartBackgroundColor, chartPropertiesEditor.ChartProperties.ChartAreaAppearance.OutlineColor, chartPropertiesEditor.ChartProperties.ChartAreaAppearance.OutlineWidth))
        ' set the plot area appearance
        chartPropertiesEditor.SetPlotAreaAppearance(New Vintasoft.Imaging.Office.Spreadsheet.Document.ShapeAppearance(plotAreaBackgroundColor, chartPropertiesEditor.ChartProperties.PlotAreaAppearance.OutlineColor, chartPropertiesEditor.ChartProperties.PlotAreaAppearance.OutlineWidth))
    Finally
        spreadsheetVisualEditor.Editor.FinishEditing()
    End Try
End Sub


Вид диаграммы: Установка цвета для серии диаграммы

Вот C#/VB.NET код, который демонстрирует, как установить цвет для серии диаграммы:
/// <summary>
/// Sets the colors for the specified chart series.
/// </summary>
/// <param name="editorControl">The spreadsheet editor control.</param>
/// <param name="seriesIndex">Index of the series.</param>
public void SetColorsForChartSeriesOfXlsxChart(
    Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl,
    int seriesIndex)
{
    // get visual editor for spreadsheet document
    Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor spreadsheetVisualEditor = editorControl.VisualEditor;

    // create worksheet editor
    Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.WorksheetEditor worksheetEditor =
        spreadsheetVisualEditor.Editor.StartEditing(spreadsheetVisualEditor.FocusedWorksheet);
    try
    {
        // create editor for focused chart
        Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.SheetDrawingEditor chartEditor =
            worksheetEditor.CreateDrawingEditor(spreadsheetVisualEditor.FocusedDrawing);
        // create editor for chart properties
        Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.ChartPropertiesEditor chartPropertiesEditor =
            chartEditor.CreateChartPropertiesEditor();
        // create editor for chart series
        Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.ChartDataSeriesEditor seriesEditor =
            chartPropertiesEditor.CreateChartDataSeriesEditor(chartPropertiesEditor.ChartProperties.Series[seriesIndex]);

        Vintasoft.Imaging.Office.Spreadsheet.Document.ShapeAppearance appearance = new Vintasoft.Imaging.Office.Spreadsheet.Document.ShapeAppearance(
            Vintasoft.Primitives.VintasoftColor.Black,
            Vintasoft.Primitives.VintasoftColor.Red, 3);

        // set appearance for chart series
        seriesEditor.SetAppearanceProperties(appearance);
    }
    finally
    {
        spreadsheetVisualEditor.Editor.FinishEditing();
    }
}
''' <summary>
''' Sets the colors for the specified chart series.
''' </summary>
''' <param name="editorControl">The spreadsheet editor control.</param>
''' <param name="seriesIndex">Index of the series.</param>
Public Sub SetColorsForChartSeriesOfXlsxChart(editorControl As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl, seriesIndex As Integer)
    ' get visual editor for spreadsheet document
    Dim spreadsheetVisualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor = editorControl.VisualEditor

    ' create worksheet editor
    Dim worksheetEditor As Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.WorksheetEditor = spreadsheetVisualEditor.Editor.StartEditing(spreadsheetVisualEditor.FocusedWorksheet)
    Try
        ' create editor for focused chart
        Dim chartEditor As Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.SheetDrawingEditor = worksheetEditor.CreateDrawingEditor(spreadsheetVisualEditor.FocusedDrawing)
        ' create editor for chart properties
        Dim chartPropertiesEditor As Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.ChartPropertiesEditor = chartEditor.CreateChartPropertiesEditor()
        ' create editor for chart series
        Dim seriesEditor As Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.ChartDataSeriesEditor = chartPropertiesEditor.CreateChartDataSeriesEditor(chartPropertiesEditor.ChartProperties.Series(seriesIndex))

        Dim appearance As New Vintasoft.Imaging.Office.Spreadsheet.Document.ShapeAppearance(Vintasoft.Primitives.VintasoftColor.Black, Vintasoft.Primitives.VintasoftColor.Red, 3)

        ' set appearance for chart series
        seriesEditor.SetAppearanceProperties(appearance)
    Finally
        spreadsheetVisualEditor.Editor.FinishEditing()
    End Try
End Sub


Вид диаграммы: Установка цвета для точек данных диаграммы.

Вот C#/VB.NET код, который демонстрирует, как установить цвета для точек данных диаграммы:
/// <summary>
/// Sets the colors for chart data points.
/// </summary>
/// <param name="editorControl">The spreadsheet editor control.</param>
/// <param name="seriesIndex">A zero-based index of the chart series.</param>
public void SetColorsForChartDataPointsOfXlsxChart(
    Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl,
    int seriesIndex)
{
    // get visual editor for spreadsheet document
    Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor spreadsheetVisualEditor = editorControl.VisualEditor;

    // create worksheet editor
    Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.WorksheetEditor worksheetEditor =
        spreadsheetVisualEditor.Editor.StartEditing(spreadsheetVisualEditor.FocusedWorksheet);
    try
    {
        // create editor for focused chart
        Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.SheetDrawingEditor chartEditor =
            worksheetEditor.CreateDrawingEditor(spreadsheetVisualEditor.FocusedDrawing);
        // create editor for chart properties
        Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.ChartPropertiesEditor chartPropertiesEditor =
            chartEditor.CreateChartPropertiesEditor();
        // create editor for chart series
        Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.ChartDataSeriesEditor seriesEditor =
            chartPropertiesEditor.CreateChartDataSeriesEditor(chartPropertiesEditor.ChartProperties.Series[seriesIndex]);

        // create new data points
        Vintasoft.Imaging.Office.Spreadsheet.Document.ChartDataPoint[] dataPoints =
            new Vintasoft.Imaging.Office.Spreadsheet.Document.ChartDataPoint[seriesEditor.Series.DataPoints.Length];

        for (int i = 0; i < dataPoints.Length; i++)
        {
            // get data point from chart
            Vintasoft.Imaging.Office.Spreadsheet.Document.ChartDataPoint dataPoint = seriesEditor.Series.DataPoints[i];
            Vintasoft.Imaging.Office.Spreadsheet.Document.ChartMarker marker = null;

            // if data point has marker
            if (dataPoint.Marker != null)
            {
                Vintasoft.Imaging.Office.Spreadsheet.Document.ShapeAppearance dataPointMarkerAppearance = new Vintasoft.Imaging.Office.Spreadsheet.Document.ShapeAppearance(
                    Vintasoft.Primitives.VintasoftColor.Red,
                    Vintasoft.Primitives.VintasoftColor.Blue, 3);

                // create new marker for new data point
                marker = new Vintasoft.Imaging.Office.Spreadsheet.Document.ChartMarker(
                    dataPoint.Marker.Style,
                    dataPoint.Marker.Size,
                    dataPointMarkerAppearance);
            }

            Vintasoft.Imaging.Office.Spreadsheet.Document.ShapeAppearance dataPointAppearance = new Vintasoft.Imaging.Office.Spreadsheet.Document.ShapeAppearance(
                Vintasoft.Primitives.VintasoftColor.Black,
                Vintasoft.Primitives.VintasoftColor.Green, 3);

            // change the color of new data point
            dataPoints[i] = new Vintasoft.Imaging.Office.Spreadsheet.Document.ChartDataPoint(marker, dataPointAppearance);
        }

        // set new data points for chart
        seriesEditor.SetDataPoints(dataPoints);
    }
    finally
    {
        spreadsheetVisualEditor.Editor.FinishEditing();
    }
}
''' <summary>
''' Sets the colors for chart data points.
''' </summary>
''' <param name="editorControl">The spreadsheet editor control.</param>
''' <param name="seriesIndex">A zero-based index of the chart series.</param>
Public Sub SetColorsForChartDataPointsOfXlsxChart(editorControl As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl, seriesIndex As Integer)
    ' get visual editor for spreadsheet document
    Dim spreadsheetVisualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor = editorControl.VisualEditor

    ' create worksheet editor
    Dim worksheetEditor As Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.WorksheetEditor = spreadsheetVisualEditor.Editor.StartEditing(spreadsheetVisualEditor.FocusedWorksheet)
    Try
        ' create editor for focused chart
        Dim chartEditor As Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.SheetDrawingEditor = worksheetEditor.CreateDrawingEditor(spreadsheetVisualEditor.FocusedDrawing)
        ' create editor for chart properties
        Dim chartPropertiesEditor As Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.ChartPropertiesEditor = chartEditor.CreateChartPropertiesEditor()
        ' create editor for chart series
        Dim seriesEditor As Vintasoft.Imaging.Office.Spreadsheet.Document.Editors.ChartDataSeriesEditor = chartPropertiesEditor.CreateChartDataSeriesEditor(chartPropertiesEditor.ChartProperties.Series(seriesIndex))

        ' create new data points
        Dim dataPoints As Vintasoft.Imaging.Office.Spreadsheet.Document.ChartDataPoint() = New Vintasoft.Imaging.Office.Spreadsheet.Document.ChartDataPoint(seriesEditor.Series.DataPoints.Length - 1) {}

        For i As Integer = 0 To dataPoints.Length - 1
            ' get data point from chart
            Dim dataPoint As Vintasoft.Imaging.Office.Spreadsheet.Document.ChartDataPoint = seriesEditor.Series.DataPoints(i)
            Dim marker As Vintasoft.Imaging.Office.Spreadsheet.Document.ChartMarker = Nothing

            ' if data point has marker
            If dataPoint.Marker IsNot Nothing Then
                Dim dataPointMarkerAppearance As New Vintasoft.Imaging.Office.Spreadsheet.Document.ShapeAppearance(Vintasoft.Primitives.VintasoftColor.Red, Vintasoft.Primitives.VintasoftColor.Blue, 3)

                ' create new marker for new data point
                marker = New Vintasoft.Imaging.Office.Spreadsheet.Document.ChartMarker(dataPoint.Marker.Style, dataPoint.Marker.Size, dataPointMarkerAppearance)
            End If

            Dim dataPointAppearance As New Vintasoft.Imaging.Office.Spreadsheet.Document.ShapeAppearance(Vintasoft.Primitives.VintasoftColor.Black, Vintasoft.Primitives.VintasoftColor.Green, 3)

            ' change the color of new data point
            dataPoints(i) = New Vintasoft.Imaging.Office.Spreadsheet.Document.ChartDataPoint(marker, dataPointAppearance)
        Next

        ' set new data points for chart
        seriesEditor.SetDataPoints(dataPoints)
    Finally
        spreadsheetVisualEditor.Editor.FinishEditing()
    End Try
End Sub


Изменение размера диаграммы рабочего листа XLSX

Если вы хотите изменить размер диаграммы рабочего листа XLSX с помощью мыши, вам следует выполнить следующие шаги:

Перемещение диаграммы рабочего листа XLSX

Если вы хотите переместить (изменить положение) диаграмму рабочего листа XLSX с помощью мыши, вам следует выполнить следующие шаги:

Удаление диаграммы из листа XLSX

Вот C#/VB.NET код, который демонстрирует, как удалить диаграмму из листа XLSX:
/// <summary>
/// Removes the focused chart from worksheet.
/// </summary>
/// <param name="editorControl">The spreadsheet editor control.</param>
public void RemoveFocusedChartFromXlsxWorksheet(Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl)
{
    // remove focused drawing (picture, chart, graphics)
    editorControl.VisualEditor.RemoveFocusedDrawing();
}
''' <summary>
''' Removes the focused chart from worksheet.
''' </summary>
''' <param name="editorControl">The spreadsheet editor control.</param>
Public Sub RemoveFocusedChartFromXlsxWorksheet(editorControl As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl)
    ' remove focused drawing (picture, chart, graphics)
    editorControl.VisualEditor.RemoveFocusedDrawing()
End Sub