General discussion

Locked

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

By piyushfloydian ·
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 conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Erm why don't you just show

by Tony Hopkinson In reply to How do you parse huge mul ...

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.

Collapse -

Help

by piyushfloydian In reply to Erm why don't you just sh ...

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.

Collapse -

I don't use vb.net at all. Have not used VB for three

by Tony Hopkinson In reply to Help

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.

Collapse -

someone wants us to do his/her work Tony

by jck In reply to Erm why don't you just sh ...

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

Back to Software Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums