Solved

Reading Excel in VB.NET

Posted on 2004-10-09
10
6,760 Views
Last Modified: 2009-02-06
how to import data from Excel in VB.NET?
0
Comment
Question by:rmkandan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
10 Comments
 
LVL 27

Accepted Solution

by:
Dabas earned 50 total points
ID: 12268340
Hi rmkandan:
In solution explorer, right click on your solution, Add Reference... COM, Microsoft Excel Object Library, Select, OK

Dabas
0
 

Author Comment

by:rmkandan
ID: 12268351
Dabas,
thanks, may i know what is the method to read the data from Excel Object Library?
0
 
LVL 27

Expert Comment

by:Dabas
ID: 12268363
rmkandan:
It depends what you want to do!

Here is an example

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


Dabas
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rmkandan
ID: 12268595
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
 
LVL 11

Expert Comment

by:pratap_r
ID: 12274524
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
 
LVL 11

Expert Comment

by:pratap_r
ID: 12696168
Dabas answered the question, and I clarified his point in my post. I guess the points should go to Dabas

Have Fun!
Pratap
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
Six Sigma Control Plans
Introduction to Processes

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question