I am relatively new to using Aspose Words, but it seems there must be a better way to do this.
I’m trying to test for various properties on CellFormat. It seems that there is no good way to test if these are null without deliberately raising an exception.
This code throws a NullReferenceException
if (cell.CellFormat.Shading.BackgroundPatternColor != null )
I have worked around this type of problem in what I think is a bad and inefficient way such as
private bool IsBorderVisible(Border border)
{
bool visible = false;
try
{
visible = border.IsVisible;
}
catch
{
visible = false;
}
return visible;
}
Additionally, other than testing each property for null, is there a way to see if the CellFormat has any properties with values? If I could do a simple test to see if the CellFormat was not using any properties, that would be ideal.
Thanks.