|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Referring to sheets in excel
I'm using ASP/VBScript to look at the contents of an excel file. I know how to refer to a sheet by name:
Code:
set ExcelRS = ExcelConn.Execute ("SELECT * FROM [Sheet1$]")
but how do I refer to the first sheet, second sheet, last sheet, etc. if I don't know the names of the worksheets? |
|
#2
|
|||
|
|||
|
Found another solution - for those interested:
Code:
<%
Dim objInputXLS
Dim ObjInputWorkBook
Dim ObjInputSheet
Dim datStartTime
Dim datEndTime
Set objInputXLS = CreateObject("Excel.Application")
Set ObjInputWorkBook = objInputXLS.Workbooks.Open("c:\inetpub\wwwroot\asp\calendar\test.xls")
Set ObjInputSheet = ObjInputWorkBook.Worksheets(1)
Response.Write(ObjInputSheet.Cells(11,6))
objInputXLS.ActiveWorkbook.Close True, "c:\inetpub\wwwroot\asp\calendar\test.xls"
Set ObjInputSheet = Nothing
Set ObjInputWorkBook = Nothing
Set objInputXLS = Nothing
%>
|
|
#3
|
||||
|
||||
|
Hey to know the sheets name u can use this
excel_app.workbooks.open(xls file name) Set excel_app = CreateObject("Excel.Application") excel_app.Workbooks.Open (excelfile_name) For i = 1 To ActiveWorkbook.Sheets.Count shtname(i) = Sheets(i).Name Exit For Next |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Referring to sheets in excel |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|