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

Free Support Forum - aspose.com

Null reference exception thrown from Style.SetBorder, when values are not null

Hello,

I have been getting a NullReferenceException object, thrown from a line of code that has no null values in it (please see the screenshots):

style.SetBorder(BorderType.TopBorder, borders[BorderType.TopBorder].LineStyle, borders[BorderType.TopBorder].Color);

I have also uploaded the property inspector for the Style object, as I suspect that something inside it is causing this error. Please check your code and tell me which property is throwing the exception.

Please note that I cannot provide you with a working code example. However, the screenshots should provide enough information for the developers to recreate the issue, or figure out what the problem is.

Capture.zip (67.1 KB)

After further investigation, I have noticed that there is a problem with the Style.ForegroundColor property. After setting it to a valid value, it throws an exception of type NullReferenceException.

I have attached a video that clearly shows this happening.

I believe that this property is the cause of my border setting problem. Please confirm this, and tell me how to set this property without error.

I am using version 18.6.0.0 and cannot easily update. Please don’t offer me your usual solution of updating to the latest assembly version.

Many thanks and kind regards,
Sheridan

@workshare,

Thanks for the screenshots and details.

I am afraid, it would be hard to evaluate your issue based on given screenshots only as we need actual sample/data file (at least) if not the complete sample code to investigate the issue. Moreover, it is also quite possible that there was an issue with the version you are using and has been already addressed in newer versions. In that case, we might not help you much as we cannot add fixes to older versions. We can still check if there can be some workaround to cope with it.

I could not find your attached demo for evaluation, please zip it and provide us.

We will start investigating the issue after we have obtained all the artifacts (sample files, video, data, code segments, etc.) and details from your side.

Your system allows me to upload the video in a .zip folder, but then it removes it for some reason.

@workshare,

May be it is a size issue (the forums allows attachments to be attached not more than 10MB in size). You may upload the the zipped archive to some file sharing service (e.g Dropbox, Google drive, etc.) and share the Download link here, we will check it soon.

I have replaced the video with two screenshots and this code:

Style style = new CellsFactory().CreateStyle();
style.ForegroundColor = Color.Black;

Capture.zip (12.7 KB)

Please note that setting the Pattern property makes no difference to this error.

image.png (6.2 KB)

Please also note that some cells ARE coloured with this color, while others are not. However, this error can be seen EVERY time, even for cells that get successfully coloured.

I have also tried adding this colour to the palette, but it makes no difference to this problem.

@workshare,

Thanks for screenshots and further details.

Although your provided details and screenshots might not be sufficient to reproduce it and to evaluate your issue precisely and thoroughly but we will surely investigate and look into your issue in details. I have logged an investigation ticket with an id “CELLSNET-46660” for your issue. Please spare us little time to analyze your issue on our end.

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

@workshare,

We evaluated your issue in details. We found it was a bug in older version (there is no workaround to cope with it) and we have fixed it in the latest fix/version (attached). I am afraid, you have to upgrade to latest version to avail the fix as we cannot include fixes in older versions.

Please try our latest version/fix: Aspose.Cells for .NET v19.3.2 (attached)
Let us know your feedback.
Aspose.Cells19.3.2 For .Net2.Zip (4.8 MB)
Aspose.Cells19.3.2 For .Net2_AuthenticodeSigned.Zip (4.8 MB)
Aspose.Cells19.3.2 For .Net4.0.Zip (4.9 MB)

The issues you have found earlier (filed as CELLSNET-46660) have been fixed in Aspose.Cells for .NET v19.4. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi