By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,558 Members | 1,675 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,558 IT Pros & Developers. It's quick & easy.

importing excel

P: n/a
I need to write a little utility that can read in an excel file.

Currently I could have the end-user could save the file as a .txt and I
could import that. I would like to avoid this since I would have to rely on
the end-user to export the data properly....and we all know how well that
would work!

Also I could create an odbc connection to the file, but the name of the file
changes each time...again, I have to rely on the intelligence of the
end-user.......

Thanks.

-Rob T.
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Rob,

You can very easy create a dataset from an excel file.

\\\
Dim ConnectionString As String
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\myExcel.xls;" & _
"Extended Properties=""Excel 8.0;HDR=NO"""
Dim Conn As New System.Data.OleDb.OleDbConnection(ConnectionString )
Dim da As New System.Data.OleDb.OleDbDataAdapter _
("Select * from [Sheet1$]", Conn)
Dim ds As New DataSet
da.Fill(ds, "Sheet1")
///

Be aware that Sheet1 can be in any language different.

I hope this helps a little bit?

Cor
Nov 21 '05 #2

P: n/a
Thanks Cor, you're right, it does look easy. I'll try it out. Thanks.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Ox**************@TK2MSFTNGP14.phx.gbl...
Rob,

You can very easy create a dataset from an excel file.

\\\
Dim ConnectionString As String
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\myExcel.xls;" & _
"Extended Properties=""Excel 8.0;HDR=NO"""
Dim Conn As New System.Data.OleDb.OleDbConnection(ConnectionString )
Dim da As New System.Data.OleDb.OleDbDataAdapter _
("Select * from [Sheet1$]", Conn)
Dim ds As New DataSet
da.Fill(ds, "Sheet1")
///

Be aware that Sheet1 can be in any language different.

I hope this helps a little bit?

Cor

Nov 21 '05 #3

P: n/a
J L
Hi Cor,
I have heard others ask about filling a DS from Excel. What does the
table structure look like when that is done? Is each column a field?
and each row a row? Or what?

TIA,
John

On Tue, 10 May 2005 15:09:33 +0200, "Cor Ligthert"
<no************@planet.nl> wrote:
Rob,

You can very easy create a dataset from an excel file.

\\\
Dim ConnectionString As String
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\myExcel.xls;" & _
"Extended Properties=""Excel 8.0;HDR=NO"""
Dim Conn As New System.Data.OleDb.OleDbConnection(ConnectionString )
Dim da As New System.Data.OleDb.OleDbDataAdapter _
("Select * from [Sheet1$]", Conn)
Dim ds As New DataSet
da.Fill(ds, "Sheet1")
///

Be aware that Sheet1 can be in any language different.

I hope this helps a little bit?

Cor


Nov 21 '05 #4

P: n/a
John,
I have heard others ask about filling a DS from Excel. What does the
table structure look like when that is done? Is each column a field?
and each row a row? Or what?


Yes, and there are two option, one is to skip a headerline from Excel and
one is to get all the columns as string "Text"

Cor
Nov 21 '05 #5

P: n/a
J L
Thanks Cor, that is very helpful.

John

On Wed, 11 May 2005 08:36:01 +0200, "Cor Ligthert"
<no************@planet.nl> wrote:
John,
I have heard others ask about filling a DS from Excel. What does the
table structure look like when that is done? Is each column a field?
and each row a row? Or what?


Yes, and there are two option, one is to skip a headerline from Excel and
one is to get all the columns as string "Text"

Cor


Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.