Solved

Reading Excel in VB.NET

Posted on 2004-10-09
10
6,753 Views
Last Modified: 2009-02-06
how to import data from Excel in VB.NET?
0
Comment
Question by:rmkandan
  • 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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
 

Expert Comment

by:aganapathy
ID: 12980804
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

832 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