通过工作表一个双赢2008服务器使用传统的ASP一个Excel(XLS)文件循环 [英] Looping through worksheets in an Excel (xls) file using classic ASP on a win 2008 server
问题描述
我刚刚迁移旧的ASP解决方案在Windows 2008服务器和一切顺利除了使用ADOX.Catalog列出在上传的XLS文件的所有工作表的罚款。我用下面的code:
I have just migrated an older ASP solution to a windows 2008 server and everything works out fine except for using ADOX.Catalog to list all the worksheets in an uploaded xls file. I use the following code:
<%
设置objExcelCon =的Server.CreateObject(ADODB.Connection)
随着objExcelCon
.Provider =Microsoft.ACE.OLEDB.12.0
.ConnectionString =数据源=&放大器; strFilePath&安培; \\&放大器; strFileName&安培; ;扩展属性= Excel的12.0;
。打开
结束与
<% Set objExcelCon = Server.CreateObject("ADODB.Connection") With objExcelCon .Provider = "Microsoft.ACE.OLEDB.12.0" .ConnectionString = "Data Source=" & strFilePath & "\" & strFileName & ";Extended Properties=Excel 12.0;" .Open End With
设置objAdo =的Server.CreateObject(ADOX.Catalog)
Set objAdo = Server.CreateObject("ADOX.Catalog")
设置ADOX的ActiveConnection
objAdo.activeConnection = objExcelCon
' Set ADOX activeConnection objAdo.activeConnection = objExcelCon
通过表(工作表)循环
对于i = 0到objAdo.Tables.Count - 1
RESPONSE.WRITE objAdo.Tables(I).Name点
下一步
' Loop through tables (worksheets) For i = 0 To objAdo.Tables.Count - 1 response.Write objAdo.Tables(i).Name Next
设置objExcelCon =什么
设置objAdo =什么
%>
Set objExcelCon = Nothing Set objAdo = Nothing %>
当我运行此我没有得到任何错误信息或任何东西。任何人有任何想法,什么原因?
When I run this i get no error message or anything. Anyone got any idea whats causing this?
最好的问候,
罗伊
Best regards, Roy
推荐答案
您确实有
<% Option Explicit %>
在页面顶部的,不是吗?你可以看到你不使用你以前没有使用一个变量?
at the top of your page, no ? Do you can see that you are not using a variable you have not used before ?
另外,写出来的在循环I
价值,所以你看,无论您是循环的东西。
Also, write out the i
value in the loop, so you see whether you are looping something.
这篇关于通过工作表一个双赢2008服务器使用传统的ASP一个Excel(XLS)文件循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!