Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Excel File From Asp

Reply
Thread Tools

Excel File From Asp

 
 
Stan Sainte-Rose
Guest
Posts: n/a
 
      06-11-2004
Hi
I have to import Excel file from ASP.
I do it well with the following code
Const adUseClient = 3
Const adClipString = 2
Const Repertoire = "w:\wwwroot\look\j_consultation\j06_suivi\modules_ stan\"
Set adoCn = CreateObject("ADODB.Connection")
Set adoRs = CreateObject("ADODB.Recordset")
With adoCn
..Provider = "Microsoft.Jet.OLEDB.4.0"
..ConnectionString = _
"Data Source=" & Repertoire & "Essai.xls;" & _
"Extended Properties=Excel 8.0;"
..CursorLocation = adUseClient
..Open
End With
strQuery = "SELECT * FROM [CONTROLE INTERNE$]"
With adoRs
Set .ActiveConnection = adoCn
..Open strQuery
End With


My question is how to get the Sheet Tab Name.
Right now, with my code I have to write [CONTROLE INTERNE$]
but how to do when you don't know the name ?

Thanks for your help

Stan


 
Reply With Quote
 
 
 
 
Jamie Collins
Guest
Posts: n/a
 
      06-11-2004
"Stan Sainte-Rose" wrote ...

> My question is how to get the Sheet Tab Name.
> Right now, with my code I have to write [CONTROLE INTERNE$]
> but how to do when you don't know the name ?


Use the Connection object's OpenSchema method e.g. (untested):

Const adUseClient = 3
Const adClipString = 2
Const Repertoire = "w:\wwwroot\look\j_consultation\j06_suivi\modules_ stan\"
Const adSchemaTables = 20
Set adoCn = CreateObject("ADODB.Connection")
Set adoRs = CreateObject("ADODB.Recordset")
With adoCn
..Provider = "Microsoft.Jet.OLEDB.4.0"
..ConnectionString = _
"Data Source=" & Repertoire & "Essai.xls;" & _
"Extended Properties=Excel 8.0;"
..CursorLocation = adUseClient
..Open
Set adoRs = .OpenSchema(adSchemaTables)
End With
With adoRs
Do Until .EOF
MsgBox !TABLE_NAME
.MoveNext
Loop
End With

--
 
Reply With Quote
 
 
 
 
Radovan Vojtek
Guest
Posts: n/a
 
      08-04-2004
Hi Jamie!

Are you sure with the exlamation (!) ?

Microsoft VBScript compilation error '800a03ea'
Syntax error
/test.asp, line 19
MsgBox !TABLE_NAME
-------^

I'd like to solve it, but I'm an ASP (and VBScript) newbie

Thanx

--
R.V.


"Jamie Collins" wrote:

> "Stan Sainte-Rose" wrote ...
>
> > My question is how to get the Sheet Tab Name.
> > Right now, with my code I have to write [CONTROLE INTERNE$]
> > but how to do when you don't know the name ?

>
> Use the Connection object's OpenSchema method e.g. (untested):
>
> Const adUseClient = 3
> Const adClipString = 2
> Const Repertoire = "w:\wwwroot\look\j_consultation\j06_suivi\modules_ stan\"
> Const adSchemaTables = 20
> Set adoCn = CreateObject("ADODB.Connection")
> Set adoRs = CreateObject("ADODB.Recordset")
> With adoCn
> ..Provider = "Microsoft.Jet.OLEDB.4.0"
> ..ConnectionString = _
> "Data Source=" & Repertoire & "Essai.xls;" & _
> "Extended Properties=Excel 8.0;"
> ..CursorLocation = adUseClient
> ..Open
> Set adoRs = .OpenSchema(adSchemaTables)
> End With
> With adoRs
> Do Until .EOF
> MsgBox !TABLE_NAME
> .MoveNext
> Loop
> End With
>
> --
>

 
Reply With Quote
 
Jamie Collins
Guest
Posts: n/a
 
      08-05-2004
"Radovan Vojtek" wrote ...

> Hi Jamie!
>
> Are you sure with the exlamation (!) ?
>
> Microsoft VBScript compilation error '800a03ea'
> Syntax error
> /test.asp, line 19
> MsgBox !TABLE_NAME
> -------^


Yes, but only within the With clause i.e. could be rewritten as

MsgBox adoRs!TABLE_NAME

or

MsgBox adoRs.Fields("TABLE_NAME").Value

Jamie.

--
 
Reply With Quote
 
Radovan Vojtek
Guest
Posts: n/a
 
      08-05-2004
Thanx, Jamie, it works!!! godlike

R.V.

"Jamie Collins" wrote:

> "Radovan Vojtek" wrote ...
>
> > Hi Jamie!
> >
> > Are you sure with the exlamation (!) ?
> >
> > Microsoft VBScript compilation error '800a03ea'
> > Syntax error
> > /test.asp, line 19
> > MsgBox !TABLE_NAME
> > -------^

>
> Yes, but only within the With clause i.e. could be rewritten as
>
> MsgBox adoRs!TABLE_NAME
>
> or
>
> MsgBox adoRs.Fields("TABLE_NAME").Value
>
> Jamie.
>
> --
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to return an excel file or excel data from ASP.NET Anonieko ASP .Net 2 02-12-2008 07:03 PM
Problem with Excel reports ::::Excel 2003 Migration To Excel 2007 =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?= ASP .Net 15 10-24-2007 01:34 PM
asp.net extracting excel charts from an Excel file Robbe Morris [C# MVP] ASP .Net 0 12-15-2006 03:03 AM
ExtenXLS loads data into Excel 2002 file but damages the Excel file. kp2900@gmail.com Java 1 11-21-2006 05:48 PM
exporting an excel file from database; making changes to excel file and updating the database by importing it back Luis Esteban Valencia ASP .Net 1 01-12-2005 12:28 AM



Advertisments