Compartir a través de


Chart.ChartStyle (Propiedad)

Obtiene o establece el estilo del gráfico.

Espacio de nombres:  Microsoft.Office.Tools.Excel
Ensamblado:  Microsoft.Office.Tools.Excel (en Microsoft.Office.Tools.Excel.dll)

Sintaxis

'Declaración
Property ChartStyle As Object
Object ChartStyle { get; set; }

Valor de propiedad

Tipo: System.Object
Entero del 1 al 48 que representa el estilo del gráfico.

Comentarios

Los valores de la propiedad ChartStyle corresponden a las opciones disponibles en el grupo Estilos de diseño de la ficha Diseño de la cinta de opciones.La ficha Diseño está disponible cuando se selecciona un gráfico.

Ejemplos

En el ejemplo de código siguiente se agrega un gráfico 3D de columnas agrupadas a Sheet1 y establece el estilo en el estilo 4.A continuación, en el ejemplo se crea un intervalo de datos arbitrarios y lo establece como los datos de origen del gráfico.Luego, el código especifica los colores de los planos laterales y del plano inferior.

Private Sub SetChartBackWalls()
    ' Add a new chart and populate source data
    Dim myNewChart As Microsoft.Office.Tools.Excel.Chart = _
    Globals.Sheet1.Controls.AddChart( _
        Globals.Sheet1.Range("D5", "J16"), "myNewChart")
    myNewChart.ChartType = Excel.XlChartType.xl3DColumnClustered
    ' Set chart style
    myNewChart.ChartStyle = 4

    Globals.Sheet1.Range("A1").Value2 = "Product"
    Globals.Sheet1.Range("B1").Value2 = "Units Sold"
    Dim i As Integer
    For i = 1 To 3
        Globals.Sheet1.Range("A" + (i + 1).ToString()).Value2 = _
            "Product" + i.ToString()
        Globals.Sheet1.Range("B" + (i + 1).ToString()).Value2 = i * 10
    Next
    Dim data As Excel.Range = Globals.Sheet1.Range("A1", "B4")
    myNewChart.SetSourceData(data)

    ' Set foreground color for 3D chart walls and floor
    myNewChart.BackWall.Format.Fill.ForeColor.RGB = _
        System.Drawing.Color.LightGray.ToArgb()
    myNewChart.SideWall.Format.Fill.ForeColor.RGB = _
        System.Drawing.Color.LightGray.ToArgb()
    myNewChart.Floor.Format.Fill.ForeColor.RGB = _
        System.Drawing.Color.Gray.ToArgb()
End Sub
private void SetChartBackWalls()
{
    // Add a new chart and populate source data
    Microsoft.Office.Tools.Excel.Chart myNewChart =
    Globals.Sheet1.Controls.AddChart(
        Globals.Sheet1.Range["D5", "J16"], "myNewChart");
    myNewChart.ChartType = Excel.XlChartType.xl3DColumnClustered;
    // Set chart style
    myNewChart.ChartStyle = 4;

    Globals.Sheet1.Range["A1"].Value2 = "Product";
    Globals.Sheet1.Range["B1"].Value2 = "Units Sold";

    for (int i=1; i<4; i++)
    {
        Globals.Sheet1.Range["A" + (i + 1).ToString()].Value2 =
            "Product" + i.ToString();
        Globals.Sheet1.Range["B" + (i + 1).ToString()].Value2 = 
            i * 10;
    }
    Excel.Range data = Globals.Sheet1.Range["A1", "B4"];
    myNewChart.SetSourceData(data);

    // Set foreground color for 3D chart walls and floor
    myNewChart.BackWall.Format.Fill.ForeColor.RGB =
        System.Drawing.Color.LightGray.ToArgb();
    myNewChart.SideWall.Format.Fill.ForeColor.RGB =
        System.Drawing.Color.LightGray.ToArgb();
    myNewChart.Floor.Format.Fill.ForeColor.RGB = 
        System.Drawing.Color.Gray.ToArgb();        
}

Seguridad de .NET Framework

Vea también

Referencia

Chart Interfaz

Microsoft.Office.Tools.Excel (Espacio de nombres)