Pregunta

I have an excel spreadsheet (2007/2010) from which I have to pick up data "As it is". i.e. Cant change cell format etc. The cell format is general. The spreadsheet contains various formulas which generates numbers with large decimal places.

My code (.net) is picking up these results and doing same calculations as the excel formulas. However when it gets the results, it does not match the result in excel for some decimal places.

My understanding is that the cell value in excel differ from the value "underneath" the cell. So for e.g. if the cell is showing 0.32565 then it might me 0.3265125412112121. Is this correct?

If so how can I read this value in Excel.

To read this value from code I am using OpenXML lib which gets the value in XML format in String which I then convert to the decimal. Is this correct approach?

Thanks,

¿Fue útil?

Solución

Not sure what your asking if the value is the right value then what are you worrying about? the conversion from a string in XML to a number??

Use cell.value, not cell.text.

In fact use cell.value2 if you can.

See more here: http://smurfonspreadsheets.wordpress.com/2007/01/22/the-joy-of-text-long/ and here: http://fastexcel.wordpress.com/2011/11/30/text-vs-value-vs-value2-slow-text-and-how-to-avoid-it/

HTH, not suere it will ;-) Ross

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top