当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASP直接调用EXCEL数据的例子(不用ODBC)

ASP
构造ConnectionString的方法
在asp中如何创建动态表--调用如下sp_execute
Jmail中避过smtp验证的一法
取出所有的传递参数短方法
提高ASP性能的最佳选择(二)
提高ASP性能的最佳选择(三)
提高ASP性能的最佳选择(续一)
提高ASP性能的最佳选择(续二)
提高ASP性能的最佳选择(续三)
提高ASP性能的最佳选择(续四)
一种效率极高的分类算法
不刷新页面的情况下调用远程ASP
谈两种数据库内容HTML格式的输出方法
提高ASP页面的执行效率(上)
提高ASP页面的执行效率(中)
提高ASP页面的执行效率(下)
ASP.Net中程序构架与程序代码的分离
如何用checkbox做多选删除
判断输入是否为中文的函数
将半角转换为中文的函数

ASP直接调用EXCEL数据的例子(不用ODBC)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 83 ::
收藏到网摘: n/a

  例子:
在"c:\excel\book1.xls"存在一个EXCEL表book1.xsl,表的结构如下:
1  序号    名称      金额
2    1        张三    100
3    2        李四    200
4    3        王五    300

序号字段不为空
注意:excel 起始行是1而不是为0

<%@language=vbscript %>
<%

Set xlApp = server.CreateObject("Excel.Application")

strsource = "c:\excel\book1.xls"

Set xlbook = xlApp.Workbooks.Open(strsource)
Set xlsheet = xlbook.Worksheets(1)

  i=1
  response.write "<table cellpadding=0 cellspacing=0 border=1 width=500>"
  while xlsheet.cells(i,1)<>""
  
  response.write "<tr>"
  response.write "  <td height=20 align=center width=100>" & xlsheet.Cells(i, 1) & "</td>"
  response.write "  <td height=20 align=center width=200>" & xlsheet.Cells(i, 2) & "</td>"
  response.write "  <td height=20 align=center width=200>" & xlsheet.Cells(i, 3) & "</td>"
  response.write "</tr>"
    i=i+1

  wend
    response.write "</table>"
set xlsheet=nothing
set xlbook=nothing
xlApp.quit  '千万记住要加这一句,否则每运行一次你的机器里就增加一个excel进程,而且无法释放。我试过"set
xlApp=nothing"是不行的。
%>