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

Free Support Forum - aspose.com

NullReferenceException while setting ThemeColor to null

Hi,

A Font object's ThemeColor can be null, but if you set it to null in code it will throw an exception:

System.NullReferenceException: Object reference not set to an instance of an object. at Aspose.Cells.Font.set_ThemeColor(ThemeColor value)


Here is some sample code:

var workbook = new Workbook();

Worksheet worksheet = workbook.Worksheets[workbook.Worksheets.Add()];

Range range = worksheet.Cells.CreateRange(1, 1, 2, 5);

Chart chart = worksheet.Charts[worksheet.Charts.Add(ChartType.Line, 1, 1, 1, 1)];

Series series = chart.NSeries[chart.NSeries.Add(range.RefersTo, true)];

ThemeColor currentThemeColor = series.DataLabels.Font.ThemeColor; // null

series.DataLabels.Font.ThemeColor = new ThemeColor(ThemeColorType.Accent1, 10); // works

series.DataLabels.Font.ThemeColor = null; // Exception


I am using v.8.3.0.0

Best regards,

Hi,


Well, will evaluate your issue on our end soon.

But, I think if you need to specify null as color, you may change the last line of code to:
e.g
Sample code:

series.DataLabels.Font.Color = Color.Empty;

Color.Empty --> represents a color that is null.

Thank you.

[quote user=“Amjad Sahi”]Hi,


Well, will evaluate your issue on our end soon.

But, I think if you need to specify null as color, you may change the last line of code to:
e.g
Sample code:

series.DataLabels.Font.Color = Color.Empty;

Color.Empty --> represents a color that is null.

Thank you.
[/quote]

Thanks for the quick reply.

However, this is the ThemeColor object, not Color.

Hi John,

Thanks for your posting and using Aspose.Cells.

We were able to observe this issue after executing your sample code with the latest version: Aspose.Cells
for .NET v8.3.0.3
. Setting series.DataLabels.Font.ThemeColor = null generates the exception.

We
have logged this issue in our database for investigation. We will look
into it and fix this issue. Once this issue is resolved or we have some
other update for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-43207 - NullReferenceException while setting ThemeColor to null

Hi John,

Thanks for using Aspose.Cells.

We have fixed
this issue now. We will provide you a fix in couple of days after
incorporating other enhancements and fixes and conducting some extensive
testing. Once, it is available for you, we will let you know asap by
posting in this thread.

Hi,

Thanks for your using Aspose.Cells.

Please download and try the latest fix: Aspose.Cells for .NET v8.3.0.4 and let us know your feedback.

The issues you have found earlier (filed as CELLSNET-43207) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.