We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How to get cell value object

How do I get the cell value as an object? I.e. something like this:

object valueObject = range.ValueObject;

So if the cell contains a string, valueObject will be of type string, if it is a number, it will be of type double etc.

My end goal is getting the value object, and using that as a key for a Dictionary<object, IRange>. In this lookup table the number 2 is not considered the same as string "2".

Also is there a way to query the cell value type, rather than checking all the HasDateTime properties etc?

Best regards,

- Wout



1 Reply

SR Sridhar Syncfusion Team January 19, 2012 12:50 PM UTC

Hi Wout,

Thank you for using Syncfusion products.

1.Please use the Value2 property available with XlsIO to get the cell value as object. We have given below the code snippet for the same.

Code Snippet [C#] :

object value = worksheet.Range["A1"].Value2;

2.In the Dictionary the Number 2 and the string “2” values are considered differently.

3.We do not have the property to query the cell value type. Please use the object.GetType() property to get the type of the object.

Please let us know if you require any further clarifications.

Thanks,
Sridhar.S




Loader.
Live Chat Icon For mobile
Up arrow icon