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

Free Support Forum - aspose.com

Get Maximum and Minimum Y Axis Value of Charts in C#


When calculating and trying to get maximum and minimum y axis value of charts in C# code, I found the result returned by Aspose.Cells is inconsistent to what was actually in the MS Excel chart.

Sample Code Get Maximum and Minimum Y Axis Value of Charts in C#

var workbook1 = new Workbook(@".\test.xlsx");
var chart1 = workbook1.Worksheets[0].Charts[0];
Console.WriteLine(chart1.ValueAxis.MaxValue); // write 38, should be 40
Console.WriteLine(chart1.ValueAxis.MinValue); // write 28, should be 20
var workbook2 = new Workbook(@".\test2.xlsx");
var chart2 = workbook2.Worksheets[0].Charts[0];
Console.WriteLine(chart2.ValueAxis.MaxValue); // write 140, should be 150
Console.WriteLine(chart2.ValueAxis.MinValue); // correct as 100

I’ve attached two test examples for your reference. Could you please take a look?
test.zip (59.8 KB)



Thanks for the sample files.

After an initial testing, I am able to reproduce the issue as you mentioned by using your template files. I found I could get maximum and minimum y axis value of charts in C#.NET by using Aspose.Cells APIs but the results are not accurate. I guess this is due to the fact that axis values are “Auto” set, so Aspose.Cells might not determine it fine. Anyways, we need to evaluate the issue thoroughly. I have logged a ticket with an id “CELLSNET-49578” for your issue. We will look into it soon.

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

Hi @Amjad_Sahi

Thanks for the updates. Yes I’m aware that it was possibly due to the ‘Auto’ values. However, Aspose’s auto values are usually correct after running chart.Calculate(), also we will sometimes need to retrieve the values for further manipulation (for example, changing it to manual programmatically).

These operations are possible with MS Excel because it would suggest its calculated auto values in the configuration boxes. We would expect Aspose to do the same.

We are looking forward to your update.



Please spare us little time to evaluate your issue thoroughly. We will try to figure it out (if possible).


Please try our latest version/fix: Aspose.Cells for .NET v21.12.2 (attached)
Aspose.Cells21.12.2 For .Net4.0.Zip
Aspose.Cells21.12.2 For .Net2_AuthenticodeSigned.Zip
Aspose.Cells21.12.2 For .NetStandard20.Zip

The issues you have found earlier (filed as CELLSNET-49578) have been fixed in this update. This message was posted using Bugs notification tool by simon.zhao