We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Missing chart title for some charts

We have the following spreadsheet file: Charts.zip (621.2 KB)
And the following code:

var workbook = new Workbook("Charts.xlsx");

var chart1 = workbook.Worksheets["Chart1"].Charts[0];
var title1 = chart1.Title.Text;
// actual: null
// expected: Amount sold

var chart2 = workbook.Worksheets["Sheet1"].Charts[0];
var title2 = chart2.Title.Text;
// actual: null
// expected: Amount sold

var chart3 = workbook.Worksheets["Sheet2"].Charts[0];
var title3 = chart3.Title.Text;
// actual: null
// expected: Commission

var chart4 = workbook.Worksheets["Sheet5"].Charts[0];
var title4 = chart4.Title.Text;
// actual: null
// expected: Total

In Aspose.Cells v20.6.0 the chart title of four charts is incorrect. In Excel the chart title is visible, but in the code the property is missing.

Note that all these titles have the property IsAutoText ‘true’. I noticed that the chart title is correctly rendered by Aspose if an image is generated.

@infotron,

We were able to reproduce the issue as you mentioned by using your sample code with your template file. We found chart titles are returned as null for some charts in the workbook. We have logged a ticket with an id “CELLSNET-47413” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.

@infotron,

If the Title.IsAutoText is true, please use chart1.NSeries[0].Name
Console.WriteLine(chart1.Title.IsAutoText ? chart1.NSeries[0].Name : chart1.Title.Text);

Let us know your feedback.

That’s right. With some extra checks the correct title can be obtained:

private static string GetChartTitle(Aspose.Cells.Charts.Chart chart)
{
    if (!chart.Title.IsVisible)
    {
        return null;
    }
    return chart.Title.IsAutoText ? chart.NSeries[0].DisplayName : chart.Title.Text;
}

Thank you for your feedback. This issue is fixed.

@infotron,

Good to know that your issue is sorted out by the suggested code segment. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

@infotron,

Please try our latest version/fix: Aspose.Cells for .NET v20.6.1:
Aspose.Cells20.6.1 For .Net2_AuthenticodeSigned.Zip (5.4 MB)
Aspose.Cells20.6.1 For .Net4.0.Zip (5.4 MB)

Your issue should be fixed in it.

Let us know your feedback.

The issues you have found earlier (filed as CELLSNET-47413) have been fixed in Aspose.Cells for .NET v20.7. This message was posted using Bugs notification tool by ahsaniqbalsidiqui