I want to get the value of a cell from an excel file with a software in C#; NOT THE TEXT, because the text depend of the size of the column, and I must not change it myself, the software should not be disturbed by that. So my choice was to get the value.
I get my cell as a range of 1:1, so I have a Range object, but Value field and Value2 field are not recognized by the language. I tried with get_Value() but it needs a parameter and I don't know what to put in it, i didn't find documentations about it. Here's my code (extracted from a loop):
if((string)(ws_Varsheet.get_Range("L" + iIndex, "L" + iIndex).Text) != "")
{
rng_ResolutionCell = ws_Varsheet.get_Range("L" + iIndex, "L" + iIndex);
float iResolution;
rng_ResolutionCell.Cells.get_Value(&iResolution); //what to do here?
str_Resolution = ((string)iResolution.toString()).Replace(",",".");
str_Resolution = str_Resolution.Replace(" ","");
mObj.Str_Resolution="1";
}
Can you help me with that? Thanks by advance.
I have often found codes a little more complex than needed all over. Basically reading a cell is as simple as:
Xl.Range rng = sheet.Cells[row, column] as Xl.Range;
return rng.Value2;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With