Home > ASP Development > getting the cell range name through ASP

getting the cell range name through ASP



Hello all,

I am trying to get the all the cell-range names defined by a User in a EXCEL worksheet.
my ASP program will open an EXCEL file......
and extract all the cell range names from that excel worksheet.
What i have done till now, is that the user has to enter the cellrange name manually in a form , and that form is forwarded to a code. the code is as follows


Code:


   
'Pick the excel file from uploads
'Name of the excel file being displayed
'***************** Files **********************************************
Set fso = CreateObject("Scripting.FileSystemObject") 
Set folderObject = fso.GetFolder(Server.MapPath("..\uploads\pascoreuploads\")) 
Set filesObject = folderObject.Files 
For Each file In filesObject 
exceldb=file.name
Next 
Set fileObject = Nothing 
Set folderObject = Nothing 
Set fso = Nothing 
'=================================================  ====
' Create a server connection object
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open "DBQ=" & Server.MapPath("..\uploads\pascoreuploads\"& exceldb) & ";" & _
"DRIVER={Microsoft Excel Driver (*.xls)};"
' Create a server recordset object
Set rsexc = Server.CreateObject("ADODB.Recordset")
'----------------------------------------------------------------------------------------------
' Query to run against the exceldb
'  is the name of the 
' cell range as defined in excel
cell=Request.Form("cell_name")
sql="select * from "& cell
' Execute the sql
rsexc.Open sql,cn




Please do help
Thanks a lot

    
Guest


hmmm, I think I am right in saying you cannot actually get the info like that based on a cell, you have to format the excel sheet in such a way that the asp can read it like a database,



so you put your field names in the tops of the columns, and then the recordss in the rows undern either, then you have to select all the records and the titles then you click inset > name > define and choose the type in the name.



then if i remeber correctly the sql would be



select * from your_defined_name



then the get the record you want it is the same as using a db.



I hope that helps sorry if it doesn't

Was this answer helpful ? Yes No   
Guest


this is a fairly good but simple example



http://www.asp101.com/samples/xl_data.asp

Was this answer helpful ? Yes No   
Guest


Quote:
Originally Posted by EnenDaveyBoy
hmmm, I think I am right in saying you cannot actually get the info like that based on a cell, you have to format the excel sheet in such a way that the asp can read it like a database,



so you put your field names in the tops of the columns, and then the recordss in the rows undern either, then you have to select all the records and the titles then you click inset > name > define and choose the type in the name.



then if i remeber correctly the sql would be



select * from your_defined_name



then the get the record you want it is the same as using a db.



I hope that helps sorry if it doesn't




thanks for the reply and help....

but what u have mentioned ...i have done this way before nd it works fine...

But what i would love to have is a list of all the user-defined ranges...



For example in a single EXCEL sheet,.... he has defined mutliple cell range names....

and he only wants ASP to read data from all the columns within the cell range, just like u do from an ACCESS table.



So if the user has defined multiple cell range names.....then I am trying to get this list to be displayed...





You know in ACCESS , you have this import external data function

here you are either given the option to select the sheet name or even the cell range name..

here the list of cell range names r displayed....

I'm looking for sumthing like this



Please do help.

Thanks a lot



and

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved