How do you parse huge multicolumn excel sheet into VB & refer to each cell? - TechRepublic
General discussion
June 5, 2008 at 01:21 PM
piyushfloydian

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

by piyushfloydian . Updated 18 years, 1 month ago

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

This discussion is locked

All Comments