访问EXCEL为什么不成功呢?
我在一本书上看到了一个关于直接访问EXCEL的实例
代码是这样的:
<form action="" method="post" name="form1">
<table width="400" height="276" border="0" align="center" background="add_manager.gif">
<tr>
<td width="123" height="83"> </td>
<td width="267" height="83"> </td>
</tr>
<tr>
<td height="42" align="right">请填写显示的列数:</td>
<td width="267" height="42"><input type="text" name="cln"></td>
</tr>
<tr>
<td align="right">Excel路径:</td>
<td><input name="asf" type="file" id="asf"></td>
</tr>
<tr>
<td> </td>
<td><input type="button" name="Submit" value="查看" onClick="sd()"></td>
</tr>
</table>
</form>
<script language="vbscript">
sub sd()
set xlap=CreateObject("Excel.Application")
strsource=document.all.form1.asf.value
cln=document.all.form1.cln.value
set xlbook=xlap.Workbooks.open(strsource)
set xlsheet=xlbook.worksheets(1)
i=1
document.Write("<table border='0' align='center' cellspacing='1' bgcolor='#000000' width='400'>")
while xlsheet.cells(i,1)<>""
document.Write("<tr bgcolor='#FFFFFF'>")
for j=1 to cln
document.Write("<td>"&xlsheet.cells(i,j)&"</td>")
next
document.Write("</tr>")
i=i+1
wend
document.Write("</table>")
set xlsheet=nothing
set xlbook=nothing
xlap.quit
end sub
</script>
代码应该没问题,因为这本书是比较好的一本书
但是我运行时,当输好信息后总是提示:
错误:ActiveX部件 不能创建对象:Excel.Application
难道还要装什么组件才能运行,遇到过这种问题的前辈请指点迷津啊,
在线等~~多谢指点。。。。