theoryofben
IS-IT--Management
Hello All,
First off, thanks in advance. I am completely new to .net and I have been given a project at work for our intranet.
I need to import an excel file, do some queries on an SQL database and then output to a new excel file.
I have it all working great, except that my test file had a generic "Sheet1" worksheet name. But the actual files will not. They will be different. But there will only be one worksheet per file.
How do I either get the actual sheet name or is it possible to reference the sheet by number? My code is below.
Dim oleconn as OleDbConnection=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" &_
Server.MapPath("/matchreport/uploaded/SampleBio.xls") & ";" & "Extended Properties=Excel 8.0;")
Dim selectCmd as OleDbCommand = New OleDbCommand("SELECT * FROM [Sheet1$]", oleconn)
Thanks.
Ben
"Insanity in individuals is something rare - but in groups, parties, nations and epochs, it is the rule."
Friedrich Nietzsche
First off, thanks in advance. I am completely new to .net and I have been given a project at work for our intranet.
I need to import an excel file, do some queries on an SQL database and then output to a new excel file.
I have it all working great, except that my test file had a generic "Sheet1" worksheet name. But the actual files will not. They will be different. But there will only be one worksheet per file.
How do I either get the actual sheet name or is it possible to reference the sheet by number? My code is below.
Dim oleconn as OleDbConnection=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" &_
Server.MapPath("/matchreport/uploaded/SampleBio.xls") & ";" & "Extended Properties=Excel 8.0;")
Dim selectCmd as OleDbCommand = New OleDbCommand("SELECT * FROM [Sheet1$]", oleconn)
Thanks.
Ben
"Insanity in individuals is something rare - but in groups, parties, nations and epochs, it is the rule."
Friedrich Nietzsche