高分求教怎么在网页中把文字字段选取EXCEL文件导入到SQL SERVER2000,举一个完整的列子

zhurenweile 2003-09-24 03:26:21
高分求教怎么在网页中把文字字段选取EXCEL文件的内容追加到SQL SERVER2000相应的表中,举一个完整的列子,运行成功马上给分
...全文
47 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhurenweile 2003-09-24
  • 打赏
  • 举报
回复
程序的内容按如下编写,文件在C:\boox.xls
其中字段如下(a,b,c,d,e,f,g,l,k,m,n,p)
工作薄的名字xy
数据库名szdn,表ck(a,b,c,d,e,f,g,l,k,m,n,p)我怎么把boox.xls里的内容追加到
表ck里
我用的是excel2000,数据库是SQL server2000
ihyinger 2003-09-24
  • 打赏
  • 举报
回复
给你举个例子吧。能读出excel里面的数据。然后插入到数据库里面。按照这个思路能做到定制报表
<!-- #include file="../common.asp" -->
<!-- #include file="../flow/MainFunction.asp" -->
<%

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

strsource = server.MapPath("../Document/testexcal.xls")

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

response.write "<table cellpadding=0 cellspacing=0 border=1 width=500>"
response.write "<tr>"

for i=1 to 300 (excel行数)
for j=1 to 16(excel列数)

if j<16 then
String1 = String1 & "'" & xlsheet.Cells(i, j) & "',"
else
String1 = String1 & "'" & xlsheet.Cells(i, j) & "'"
end if
' response.write " <td height=20 align=center width=100>" & xlsheet.Cells(i, j) & "</td>"
next
sqlstr = "insert into ContractHistory (……) values ( "&String1&")"
Response.Write sqlstr & "<br>"

'dataconn.execute(sqlstr)
String1=""
' Response.End

next
response.write "</tr>"
response.write "</table>"
set xlsheet=nothing
set xlbook=nothing
xlApp.quit
%>

2,596

社区成员

发帖
与我相关
我的任务
社区描述
Sybase相关技术讨论区
社区管理员
  • Sybase社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧