This project has moved. For the latest updates, please go here.

How to read a numeric cell value from excel

May 4, 2012 at 1:00 PM

I would like to read the numeric cell value.Here is what happening:

I am trying to read a value from cell let us suppose 111,111,111 ( rule of excel format it)

but when i am reading this reading like this 111111111. should I have to format data again after reading the cell value?

please suggest.

May 4, 2012 at 2:16 PM

Okay i got it , I was using WorkSheet.Cells[excelProps.CellStartCounter, 3].Value  instead of Text property.. 

But what is the difference b/w two of them and what is Value2 used for?

If I can get a documentation it will helpful.

 

Thanks in advance

Coordinator
May 4, 2012 at 3:13 PM

From the Microsoft Documentation: http://msdn.microsoft.com/en-us/library/ff193553.aspx <<< click it.

"The only difference between this property and the Value property is that the Value2 property doesn’t use the Currency and Date data types. You can return values formatted with these data types as floating-point numbers by using the Double data type."
Another trick is to use string arrays with range.Value2.
 
Sebastian

May 4, 2012 at 4:48 PM

Thanks for a quick reply...

Actually my question was "what is the difference b/w the Text and value property?"

sorry I was not specific enough ...

Thanks a lot 

Coordinator
May 4, 2012 at 5:13 PM

text is what you see in a specific cell, value is the true value behind. as example:

float f = 3.14159
range.Value = f;
range.NumberFormat = "#.#";

range.Value is now: 3.14159 and the shown text(range.Text) in the cell is 3.1 because the NumberFormat change the presentation of the value.
this is very typical for reports with formulas and calculations. you can calculate with exact values(formulas for example) and the user see friendly values.

Sebastian

May 4, 2012 at 5:15 PM

thank that is what I was looking for...

very helpful...