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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Data Type of Cell

Thread ID:

Created:

Updated:

Platform:

Replies:

131546 Jul 16,2017 01:17 PM UTC Jul 17,2017 12:36 PM UTC WinForms 1
loading
Tags: XlsIO
John Cox
Asked On July 16, 2017 01:17 PM UTC

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.



Abirami Varadharajan [Syncfusion]
Replied On 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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;