Using VB.net to get Excel Cell Value which is not the correct value?
I've been stuck on this for the past few hours so I really could do with
some help. I am trying to get numeric (integer and decimal) values from an
Excel spreadsheet and use it create a graph on my form using the chart
control or even display that value in a textbox.
The Value of cell A11 is "2003" and K11 is "12.00" but the returned values
are 0 and 12. I use formulas to calculate the rest of the y values. The
strange thing is that text works fine. Cell A3 has "initial" which comes
back as "initial", it's just the numbers which don't work.
xlApp = New Excel.Application
xlWorkBook = xlApp.Workbooks.Open("C:\File.xls")
xlWorkBook = xlApp.Workbooks.Add("C:\File.xls")
xlSheet = xlWorkBook.Worksheets(1)
Dim x1 As String
Dim y1 As String
x1 = xlSheet.Range("A11").Value.ToString
y1 = xlSheet.Range("K11").Value.ToString
MsgBox(x1)
Thanks in advance
No comments:
Post a Comment