Click here to Skip to main content
15,900,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can some one help me in finding out the coding for getting data from an excel sheet using VB.Net coding.
Posted
Updated 25-Jul-10 22:47pm
v2
Comments
Dalek Dave 26-Jul-10 4:47am    
Edited for Readability
Dalek Dave 26-Jul-10 5:21am    
You have voted me a one because the answer is simple?

How very odd!

You can read it directly via Application.Excel or by OLEDB, which would you prefer?

This may help[^]


It is very easy to do and a simple googling will answer your question.

Basically you use the interop to open a link to the excel app.
Then point to a cell or range you want to read and then copy (should that be what you want to do).
 
Share this answer
 
Comments
jemimadas 26-Jul-10 4:57am    
Reason for my vote of 1
i don't expect such a simple method
You need to add a reference to Microsoft.Office.Interop.Excel.

Dim oXL As Microsoft.Office.Interop.Excel.Application
Dim oBook As Microsoft.Office.Interop.Excel.Workbook
Dim oSheet As Microsoft.Office.Interop.Excel.Worksheet
Dim vValue As Object

oXL = New Microsoft.Office.Interop.Excel.Application
oBook = oXL.Workbooks.Open("c:\myFile.xls")
oSheet = oBook.Worksheets("Sheet1")
'Here you have cell value, just build a loop to get the data you want
vValue =oSheet.Cells(1, 1).Value 

myTextBox.Text = vValue
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900