• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6767
  • Last Modified:

Reading Excel in VB.NET

how to import data from Excel in VB.NET?
0
rmkandan
Asked:
rmkandan
  • 2
  • 2
  • 2
  • +1
1 Solution
 
DabasCommented:
Hi rmkandan:
In solution explorer, right click on your solution, Add Reference... COM, Microsoft Excel Object Library, Select, OK

Dabas
0
 
rmkandanAuthor Commented:
Dabas,
thanks, may i know what is the method to read the data from Excel Object Library?
0
 
DabasCommented:
rmkandan:
It depends what you want to do!

Here is an example

http:Q_20984271.html "Create Excel Spreadsheet from VB.Net"


Dabas
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
rmkandanAuthor Commented:
i know how to create excel from VB.Net. But,i need to show the data from Excel to VB.Net
That is i need to retrieve data from a Excel SpeardSheet as Datasource and show the data
0
 
pratap_rCommented:
create an ADO connection to the excel sheet, you can use it as you would a sql connection

heres the sample code, i am using oledb connection, so please import System.Data.OleDb in your code

        Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\query_Excel.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1""")
        con.Open()
        Dim sq As New OleDbDataAdapter("select * from [query_Excel$]", con)
        Dim ds As New DataSet
        sq.Fill(ds)
        DataGrid1.DataSource = ds

enjoy!
pratap
0
 
pratap_rCommented:
Dabas answered the question, and I clarified his point in my post. I guess the points should go to Dabas

Have Fun!
Pratap
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now