Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

importing excel

0 views
Skip to first unread message

Rob T

unread,
May 10, 2005, 8:54:35 AM5/10/05
to
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.


Cor Ligthert

unread,
May 10, 2005, 9:09:33 AM5/10/05
to
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


Rob T

unread,
May 10, 2005, 9:34:11 AM5/10/05
to
Thanks Cor, you're right, it does look easy. I'll try it out. Thanks.

"Cor Ligthert" <notmyfi...@planet.nl> wrote in message
news:Ox7hKGWV...@TK2MSFTNGP14.phx.gbl...

J L

unread,
May 11, 2005, 1:22:39 AM5/11/05
to
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

Cor Ligthert

unread,
May 11, 2005, 2:36:01 AM5/11/05
to
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


J L

unread,
May 13, 2005, 1:43:11 PM5/13/05
to
Thanks Cor, that is very helpful.

John

0 new messages