EBDN - Community - Question & Answers

  Thursday, 19 November 2020
  1 Replies
  689 Visits
0
Votes
Undo
Hi,
I am retrieving results from worksheet via WorksheetRow object. Iam getting values for particular columns via WorksheetRow.GetValue<T>(col) method for each particular column of worksheet, I don't find any way how to check that the value of that particular really exists before retrieve its value with GetValue(col) method.

If I try to Call GetValue for column where no value exists ReferenceNull exception is thrown.

I managed to establish workaroud with catching this exception, but I want to avoid exception throwing so, that I don't call GetValue if I know that value is not present.

I know how to check presence of particular attribute via Attributes property of underlaying WorksheetRow.ObjectItem object, but I don't want to retrieve call WorksheetRow.ObjectItem if not necessary (due to speed) if I necessary attributes are already loaded in Worksheet.columns.

In short: How to avoid throwing Exception in call of GetValue<bool>(column) in code below (There is NO option that value of attribute in column "column" always exists).

case AttributeType.Boolean:
return context.contextRow.GetValue<bool>(column);