writing excel cell values to generic list using c#
-
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
RamyaNaidu
-
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
RamyaNaidu
ramyanaidu wrote:
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
Yep, we may be able to. But we need a clue - like what is in each of these cells. What parameter types SKETCH is expecting. Try expanding your code to
string cell3 = SketchWorkSheet.Cells[i, 3].ToString();
string cell4 = SketchWorkSheet.Cells[i, 4].ToString();Then pass
cell3
andcell4
etc as parameters to the main call. Your debugger, and as a result, you, will have far more chance of seeing what is going on. The problem, at a guess is with the conversion to doubleConvert.ToDouble(SketchWorkSheet.Cells[i,9]));
Convert Cells[i,9] to a string, look at the value in a debugger and I imagine you will see the problem.Small angry dogs
modified on Monday, December 17, 2007 6:28:14 AM