Documents for Excel, .NET Edition Documentation
Features / Chart / Configure Chart / Chart Title
In This Topic
    Chart Title
    In This Topic

    In GcExcel .NET, you can use the properties of the IChart Interface to set up the chart title as per your choice. When working with chart title, you can perform the following tasks:

    Set formula for chart title

    Refer to the following example code to set formula for chart title.

    C#
    Copy Code
    //Set formula for chart title.
    shape.Chart.HasTitle = true;
    shape.Chart.ChartTitle.Formula = "=Sheet1!$E$1";
    worksheet.Range["E1"].Value = "Sample Chart";

    Set format for chart title and font style

    Refer to the following example code to set format for chart title and font style.

    C#
    Copy Code
    //Set chart title's format and font style.
    shape.Chart.HasTitle = true;
    //shape.Chart.ChartTitle.Text = "aaaaa";
    shape.Chart.ChartTitle.Font.Bold = true;
    shape.Chart.ChartTitle.Format.Fill.Color.RGB = Color.Red;
    shape.Chart.ChartTitle.Format.Line.Color.RGB = Color.Blue;

    Set text angle for chart title

    You can also configure the text angle for chart title by using the Orientation property of IChartTitle interface. The text angle can also be exported or imported to JSON.

    Refer to the following example code to set text angle for chart title.

    C#
    Copy Code
    //add chart title
    shape.Chart.HasTitle = true;
    shape.Chart.ChartTitle.Text = "MyChartTitle";
    
    //config chart title angle
    shape.Chart.ChartTitle.Orientation = 30;