MSDOTnet.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Connecting to an Excel File

 
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> ODBC Dotnet
Author Message
Frans Vander Meiren



Joined: 08 Aug 2007
Posts: 2

PostPosted: Wed Jun 23, 2004 5:02 pm    Post subject: Connecting to an Excel File Reply with quote

Hi

Anyone who can explain me how to load and edit an Excel-file in a DataGrid via an odbcConnection?
Thanks

Frans Vander Meiren

Archived from group: microsoft>public>dotnet>framework>odbcnet
Back to top
View user's profile Send private message
Paul Clement



Joined: 08 Aug 2007
Posts: 154

PostPosted: Thu Jun 24, 2004 1:11 pm    Post subject: Re: Connecting to an Excel File Reply with quote

On Wed, 23 Jun 2004 13:02:01 -0700, "Frans Vander Meiren" email_removed wrote:

¤ Hi
¤
¤ Anyone who can explain me how to load and edit an Excel-file in a DataGrid via an odbcConnection?
¤ Thanks

The following should get you started:

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\Book20.xls;Extended Properties=""Excel 8.0;HDR=NO"""

Dim ExcelConnection As New System.Data.OleDb.OleDbConnection(ConnectionString)
ExcelConnection.Open()

Dim da As New System.Data.OleDb.OleDbDataAdapter("Select * from [Sheet8$]", ExcelConnection)

Dim ds As New DataSet("Workbooks")

da.Fill(ds, "Sheet8")

DataGrid1.SetDataBinding(ds, "Sheet8")


Paul ~~~ pclement@ameritech.net
Microsoft MVP (Visual Basic)
Back to top
View user's profile Send private message
Frans Vander Meiren



Joined: 08 Aug 2007
Posts: 1

PostPosted: Thu Jun 24, 2004 3:11 pm    Post subject: Re: Connecting to an Excel File Reply with quote

Thanks a lot, Paul. I'll try it

Frans

"Paul Clement" wrote:

> On Wed, 23 Jun 2004 13:02:01 -0700, "Frans Vander Meiren" > email_removed wrote:
>
> ¤ Hi
> ¤
> ¤ Anyone who can explain me how to load and edit an Excel-file in a DataGrid via an odbcConnection?
> ¤ Thanks
>
> The following should get you started:
>
> ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
> "Data Source=e:\My Documents\Book20.xls;Extended Properties=""Excel 8.0;HDR=NO"""
>
> Dim ExcelConnection As New System.Data.OleDb.OleDbConnection(ConnectionString)
> ExcelConnection.Open()
>
> Dim da As New System.Data.OleDb.OleDbDataAdapter("Select * from [Sheet8$]", ExcelConnection)
>
> Dim ds As New DataSet("Workbooks")
>
> da.Fill(ds, "Sheet8")
>
> DataGrid1.SetDataBinding(ds, "Sheet8")
>
>
> Paul ~~~ pclement@ameritech.net
> Microsoft MVP (Visual Basic)
>
Back to top
View user's profile Send private message
SN



Joined: 08 Jan 2008
Posts: 1

PostPosted: Tue Jan 08, 2008 4:23 am    Post subject: Re: Connecting to an Excel File Reply with quote

Hi All,

I could achieve the same thing using below help.
Now, facing another problem like the excel data with numeric or datetime
data comes in datagrid along with the same formatting applied.
So the header for numeric columns(e.g. Price/Quantity) does not show in grid.
Can anyone suggest any soln on this?

Thanks in advance.


"Frans Vander Meiren" wrote:

> Thanks a lot, Paul. I'll try it
>
> Frans
>
> "Paul Clement" wrote:
>
> > On Wed, 23 Jun 2004 13:02:01 -0700, "Frans Vander Meiren" > > email_removed wrote:
> >
> > ¤ Hi
> > ¤
> > ¤ Anyone who can explain me how to load and edit an Excel-file in a DataGrid via an odbcConnection?
> > ¤ Thanks
> >
> > The following should get you started:
> >
> > ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
> > "Data Source=e:\My Documents\Book20.xls;Extended Properties=""Excel 8.0;HDR=NO"""
> >
> > Dim ExcelConnection As New System.Data.OleDb.OleDbConnection(ConnectionString)
> > ExcelConnection.Open()
> >
> > Dim da As New System.Data.OleDb.OleDbDataAdapter("Select * from [Sheet8$]", ExcelConnection)
> >
> > Dim ds As New DataSet("Workbooks")
> >
> > da.Fill(ds, "Sheet8")
> >
> > DataGrid1.SetDataBinding(ds, "Sheet8")
> >
> >
> > Paul ~~~ pclement@ameritech.net
> > Microsoft MVP (Visual Basic)
> >

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Connecting to an Excel file Hi I'm an newbie on .NET so I hope my question is not disturbing you. I want to write an application to load and edit an Excel-file in a DataGrid. Can you present or guide me to some example code? Thanks a lot Frans Vander Meiren

E_UNEXPECTED trying to open Excel file with ASP .NET Hi, I have an ASP .NET application that successfully opens and reads an Excel file on when running on 3 servers. on a 4th server (the production server) it fails: (0x8000ffff): No error information available:

problems connecting to Oracle DB Hello, I have this problems. I wrote a asp.net application and I tested on my pc (windows 2000, IIS 5.0) and everything works. I tried to move the application on my server, but when I try to run it, at the first attempt to connect to my Oracle Database (O

ODBC.NET ERROR WHEN CONNECTING TO DB2 mainframe udb I am using ODBC.Net to connect to DB2 and I get this error randomly. "ERROR [08001] [IBM][CLI Driver] SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location whe

Lising all the Excel Sheets Hi All Using a SELECT Statement How do you list all the sheets from an xls file ? Because "Select * from MySheet$" does n't work. Here "MySheet" is the xls file name. Thanks in Advance Sethu
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> ODBC Dotnet All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group