Sketchs.Add(new SKETCH(SketchWorkSheet.Cells[i, 3].ToString(),
SketchWorkSheet.Cells[i, 4].ToString(),
SketchWorkSheet.Cells[i, 5].ToString(),
SketchWorkSheet.Cells[i, 6].ToString(),
SketchWorkSheet.Cells[i, 7].ToString(),
SketchWorkSheet.Cells[i, 8].ToString(), Convert.ToDouble(SketchWorkSheet.Cells[i,9])));
when i run this i get an error as
Input string was not in a correct format
Can any one help me in this
AlanPosted Dec 19, 2007, 11:18 AM
double.TryParse() will return false if what's in the Excel cell cannot be parsed as a floating point number but, in this event, the variable 'd' will be zero i.e. an exception will not be thrown.
Are you saying that a value of zero is not acceptable as the last parameter of the SKETCH constructor? If so, is there some default value that could be used instead?
ramya naiduPosted Dec 18, 2007, 12:54 AM
Hai its not taking any value and its showing false value i need to write data from excel cells to generic list using c#
I have made the attempt to do that but iam not able to read the values plz help me in this
ramya naiduPosted Dec 17, 2007, 11:08 PM
Thanks for u help i will try it
AlanPosted Dec 17, 2007, 12:52 PM
Given that particular error meesage, I'm fairly sure that this expression is the problem:
Convert.ToDouble(SketchWorkSheet.Cells[i,9])
The most likely explanation is that Cells[i,9] is either empty or contains nothing but spaces which would cause Convert.ToDouble to fail.
If that's the case and you'd be happy to pass zero in that situation, you could use:
double d;
double.TryParse(SketchWorkSheet.Cells[i,9], out d);
and then pass 'd' as the final parameter to the SKETCH constructor.