Discussion Locked

How do you parse huge multicolumn excel sheet into VB & refer to each cell?

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am trying to parse a huge excel spread sheet into my VB code for a GUI and refer to its elements (cells) for carrying out the computations. Can anybody suggets an easy and fast way to do it?

Below is what I have developed till now:

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

End Sub

Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

End Sub

Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click

End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

End Sub

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

End Sub

Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Handles Button1.Click
Dim data As New Matrix
Dim code As String
Dim linevoltage As Double
Dim phasecurrent As Double

'Dim Leads As Integer

Dim cn As System.Data.OleDb.OleDbConnection
Dim cmd As System.Data.OleDb.OleDbDataAdapter
Dim ds As New System.Data.DataSet()
cn = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;" & _
"data source=D:\myData.XLS;Extended Properties=Excel 8.0;")

cmd = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", cn)

linevoltage = Convert.ToDouble(TextBox2.Text)
phasecurrent = Convert.ToDouble(TextBox3.Text)

If phasecurrent <= 300 Then
MessageBox.Show("The lead requirements are: " & 1)
ElseIf phasecurrent <= 600 Then
MessageBox.Show("The lead requirements are: " & 2)
ElseIf phasecurrent <= 900 Then
MessageBox.Show("The lead requirements are: " & 3)
ElseIf phasecurrent <= 1200 Then
MessageBox.Show("The lead requirements are: " & 4)
ElseIf phasecurrent <= 1500 Then
MessageBox.Show("The lead requirements are: " & 5)
Else
MessageBox.Show("The lead requirements are: " & 0)

End If
'select phasecurrent from [Sheet1$A1:B7]
cn.Open()
End Sub
End Class

4 replies

by tony hopkinson

the spreadsheet in an OLE container and put the calcs in Excel.

Just wondering, you seem to have gone for the collect lock of baby's hair with axe weilding maniac solution.

by piyushfloydian

I have just started using VB this week and I do not have much experienc with programming other than MATLAB and C. If you could explicitily tell me what should I do and how that would be vey helpful.

by tony hopkinson

years plus, so I'm afraid I can't give you the exact steps.

What you really need is Jck and Tony's best pal. Google.

Learning to ask the right question is skill you'll develop as you go along

vb.net datagrid excel import, got me close.

You need to go and buy a vb.net book and get an idea of what's in there, or you'll be re-inventing wheels and never making a car.

by jck

if they knew anything, they'd know where the example source code sits on the internet 24/7

shhhhhh...let them learn to Google lol

This discussion is closed to new replies.