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

Data Type of Cell

I am reading in a spreadsheet and calling the method IWorksheet.GetText( row, col ); When it encounters a cell containing only numeric data it returns a null. If I call IWorksheet.GetNumber( row, col ) instead against that same row and col, it returns the value as a double which makes sense.

However if I call the method GetValueRowCol( row, col ), it returns and C# Object and its type is string, with a value of "11"


I have 2 questions:

Is it possible to get the values inside of a cell always as a string ?

Why does GetValueRowCol( row, col ) return an object with a type of string when it is a number, but GetText( row, col ) returns a null ?



Thanks.



1 Reply

AV Abirami Varadharajan Syncfusion Team July 17, 2017 12:36 PM UTC

Hi John, 
 
Please find the details for your queries below. 
 
Queries 
Details 
Is it possible to get the values inside of a cell always as a string ? 
Yes, we request you to make use of DisplayText property of IRange to return cell value in string always. 
 
Kindly refer below code to retrieve the displaytext of the cell. 
string displayText = worksheet.Range["A2"].DisplayText; 
 
Kindly refer below documentation to know more about displaytext property. 
 
 
Why does GetValueRowCol( row, col ) return an object with a type of string when it is a number, but GetText( row, col ) returns a null ? 
 
GetValueRowCol property should return object with type as string. This is the behavior. We request you to make use of Value2 property of IRange to return proper type of the cell. 
 
Kindly refer below documentation to know more about Value2 property 
 
 
 
Regards, 
Abirami. 


Loader.
Live Chat Icon For mobile
Up arrow icon